Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751780AbcDQLjL (ORCPT ); Sun, 17 Apr 2016 07:39:11 -0400 Received: from mail3-relais-sop.national.inria.fr ([192.134.164.104]:35362 "EHLO mail3-relais-sop.national.inria.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751316AbcDQLjJ (ORCPT ); Sun, 17 Apr 2016 07:39:09 -0400 X-IronPort-AV: E=Sophos;i="5.24,497,1454972400"; d="scan'208";a="174757248" Date: Sun, 17 Apr 2016 13:39:01 +0200 (CEST) From: Julia Lawall X-X-Sender: jll@localhost6.localdomain6 To: Joe Perches cc: Andrew Morton , Andy Whitcroft , linux-kernel@vger.kernel.org, Davidlohr Bueso , Davidlohr Bueso Subject: Re: [PATCH] checkpatch: Whine about ACCESS_ONCE In-Reply-To: <1460881671.19090.90.camel@perches.com> Message-ID: References: <1460828078-5224-1-git-send-email-dave@stgolabs.net> <1460833453.19090.79.camel@perches.com> <1460836099.19090.82.camel@perches.com> <1460881671.19090.90.camel@perches.com> User-Agent: Alpine 2.02 (DEB 1266 2009-07-14) MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1904 Lines: 80 A suitably versatile semantic patch is below. Feel free to update at least the copyright line, and perhaps the initial explanation and the strings printed in report and org modes. julia /// Use READ_ONCE or WRITE_ONCE instead of ACCESS_ONCE. /// // Confidence: High // Copyright: (C) 2016 Joe Perches, afffiliation?, license? // Options: --no-includes --include-headers virtual patch virtual context virtual org virtual report @written depends on patch && !context && !org && !report@ expression e1; expression e2; @@ - ACCESS_ONCE(e1) = e2 + WRITE_ONCE(e1, e2) @read depends on patch && !context && !org && !report@ expression e1; @@ - ACCESS_ONCE(e1) + READ_ONCE(e1) // ---------------------------------------------------------------------------- @written_context depends on !patch && (context || org || report)@ expression e1, e2; position j0; @@ * ACCESS_ONCE@j0(e1) = e2 @read_context depends on !patch && (context || org || report)@ expression e1; position j0; @@ * ACCESS_ONCE@j0(e1) // ---------------------------------------------------------------------------- @script:python written_org depends on org@ j0 << written_context.j0; @@ msg = "Use WRITE_ONCE for an ACCESS_ONCE that is written." coccilib.org.print_todo(j0[0], msg, color="ovl-face2") @script:python read_org depends on org@ j0 << read_context.j0; @@ msg = "Use READ_ONCE for an ACCESS_ONCE that is read." coccilib.org.print_todo(j0[0], msg) // ---------------------------------------------------------------------------- @script:python written_report depends on report@ j0 << written_context.j0; @@ msg = "Use WRITE_ONCE for an ACCESS_ONCE that is written." coccilib.report.print_report(j0[0], msg) @script:python read_report depends on report@ j0 << read_context.j0; @@ msg = "Use READ_ONCE for an ACCESS_ONCE that is read." coccilib.report.print_report(j0[0], msg)