public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Himangi Saraogi <himangi774@gmail.com>
To: Julia Lawall <Julia.Lawall@lip6.fr>,
	Gilles Muller <Gilles.Muller@lip6.fr>,
	Nicolas Palix <nicolas.palix@imag.fr>,
	Michal Marek <mmarek@suse.cz>,
	cocci@systeme.lip6.fr, linux-kernel@vger.kernel.org
Cc: benoit.taine@lip6.fr
Subject: [PATCH] Coccinelle: Script to drop parenthesis in the return statements
Date: Thu, 19 Jun 2014 21:59:54 +0530	[thread overview]
Message-ID: <20140619162954.GA4698@himangi-Dell> (raw)

This script detects the use of a parenthesis around return value ot the
return statements and removes them as they are unnecessary and against
the CodingStyle. A new directory called checkpatch is added for semantic
patches that just make patches for what checkpatch does. This will help
developers having checkpatch problems, to run the semantic patches in this
directory on their code and fix some of them automatically.

Signed-off-by: Himangi Saraogi <himangi774@gmail.com>
Acked-by: Julia Lawall <julia.lawall@lip6.fr>
---
 .../coccinelle/checkpatch/drop_parenthesis.cocci   | 33 ++++++++++++++++++++++
 1 file changed, 33 insertions(+)
 create mode 100644 scripts/coccinelle/checkpatch/drop_parenthesis.cocci

diff --git a/scripts/coccinelle/checkpatch/drop_parenthesis.cocci b/scripts/coccinelle/checkpatch/drop_parenthesis.cocci
new file mode 100644
index 0000000..49c0538
--- /dev/null
+++ b/scripts/coccinelle/checkpatch/drop_parenthesis.cocci
@@ -0,0 +1,33 @@
+/// Remove parenthesis around return value in return statements
+///
+//# This makes an effort to find cases of parenthesis in the return
+//# statements when returning an identifier or a constant and removes
+//# the parenthesis as they are not required.
+//
+// Confidence: High
+// Copyright: 2014, Himangi Saraogi  GPLv2.
+// Comments:
+// Options: --no-includes --include-headers
+//
+
+virtual patch
+
+//----------------------------------------------------------
+//  For patch mode
+//----------------------------------------------------------
+
+@depends on patch disable paren@
+identifier a;
+constant C;
+@@
+ return
+-(
+(
+C
+|
+a
+)
+-)
+ ;
+
-- 
1.9.1


             reply	other threads:[~2014-06-19 16:30 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-06-19 16:29 Himangi Saraogi [this message]
2014-06-19 16:34 ` [PATCH] Coccinelle: Script to drop parenthesis in the return statements Joe Perches
2014-06-19 16:49   ` Julia Lawall
2014-06-19 16:59     ` Joe Perches
2014-06-20  5:22       ` Julia Lawall

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20140619162954.GA4698@himangi-Dell \
    --to=himangi774@gmail.com \
    --cc=Gilles.Muller@lip6.fr \
    --cc=Julia.Lawall@lip6.fr \
    --cc=benoit.taine@lip6.fr \
    --cc=cocci@systeme.lip6.fr \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mmarek@suse.cz \
    --cc=nicolas.palix@imag.fr \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox