All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] coccinelle: add style check for assignment in if
@ 2016-02-08 12:46 ` Kris Borer
  0 siblings, 0 replies; 16+ messages in thread
From: Kris Borer @ 2016-02-08 12:46 UTC (permalink / raw)
  To: mmarek
  Cc: Julia.Lawall, Gilles.Muller, nicolas.palix, linux-kernel, cocci,
	Kris Borer

Add a semantic patch for fixing some cases of checkpatch.pl error:

ERROR: do not use assignment in if condition

Signed-off-by: Kris Borer <kborer@gmail.com>
---
 scripts/coccinelle/style/assignment_in_if.cocci | 128 ++++++++++++++++++++++++
 1 file changed, 128 insertions(+)
 create mode 100644 scripts/coccinelle/style/assignment_in_if.cocci

diff --git a/scripts/coccinelle/style/assignment_in_if.cocci b/scripts/coccinelle/style/assignment_in_if.cocci
new file mode 100644
index 0000000..b23db8f
--- /dev/null
+++ b/scripts/coccinelle/style/assignment_in_if.cocci
@@ -0,0 +1,128 @@
+/// move assignments out of if conditions
+///
+//# This script is designed to correct code where assignments exist in if
+//# conditions. It is only capable of handling a subset of such problems.
+//# Ideally it would handle all checkpatch errors of the following type:
+//#	ERROR: do not use assignment in if condition
+//#
+//# For example:
+//#	if(result = myfun())
+//#
+//# would become:
+//#	result = myfun();
+//#	if(result)
+//
+// Confidence: Moderate
+// Copyright: (C) 2015 Kris Borer.  GPLv2.
+// URL: http://coccinelle.lip6.fr/
+// Comments:
+// Options: --no-includes --include-headers
+
+virtual patch
+
+
+// if ( (ret = call()) )
+// if ( (ret = call()) < 0 )
+@if1@
+expression i;
+expression E, E2;
+statement S1, S2;
+binary operator b;
+@@
+
++ i = E;
+  if (
+(
+- (i = E)
++ i
+|
+- (i = E)
++ i
+  b ...
+|
+- (i = E),
+  E2
+)
+  ) S1 else S2
+
+
+// if ( ptr->fun && (ret = ptr->fun()) )
+@if2@
+expression i2;
+expression E1, E2;
+@@
+
++ if( E1 ) {
++       i2 = E2;
++       if (i2) {
+- if( E1 && (i2 = E2) ) {
+  ...
+- }
++       }
++ }
+
+
+// if ( ptr->fun && (ret = ptr->fun()) < 0 )
+@if3@
+expression i2;
+expression E1, E2;
+constant c;
+binary operator b;
+@@
+
++ if( E1 ) {
++       i2 = E2;
++       if (i2 b c) {
+- if( E1 && ((i2 = E2) b c) ) {
+  ...
+- }
++       }
++ }
+
+
+// if ( (ret = call()) && ret != -1 )
+// if ( (ret = call()) < 0 && ret != -1 )
+@if4@
+expression i;
+expression E, E2;
+statement S1, S2;
+binary operator b;
+@@
+
++ i = E;
+  if (
+(
+- (i = E)
++ i
+|
+  (
+- (i = E)
++ i
+  b
+  ...)
+)
+  && E2 ) S1 else S2
+
+
+// if ( (ret = call()) && ret != -1 && ret != -2 )
+// if ( (ret = call()) < 0 && ret != -1 && ret != -2 )
+@if5@
+expression i;
+expression E, E2, E3;
+statement S1, S2;
+binary operator b;
+@@
+
++ i = E;
+  if (
+(
+- (i = E)
++ i
+|
+  (
+- (i = E)
++ i
+  b
+  ...)
+)
+  && E2 && E3 ) S1 else S2
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [Cocci] [PATCH v2] coccinelle: add style check for assignment in if
@ 2016-02-08 12:46 ` Kris Borer
  0 siblings, 0 replies; 16+ messages in thread
From: Kris Borer @ 2016-02-08 12:46 UTC (permalink / raw)
  To: cocci

Add a semantic patch for fixing some cases of checkpatch.pl error:

ERROR: do not use assignment in if condition

Signed-off-by: Kris Borer <kborer@gmail.com>
---
 scripts/coccinelle/style/assignment_in_if.cocci | 128 ++++++++++++++++++++++++
 1 file changed, 128 insertions(+)
 create mode 100644 scripts/coccinelle/style/assignment_in_if.cocci

diff --git a/scripts/coccinelle/style/assignment_in_if.cocci b/scripts/coccinelle/style/assignment_in_if.cocci
new file mode 100644
index 0000000..b23db8f
--- /dev/null
+++ b/scripts/coccinelle/style/assignment_in_if.cocci
@@ -0,0 +1,128 @@
+/// move assignments out of if conditions
+///
+//# This script is designed to correct code where assignments exist in if
+//# conditions. It is only capable of handling a subset of such problems.
+//# Ideally it would handle all checkpatch errors of the following type:
+//#	ERROR: do not use assignment in if condition
+//#
+//# For example:
+//#	if(result = myfun())
+//#
+//# would become:
+//#	result = myfun();
+//#	if(result)
+//
+// Confidence: Moderate
+// Copyright: (C) 2015 Kris Borer.  GPLv2.
+// URL: http://coccinelle.lip6.fr/
+// Comments:
+// Options: --no-includes --include-headers
+
+virtual patch
+
+
+// if ( (ret = call()) )
+// if ( (ret = call()) < 0 )
+@if1@
+expression i;
+expression E, E2;
+statement S1, S2;
+binary operator b;
+@@
+
++ i = E;
+  if (
+(
+- (i = E)
++ i
+|
+- (i = E)
++ i
+  b ...
+|
+- (i = E),
+  E2
+)
+  ) S1 else S2
+
+
+// if ( ptr->fun && (ret = ptr->fun()) )
+ at if2@
+expression i2;
+expression E1, E2;
+@@
+
++ if( E1 ) {
++       i2 = E2;
++       if (i2) {
+- if( E1 && (i2 = E2) ) {
+  ...
+- }
++       }
++ }
+
+
+// if ( ptr->fun && (ret = ptr->fun()) < 0 )
+ at if3@
+expression i2;
+expression E1, E2;
+constant c;
+binary operator b;
+@@
+
++ if( E1 ) {
++       i2 = E2;
++       if (i2 b c) {
+- if( E1 && ((i2 = E2) b c) ) {
+  ...
+- }
++       }
++ }
+
+
+// if ( (ret = call()) && ret != -1 )
+// if ( (ret = call()) < 0 && ret != -1 )
+ at if4@
+expression i;
+expression E, E2;
+statement S1, S2;
+binary operator b;
+@@
+
++ i = E;
+  if (
+(
+- (i = E)
++ i
+|
+  (
+- (i = E)
++ i
+  b
+  ...)
+)
+  && E2 ) S1 else S2
+
+
+// if ( (ret = call()) && ret != -1 && ret != -2 )
+// if ( (ret = call()) < 0 && ret != -1 && ret != -2 )
+@if5@
+expression i;
+expression E, E2, E3;
+statement S1, S2;
+binary operator b;
+@@
+
++ i = E;
+  if (
+(
+- (i = E)
++ i
+|
+  (
+- (i = E)
++ i
+  b
+  ...)
+)
+  && E2 && E3 ) S1 else S2
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 16+ messages in thread

* Re: [PATCH v2] coccinelle: add style check for assignment in if
  2016-02-08 12:46 ` [Cocci] " Kris Borer
@ 2016-02-09  8:27   ` SF Markus Elfring
  -1 siblings, 0 replies; 16+ messages in thread
From: SF Markus Elfring @ 2016-02-09  8:27 UTC (permalink / raw)
  To: Kris Borer
  Cc: Michal Marek, Julia Lawall, Gilles Muller, Nicolas Palix,
	linux-kernel, cocci

> +virtual patch

How do you think about to use this variable in a subsequent
SmPL rule?

Would you like to consider also the reuse of SmPL variables
like "org" and "report"?

Regards,
Markus

^ permalink raw reply	[flat|nested] 16+ messages in thread

* [Cocci] [PATCH v2] coccinelle: add style check for assignment in if
@ 2016-02-09  8:27   ` SF Markus Elfring
  0 siblings, 0 replies; 16+ messages in thread
From: SF Markus Elfring @ 2016-02-09  8:27 UTC (permalink / raw)
  To: cocci

> +virtual patch

How do you think about to use this variable in a subsequent
SmPL rule?

Would you like to consider also the reuse of SmPL variables
like "org" and "report"?

Regards,
Markus

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH v2] coccinelle: add style check for assignment in if
  2016-02-09  8:27   ` [Cocci] " SF Markus Elfring
@ 2016-02-09  9:18     ` Julia Lawall
  -1 siblings, 0 replies; 16+ messages in thread
From: Julia Lawall @ 2016-02-09  9:18 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: Kris Borer, Michal Marek, Gilles Muller, Nicolas Palix,
	linux-kernel, cocci



On Tue, 9 Feb 2016, SF Markus Elfring wrote:

> > +virtual patch
>
> How do you think about to use this variable in a subsequent
> SmPL rule?
>
> Would you like to consider also the reuse of SmPL variables
> like "org" and "report"?

I think that there is no point for these things, because checkpatch
already gives warnings about this issue.

It could be nice for the provided rules to actually depend on patch.  But
in the context of make coccicheck, it doesn't matter, because attempts to
run the rule in another mode will just fail, due to the mode not being
declared.

julia

^ permalink raw reply	[flat|nested] 16+ messages in thread

* [Cocci] [PATCH v2] coccinelle: add style check for assignment in if
@ 2016-02-09  9:18     ` Julia Lawall
  0 siblings, 0 replies; 16+ messages in thread
From: Julia Lawall @ 2016-02-09  9:18 UTC (permalink / raw)
  To: cocci



On Tue, 9 Feb 2016, SF Markus Elfring wrote:

> > +virtual patch
>
> How do you think about to use this variable in a subsequent
> SmPL rule?
>
> Would you like to consider also the reuse of SmPL variables
> like "org" and "report"?

I think that there is no point for these things, because checkpatch
already gives warnings about this issue.

It could be nice for the provided rules to actually depend on patch.  But
in the context of make coccicheck, it doesn't matter, because attempts to
run the rule in another mode will just fail, due to the mode not being
declared.

julia

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: coccinelle: add style check for assignment in if
  2016-02-09  9:18     ` [Cocci] " Julia Lawall
@ 2016-02-09 12:55       ` SF Markus Elfring
  -1 siblings, 0 replies; 16+ messages in thread
From: SF Markus Elfring @ 2016-02-09 12:55 UTC (permalink / raw)
  To: Julia Lawall
  Cc: Kris Borer, Michal Marek, Gilles Muller, Nicolas Palix,
	linux-kernel, cocci

>> Would you like to consider also the reuse of SmPL variables
>> like "org" and "report"?
> 
> I think that there is no point for these things, because checkpatch
> already gives warnings about this issue.

Can the check result display be more convenient from the semantic
patch script interface in comparison to the other tool?

Regards,
Markus

^ permalink raw reply	[flat|nested] 16+ messages in thread

* [Cocci] coccinelle: add style check for assignment in if
@ 2016-02-09 12:55       ` SF Markus Elfring
  0 siblings, 0 replies; 16+ messages in thread
From: SF Markus Elfring @ 2016-02-09 12:55 UTC (permalink / raw)
  To: cocci

>> Would you like to consider also the reuse of SmPL variables
>> like "org" and "report"?
> 
> I think that there is no point for these things, because checkpatch
> already gives warnings about this issue.

Can the check result display be more convenient from the semantic
patch script interface in comparison to the other tool?

Regards,
Markus

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: coccinelle: add style check for assignment in if
  2016-02-09 12:55       ` [Cocci] " SF Markus Elfring
@ 2016-02-09 23:56         ` Joe Perches
  -1 siblings, 0 replies; 16+ messages in thread
From: Joe Perches @ 2016-02-09 23:56 UTC (permalink / raw)
  To: SF Markus Elfring, Julia Lawall
  Cc: Kris Borer, Michal Marek, Gilles Muller, Nicolas Palix,
	linux-kernel, cocci

On Tue, 2016-02-09 at 13:55 +0100, SF Markus Elfring wrote:
> > > Would you like to consider also the reuse of SmPL variables
> > > like "org" and "report"?
> > 
> > I think that there is no point for these things, because checkpatch
> > already gives warnings about this issue.
> 
> Can the check result display be more convenient from the semantic
> patch script interface in comparison to the other tool?

-ENOPARSE.  More detail please.

^ permalink raw reply	[flat|nested] 16+ messages in thread

* [Cocci] coccinelle: add style check for assignment in if
@ 2016-02-09 23:56         ` Joe Perches
  0 siblings, 0 replies; 16+ messages in thread
From: Joe Perches @ 2016-02-09 23:56 UTC (permalink / raw)
  To: cocci

On Tue, 2016-02-09 at 13:55 +0100, SF Markus Elfring wrote:
> > > Would you like to consider also the reuse of SmPL variables
> > > like "org" and "report"?
> > 
> > I think that there is no point for these things, because checkpatch
> > already gives warnings about this issue.
> 
> Can the check result display be more convenient from the semantic
> patch script interface in comparison to the other tool?

-ENOPARSE. ?More detail please.

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: coccinelle: add style check for assignment in if
  2016-02-09 23:56         ` [Cocci] " Joe Perches
@ 2016-02-10  9:00           ` SF Markus Elfring
  -1 siblings, 0 replies; 16+ messages in thread
From: SF Markus Elfring @ 2016-02-10  9:00 UTC (permalink / raw)
  To: Joe Perches
  Cc: Julia Lawall, Kris Borer, Michal Marek, Gilles Muller,
	Nicolas Palix, linux-kernel, cocci

>> Can the check result display be more convenient from the semantic
>> patch script interface in comparison to the other tool?
> 
> -ENOPARSE.  More detail please.

Kris Borer suggested a SmPL script which can generate (only) patches
so far by the usual application of the Coccinelle software.
I assume that this approach was limited just because Julia Lawall
indicated that this functionality would be sufficient for a while.

The documentation for the command "make coccicheck" mentions
additional modes.
https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/Documentation/coccinelle.txt?id=ec97946ed038f4b3faa587bc76152b198805b0c4#n170

They refer to specific output formats for the result from the
static source code analysis.

* How often would you like to look at proposed changes by the
  Org mode format (of Emacs)?
  http://orgmode.org/

* Do you find the report mode also useful occasionally?


Are you interested to get further output variants?

Examples:
* CSV
* XML

Regards,
Markus

^ permalink raw reply	[flat|nested] 16+ messages in thread

* [Cocci] coccinelle: add style check for assignment in if
@ 2016-02-10  9:00           ` SF Markus Elfring
  0 siblings, 0 replies; 16+ messages in thread
From: SF Markus Elfring @ 2016-02-10  9:00 UTC (permalink / raw)
  To: cocci

>> Can the check result display be more convenient from the semantic
>> patch script interface in comparison to the other tool?
> 
> -ENOPARSE.  More detail please.

Kris Borer suggested a SmPL script which can generate (only) patches
so far by the usual application of the Coccinelle software.
I assume that this approach was limited just because Julia Lawall
indicated that this functionality would be sufficient for a while.

The documentation for the command "make coccicheck" mentions
additional modes.
https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/Documentation/coccinelle.txt?id=ec97946ed038f4b3faa587bc76152b198805b0c4#n170

They refer to specific output formats for the result from the
static source code analysis.

* How often would you like to look at proposed changes by the
  Org mode format (of Emacs)?
  http://orgmode.org/

* Do you find the report mode also useful occasionally?


Are you interested to get further output variants?

Examples:
* CSV
* XML

Regards,
Markus

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: coccinelle: add style check for assignment in if
  2016-02-10  9:00           ` [Cocci] " SF Markus Elfring
@ 2016-02-10 15:06             ` Kris Borer
  -1 siblings, 0 replies; 16+ messages in thread
From: Kris Borer @ 2016-02-10 15:06 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: Joe Perches, Julia Lawall, Michal Marek, Gilles Muller,
	Nicolas Palix, linux-kernel, cocci

On Wed, Feb 10, 2016 at 4:00 AM, SF Markus Elfring
<elfring@users.sourceforge.net> wrote:
> Kris Borer suggested a SmPL script which can generate (only) patches
> so far by the usual application of the Coccinelle software.
> I assume that this approach was limited just because Julia Lawall
> indicated that this functionality would be sufficient for a while.
>
> * Do you find the report mode also useful occasionally?
>
> Are you interested to get further output variants?
>
> Examples:
> * CSV
> * XML

I would happy to add additional modes or features, but I would prefer
to do those in a separate patch if possible.

^ permalink raw reply	[flat|nested] 16+ messages in thread

* [Cocci] coccinelle: add style check for assignment in if
@ 2016-02-10 15:06             ` Kris Borer
  0 siblings, 0 replies; 16+ messages in thread
From: Kris Borer @ 2016-02-10 15:06 UTC (permalink / raw)
  To: cocci

On Wed, Feb 10, 2016 at 4:00 AM, SF Markus Elfring
<elfring@users.sourceforge.net> wrote:
> Kris Borer suggested a SmPL script which can generate (only) patches
> so far by the usual application of the Coccinelle software.
> I assume that this approach was limited just because Julia Lawall
> indicated that this functionality would be sufficient for a while.
>
> * Do you find the report mode also useful occasionally?
>
> Are you interested to get further output variants?
>
> Examples:
> * CSV
> * XML

I would happy to add additional modes or features, but I would prefer
to do those in a separate patch if possible.

^ permalink raw reply	[flat|nested] 16+ messages in thread

* [PATCH v2] coccinelle: add style check for assignment in if
@ 2015-11-17 16:34 Kris Borer
  0 siblings, 0 replies; 16+ messages in thread
From: Kris Borer @ 2015-11-17 16:34 UTC (permalink / raw)
  To: mmarek
  Cc: Julia.Lawall, Gilles.Muller, nicolas.palix, linux-kernel, cocci,
	Kris Borer

Add a semantic patch for fixing some cases of checkpatch.pl error:

ERROR: do not use assignment in if condition

Signed-off-by: Kris Borer <kborer@gmail.com>
---
 scripts/coccinelle/style/assignment_in_if.cocci | 128 ++++++++++++++++++++++++
 1 file changed, 128 insertions(+)
 create mode 100644 scripts/coccinelle/style/assignment_in_if.cocci

diff --git a/scripts/coccinelle/style/assignment_in_if.cocci b/scripts/coccinelle/style/assignment_in_if.cocci
new file mode 100644
index 0000000..b23db8f
--- /dev/null
+++ b/scripts/coccinelle/style/assignment_in_if.cocci
@@ -0,0 +1,128 @@
+/// move assignments out of if conditions
+///
+//# This script is designed to correct code where assignments exist in if
+//# conditions. It is only capable of handling a subset of such problems.
+//# Ideally it would handle all checkpatch errors of the following type:
+//#	ERROR: do not use assignment in if condition
+//#
+//# For example:
+//#	if(result = myfun())
+//#
+//# would become:
+//#	result = myfun();
+//#	if(result)
+//
+// Confidence: Moderate
+// Copyright: (C) 2015 Kris Borer.  GPLv2.
+// URL: http://coccinelle.lip6.fr/
+// Comments:
+// Options: --no-includes --include-headers
+
+virtual patch
+
+
+// if ( (ret = call()) )
+// if ( (ret = call()) < 0 )
+@if1@
+expression i;
+expression E, E2;
+statement S1, S2;
+binary operator b;
+@@
+
++ i = E;
+  if (
+(
+- (i = E)
++ i
+|
+- (i = E)
++ i
+  b ...
+|
+- (i = E),
+  E2
+)
+  ) S1 else S2
+
+
+// if ( ptr->fun && (ret = ptr->fun()) )
+@if2@
+expression i2;
+expression E1, E2;
+@@
+
++ if( E1 ) {
++       i2 = E2;
++       if (i2) {
+- if( E1 && (i2 = E2) ) {
+  ...
+- }
++       }
++ }
+
+
+// if ( ptr->fun && (ret = ptr->fun()) < 0 )
+@if3@
+expression i2;
+expression E1, E2;
+constant c;
+binary operator b;
+@@
+
++ if( E1 ) {
++       i2 = E2;
++       if (i2 b c) {
+- if( E1 && ((i2 = E2) b c) ) {
+  ...
+- }
++       }
++ }
+
+
+// if ( (ret = call()) && ret != -1 )
+// if ( (ret = call()) < 0 && ret != -1 )
+@if4@
+expression i;
+expression E, E2;
+statement S1, S2;
+binary operator b;
+@@
+
++ i = E;
+  if (
+(
+- (i = E)
++ i
+|
+  (
+- (i = E)
++ i
+  b
+  ...)
+)
+  && E2 ) S1 else S2
+
+
+// if ( (ret = call()) && ret != -1 && ret != -2 )
+// if ( (ret = call()) < 0 && ret != -1 && ret != -2 )
+@if5@
+expression i;
+expression E, E2, E3;
+statement S1, S2;
+binary operator b;
+@@
+
++ i = E;
+  if (
+(
+- (i = E)
++ i
+|
+  (
+- (i = E)
++ i
+  b
+  ...)
+)
+  && E2 && E3 ) S1 else S2
-- 
1.9.1


^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH v2] coccinelle: add style check for assignment in if
@ 2015-08-22 17:04 Kris Borer
  0 siblings, 0 replies; 16+ messages in thread
From: Kris Borer @ 2015-08-22 17:04 UTC (permalink / raw)
  To: Julia.Lawall
  Cc: Gilles.Muller, nicolas.palix, mmarek, linux-kernel, cocci, Kris Borer

Add a semantic patch for fixing some cases of checkpatch.pl error:

ERROR: do not use assignment in if condition

Signed-off-by: Kris Borer <kborer@gmail.com>
Acked-by: Julia Lawall <julia.lawall@lip6.fr>
---
 scripts/coccinelle/style/assignment_in_if.cocci | 128 ++++++++++++++++++++++++
 1 file changed, 128 insertions(+)
 create mode 100644 scripts/coccinelle/style/assignment_in_if.cocci

diff --git a/scripts/coccinelle/style/assignment_in_if.cocci b/scripts/coccinelle/style/assignment_in_if.cocci
new file mode 100644
index 0000000..b23db8f
--- /dev/null
+++ b/scripts/coccinelle/style/assignment_in_if.cocci
@@ -0,0 +1,128 @@
+/// move assignments out of if conditions
+///
+//# This script is designed to correct code where assignments exist in if
+//# conditions. It is only capable of handling a subset of such problems.
+//# Ideally it would handle all checkpatch errors of the following type:
+//#	ERROR: do not use assignment in if condition
+//#
+//# For example:
+//#	if(result = myfun())
+//#
+//# would become:
+//#	result = myfun();
+//#	if(result)
+//
+// Confidence: Moderate
+// Copyright: (C) 2015 Kris Borer.  GPLv2.
+// URL: http://coccinelle.lip6.fr/
+// Comments:
+// Options: --no-includes --include-headers
+
+virtual patch
+
+
+// if ( (ret = call()) )
+// if ( (ret = call()) < 0 )
+@if1@
+expression i;
+expression E, E2;
+statement S1, S2;
+binary operator b;
+@@
+
++ i = E;
+  if (
+(
+- (i = E)
++ i
+|
+- (i = E)
++ i
+  b ...
+|
+- (i = E),
+  E2
+)
+  ) S1 else S2
+
+
+// if ( ptr->fun && (ret = ptr->fun()) )
+@if2@
+expression i2;
+expression E1, E2;
+@@
+
++ if( E1 ) {
++       i2 = E2;
++       if (i2) {
+- if( E1 && (i2 = E2) ) {
+  ...
+- }
++       }
++ }
+
+
+// if ( ptr->fun && (ret = ptr->fun()) < 0 )
+@if3@
+expression i2;
+expression E1, E2;
+constant c;
+binary operator b;
+@@
+
++ if( E1 ) {
++       i2 = E2;
++       if (i2 b c) {
+- if( E1 && ((i2 = E2) b c) ) {
+  ...
+- }
++       }
++ }
+
+
+// if ( (ret = call()) && ret != -1 )
+// if ( (ret = call()) < 0 && ret != -1 )
+@if4@
+expression i;
+expression E, E2;
+statement S1, S2;
+binary operator b;
+@@
+
++ i = E;
+  if (
+(
+- (i = E)
++ i
+|
+  (
+- (i = E)
++ i
+  b
+  ...)
+)
+  && E2 ) S1 else S2
+
+
+// if ( (ret = call()) && ret != -1 && ret != -2 )
+// if ( (ret = call()) < 0 && ret != -1 && ret != -2 )
+@if5@
+expression i;
+expression E, E2, E3;
+statement S1, S2;
+binary operator b;
+@@
+
++ i = E;
+  if (
+(
+- (i = E)
++ i
+|
+  (
+- (i = E)
++ i
+  b
+  ...)
+)
+  && E2 && E3 ) S1 else S2
-- 
1.9.1


^ permalink raw reply related	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2016-02-10 15:06 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-02-08 12:46 [PATCH v2] coccinelle: add style check for assignment in if Kris Borer
2016-02-08 12:46 ` [Cocci] " Kris Borer
2016-02-09  8:27 ` SF Markus Elfring
2016-02-09  8:27   ` [Cocci] " SF Markus Elfring
2016-02-09  9:18   ` Julia Lawall
2016-02-09  9:18     ` [Cocci] " Julia Lawall
2016-02-09 12:55     ` SF Markus Elfring
2016-02-09 12:55       ` [Cocci] " SF Markus Elfring
2016-02-09 23:56       ` Joe Perches
2016-02-09 23:56         ` [Cocci] " Joe Perches
2016-02-10  9:00         ` SF Markus Elfring
2016-02-10  9:00           ` [Cocci] " SF Markus Elfring
2016-02-10 15:06           ` Kris Borer
2016-02-10 15:06             ` [Cocci] " Kris Borer
  -- strict thread matches above, loose matches on Subject: below --
2015-11-17 16:34 [PATCH v2] " Kris Borer
2015-08-22 17:04 Kris Borer

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.