From patchwork Sun Jun 6 15:15:06 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicolas Palix X-Patchwork-Id: 104593 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter.kernel.org (8.14.3/8.14.3) with ESMTP id o56FHUNO014543 for ; Sun, 6 Jun 2010 15:17:34 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757942Ab0FFPPn (ORCPT ); Sun, 6 Jun 2010 11:15:43 -0400 Received: from mgw2.diku.dk ([130.225.96.92]:51378 "EHLO mgw2.diku.dk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1758005Ab0FFPPd (ORCPT ); Sun, 6 Jun 2010 11:15:33 -0400 Received: from localhost (localhost [127.0.0.1]) by mgw2.diku.dk (Postfix) with ESMTP id 13A4519BBFF; Sun, 6 Jun 2010 17:15:33 +0200 (CEST) Received: from mgw2.diku.dk ([127.0.0.1]) by localhost (mgw2.diku.dk [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 21915-07; Sun, 6 Jun 2010 17:15:28 +0200 (CEST) Received: from nhugin.diku.dk (nhugin.diku.dk [130.225.96.140]) by mgw2.diku.dk (Postfix) with ESMTP id AD02619BBFA; Sun, 6 Jun 2010 17:15:28 +0200 (CEST) Received: from localhost.localdomain (tyr.diku.dk [130.225.96.226]) by nhugin.diku.dk (Postfix) with ESMTP id 7B0CD6DFD3E; Sun, 6 Jun 2010 17:07:46 +0200 (CEST) From: Nicolas Palix To: Randy Dunlap , Roland Dreier , Joe Perches , Andrew Morton , "David S. Miller" , Michal Marek , Sam Ravnborg , Julia Lawall , Gilles Muller , linux-kernel@vger.kernel.org, linux-kbuild@vger.kernel.org, cocci@diku.dk, Wolfram Sang , Kernel Janitors , =?UTF-8?q?Am=C3=A9rico=20Wang?= , Andy Isaacson , Linus Torvalds , Pekka Enberg , walter harms , Joerg Roedel , Jan Engelhardt Cc: Nicolas Palix Subject: [PATCH 6/7] Add scripts/coccinelle/err_cast.cocci Date: Sun, 6 Jun 2010 17:15:06 +0200 Message-Id: <1275837307-4283-7-git-send-email-npalix@diku.dk> X-Mailer: git-send-email 1.7.0.4 In-Reply-To: <1275837307-4283-1-git-send-email-npalix@diku.dk> References: <1275837307-4283-1-git-send-email-npalix@diku.dk> Sender: linux-kbuild-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kbuild@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter.kernel.org [140.211.167.41]); Sun, 06 Jun 2010 15:17:34 +0000 (UTC) diff --git a/scripts/coccinelle/err_cast.cocci b/scripts/coccinelle/err_cast.cocci new file mode 100644 index 0000000..2ce1150 --- /dev/null +++ b/scripts/coccinelle/err_cast.cocci @@ -0,0 +1,56 @@ +/// +/// Use ERR_CAST inlined function instead of ERR_PTR(PTR_ERR(...)) +/// +// Confidence: High +// Copyright: (C) 2009, 2010 Nicolas Palix, DIKU. GPLv2. +// Copyright: (C) 2009, 2010 Julia Lawall, DIKU. GPLv2. +// Copyright: (C) 2009, 2010 Gilles Muller, INRIA/LiP6. GPLv2. +// URL: http://coccinelle.lip6.fr/ +// Options: +// +// Keywords: ERR_PTR, PTR_ERR, ERR_CAST +// Version min: 2.6.25 +// + +virtual context +virtual patch +virtual org +virtual report + + +@ depends on context && !patch && !org && !report@ +expression x; +@@ + +* ERR_PTR(PTR_ERR(x)) + +@ depends on !context && patch && !org && !report @ +expression x; +@@ + +- ERR_PTR(PTR_ERR(x)) ++ ERR_CAST(x) + +@r depends on !context && !patch && (org || report)@ +expression x; +position p; +@@ + + ERR_PTR@p(PTR_ERR(x)) + +@script:python depends on org@ +p << r.p; +x << r.x; +@@ + +msg="WARNING ERR_CAST can be used with %s" % (x) +msg_safe=msg.replace("[","@(").replace("]",")") +coccilib.org.print_todo(p[0], msg_safe) + +@script:python depends on report@ +p << r.p; +x << r.x; +@@ + +msg="WARNING: ERR_CAST can be used with %s" % (x) +coccilib.report.print_report(p[0], msg)