* [PATCH/RFC] coccinelle: replace 0/1 with false/true in functions returning bool
@ 2013-08-09 16:15 ` Rasmus Villemoes
0 siblings, 0 replies; 12+ messages in thread
From: Rasmus Villemoes @ 2013-08-09 16:15 UTC (permalink / raw)
To: Julia Lawall, Gilles Muller, Nicolas Palix, Michal Marek
Cc: linux-kernel, cocci, Rasmus Villemoes
This semantic patch replaces "return {0,1};" with "return
{false,true};" in functions returning bool. There doesn't seem to be
any false positives, but some whitespace mangling is happening, for
example:
diff -u -p a/block/blk-throttle.c b/block/blk-throttle.c
--- a/block/blk-throttle.c
+++ b/block/blk-throttle.c
@@ -734,9 +734,7 @@ static inline void throtl_extend_slice(s
static bool throtl_slice_used(struct throtl_grp *tg, bool rw)
{
if (time_in_range(jiffies, tg->slice_start[rw], tg->slice_end[rw]))
- return 0;
-
- return 1;
+ return false;return true;
}
Is there a way to prevent this, or is this the kind of thing which
must be handled in post-processing?
Signed-off-by: Rasmus Villemoes <linux@rasmusvillemoes.dk>
---
scripts/coccinelle/misc/boolreturn.cocci | 51 ++++++++++++++++++++++++++++++
1 file changed, 51 insertions(+)
create mode 100644 scripts/coccinelle/misc/boolreturn.cocci
diff --git a/scripts/coccinelle/misc/boolreturn.cocci b/scripts/coccinelle/misc/boolreturn.cocci
new file mode 100644
index 0000000..e6ece0d
--- /dev/null
+++ b/scripts/coccinelle/misc/boolreturn.cocci
@@ -0,0 +1,51 @@
+/// Return statements in functions returning bool should use
+/// true/false instead of 1/0.
+//
+
+virtual patch
+virtual report
+
+
+@r1 depends on patch@
+identifier fn;
+typedef bool;
+symbol false;
+symbol true;
+@@
+
+bool fn ( ... )
+{
+...
+(
+- return 0;
++ return false;
+|
+- return 1;
++ return true;
+)
+...
+}
+
+@r2 depends on !patch@
+identifier fn;
+position p;
+@@
+
+bool fn ( ... )
+{
+ ...
+(
+* return 0@p ;
+|
+* return 1@p ;
+)
+ ...
+}
+
+
+@script:python depends on report@
+p << r2.p;
+fn << r2.fn;
+@@
+
+coccilib.report.print_report(p[0], "WARNING: return of 0/1 in function '%s' with return type bool" % fn)
--
1.7.9.5
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [Cocci] [PATCH/RFC] coccinelle: replace 0/1 with false/true in functions returning bool
@ 2013-08-09 16:15 ` Rasmus Villemoes
0 siblings, 0 replies; 12+ messages in thread
From: Rasmus Villemoes @ 2013-08-09 16:15 UTC (permalink / raw)
To: cocci
This semantic patch replaces "return {0,1};" with "return
{false,true};" in functions returning bool. There doesn't seem to be
any false positives, but some whitespace mangling is happening, for
example:
diff -u -p a/block/blk-throttle.c b/block/blk-throttle.c
--- a/block/blk-throttle.c
+++ b/block/blk-throttle.c
@@ -734,9 +734,7 @@ static inline void throtl_extend_slice(s
static bool throtl_slice_used(struct throtl_grp *tg, bool rw)
{
if (time_in_range(jiffies, tg->slice_start[rw], tg->slice_end[rw]))
- return 0;
-
- return 1;
+ return false;return true;
}
Is there a way to prevent this, or is this the kind of thing which
must be handled in post-processing?
Signed-off-by: Rasmus Villemoes <linux@rasmusvillemoes.dk>
---
scripts/coccinelle/misc/boolreturn.cocci | 51 ++++++++++++++++++++++++++++++
1 file changed, 51 insertions(+)
create mode 100644 scripts/coccinelle/misc/boolreturn.cocci
diff --git a/scripts/coccinelle/misc/boolreturn.cocci b/scripts/coccinelle/misc/boolreturn.cocci
new file mode 100644
index 0000000..e6ece0d
--- /dev/null
+++ b/scripts/coccinelle/misc/boolreturn.cocci
@@ -0,0 +1,51 @@
+/// Return statements in functions returning bool should use
+/// true/false instead of 1/0.
+//
+
+virtual patch
+virtual report
+
+
+ at r1 depends on patch@
+identifier fn;
+typedef bool;
+symbol false;
+symbol true;
+@@
+
+bool fn ( ... )
+{
+...
+(
+- return 0;
++ return false;
+|
+- return 1;
++ return true;
+)
+...
+}
+
+ at r2 depends on !patch@
+identifier fn;
+position p;
+@@
+
+bool fn ( ... )
+{
+ ...
+(
+* return 0 at p ;
+|
+* return 1 at p ;
+)
+ ...
+}
+
+
+ at script:python depends on report@
+p << r2.p;
+fn << r2.fn;
+@@
+
+coccilib.report.print_report(p[0], "WARNING: return of 0/1 in function '%s' with return type bool" % fn)
--
1.7.9.5
^ permalink raw reply related [flat|nested] 12+ messages in thread
* Re: [PATCH/RFC] coccinelle: replace 0/1 with false/true in functions returning bool
2013-08-09 16:15 ` [Cocci] " Rasmus Villemoes
@ 2013-08-09 16:18 ` Julia Lawall
-1 siblings, 0 replies; 12+ messages in thread
From: Julia Lawall @ 2013-08-09 16:18 UTC (permalink / raw)
To: Rasmus Villemoes
Cc: Gilles Muller, Nicolas Palix, Michal Marek, linux-kernel, cocci
On Fri, 9 Aug 2013, Rasmus Villemoes wrote:
> This semantic patch replaces "return {0,1};" with "return
> {false,true};" in functions returning bool. There doesn't seem to be
> any false positives, but some whitespace mangling is happening, for
> example:
When you change the argument to return, you don't have to recopy the whole
thing.
return
- 0
+ false
;
In general, if it is not too inconvenient, it is better not to recopy
code. That way you are sure that the spaces and newlines will not be
touched. In this case, it looks like a bug in the pretty printer, but it
it easy to avoid it.
julia
> diff -u -p a/block/blk-throttle.c b/block/blk-throttle.c
> --- a/block/blk-throttle.c
> +++ b/block/blk-throttle.c
> @@ -734,9 +734,7 @@ static inline void throtl_extend_slice(s
> static bool throtl_slice_used(struct throtl_grp *tg, bool rw)
> {
> if (time_in_range(jiffies, tg->slice_start[rw], tg->slice_end[rw]))
> - return 0;
> -
> - return 1;
> + return false;return true;
> }
>
> Is there a way to prevent this, or is this the kind of thing which
> must be handled in post-processing?
>
> Signed-off-by: Rasmus Villemoes <linux@rasmusvillemoes.dk>
> ---
> scripts/coccinelle/misc/boolreturn.cocci | 51 ++++++++++++++++++++++++++++++
> 1 file changed, 51 insertions(+)
> create mode 100644 scripts/coccinelle/misc/boolreturn.cocci
>
> diff --git a/scripts/coccinelle/misc/boolreturn.cocci b/scripts/coccinelle/misc/boolreturn.cocci
> new file mode 100644
> index 0000000..e6ece0d
> --- /dev/null
> +++ b/scripts/coccinelle/misc/boolreturn.cocci
> @@ -0,0 +1,51 @@
> +/// Return statements in functions returning bool should use
> +/// true/false instead of 1/0.
> +//
> +
> +virtual patch
> +virtual report
> +
> +
> +@r1 depends on patch@
> +identifier fn;
> +typedef bool;
> +symbol false;
> +symbol true;
> +@@
> +
> +bool fn ( ... )
> +{
> +...
> +(
> +- return 0;
> ++ return false;
> +|
> +- return 1;
> ++ return true;
> +)
> +...
> +}
> +
> +@r2 depends on !patch@
> +identifier fn;
> +position p;
> +@@
> +
> +bool fn ( ... )
> +{
> + ...
> +(
> +* return 0@p ;
> +|
> +* return 1@p ;
> +)
> + ...
> +}
> +
> +
> +@script:python depends on report@
> +p << r2.p;
> +fn << r2.fn;
> +@@
> +
> +coccilib.report.print_report(p[0], "WARNING: return of 0/1 in function '%s' with return type bool" % fn)
> --
> 1.7.9.5
>
>
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Cocci] [PATCH/RFC] coccinelle: replace 0/1 with false/true in functions returning bool
@ 2013-08-09 16:18 ` Julia Lawall
0 siblings, 0 replies; 12+ messages in thread
From: Julia Lawall @ 2013-08-09 16:18 UTC (permalink / raw)
To: cocci
On Fri, 9 Aug 2013, Rasmus Villemoes wrote:
> This semantic patch replaces "return {0,1};" with "return
> {false,true};" in functions returning bool. There doesn't seem to be
> any false positives, but some whitespace mangling is happening, for
> example:
When you change the argument to return, you don't have to recopy the whole
thing.
return
- 0
+ false
;
In general, if it is not too inconvenient, it is better not to recopy
code. That way you are sure that the spaces and newlines will not be
touched. In this case, it looks like a bug in the pretty printer, but it
it easy to avoid it.
julia
> diff -u -p a/block/blk-throttle.c b/block/blk-throttle.c
> --- a/block/blk-throttle.c
> +++ b/block/blk-throttle.c
> @@ -734,9 +734,7 @@ static inline void throtl_extend_slice(s
> static bool throtl_slice_used(struct throtl_grp *tg, bool rw)
> {
> if (time_in_range(jiffies, tg->slice_start[rw], tg->slice_end[rw]))
> - return 0;
> -
> - return 1;
> + return false;return true;
> }
>
> Is there a way to prevent this, or is this the kind of thing which
> must be handled in post-processing?
>
> Signed-off-by: Rasmus Villemoes <linux@rasmusvillemoes.dk>
> ---
> scripts/coccinelle/misc/boolreturn.cocci | 51 ++++++++++++++++++++++++++++++
> 1 file changed, 51 insertions(+)
> create mode 100644 scripts/coccinelle/misc/boolreturn.cocci
>
> diff --git a/scripts/coccinelle/misc/boolreturn.cocci b/scripts/coccinelle/misc/boolreturn.cocci
> new file mode 100644
> index 0000000..e6ece0d
> --- /dev/null
> +++ b/scripts/coccinelle/misc/boolreturn.cocci
> @@ -0,0 +1,51 @@
> +/// Return statements in functions returning bool should use
> +/// true/false instead of 1/0.
> +//
> +
> +virtual patch
> +virtual report
> +
> +
> + at r1 depends on patch@
> +identifier fn;
> +typedef bool;
> +symbol false;
> +symbol true;
> +@@
> +
> +bool fn ( ... )
> +{
> +...
> +(
> +- return 0;
> ++ return false;
> +|
> +- return 1;
> ++ return true;
> +)
> +...
> +}
> +
> + at r2 depends on !patch@
> +identifier fn;
> +position p;
> +@@
> +
> +bool fn ( ... )
> +{
> + ...
> +(
> +* return 0 at p ;
> +|
> +* return 1 at p ;
> +)
> + ...
> +}
> +
> +
> + at script:python depends on report@
> +p << r2.p;
> +fn << r2.fn;
> +@@
> +
> +coccilib.report.print_report(p[0], "WARNING: return of 0/1 in function '%s' with return type bool" % fn)
> --
> 1.7.9.5
>
>
^ permalink raw reply [flat|nested] 12+ messages in thread
* [PATCH v2] coccinelle: replace 0/1 with false/true in functions returning bool
2013-08-09 16:15 ` [Cocci] " Rasmus Villemoes
@ 2013-08-09 17:59 ` Rasmus Villemoes
-1 siblings, 0 replies; 12+ messages in thread
From: Rasmus Villemoes @ 2013-08-09 17:59 UTC (permalink / raw)
To: Julia Lawall, Gilles Muller, Nicolas Palix, Michal Marek
Cc: linux-kernel, cocci, Rasmus Villemoes
This semantic patch replaces "return {0,1};" with "return
{false,true};" in functions returning bool.
Signed-off-by: Rasmus Villemoes <linux@rasmusvillemoes.dk>
---
v2: Simplified script, and eliminate whitespace mangling at the same
time. Thanks to Julia Lawall.
scripts/coccinelle/misc/boolreturn.cocci | 56 ++++++++++++++++++++++++++++++
1 file changed, 56 insertions(+)
create mode 100644 scripts/coccinelle/misc/boolreturn.cocci
diff --git a/scripts/coccinelle/misc/boolreturn.cocci b/scripts/coccinelle/misc/boolreturn.cocci
new file mode 100644
index 0000000..c8d494c
--- /dev/null
+++ b/scripts/coccinelle/misc/boolreturn.cocci
@@ -0,0 +1,56 @@
+/// Return statements in functions returning bool should use
+/// true/false instead of 1/0.
+//
+// Confidence: High
+
+virtual patch
+virtual report
+
+
+@r1 depends on patch@
+identifier fn;
+typedef bool;
+symbol false;
+symbol true;
+@@
+
+bool fn ( ... )
+{
+...
+return
+(
+- 0
++ false
+|
+- 1
++ true
+)
+ ;
+...
+}
+
+@r2 depends on !patch@
+identifier fn;
+position p;
+@@
+
+bool fn ( ... )
+{
+ ...
+return
+(
+* 0@p
+|
+* 1@p
+)
+ ;
+ ...
+}
+
+
+@script:python depends on report@
+p << r2.p;
+fn << r2.fn;
+@@
+
+coccilib.report.print_report(p[0], "WARNING: return of 0/1 in function '%s' with return type bool" % fn)
--
1.7.9.5
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [Cocci] [PATCH v2] coccinelle: replace 0/1 with false/true in functions returning bool
@ 2013-08-09 17:59 ` Rasmus Villemoes
0 siblings, 0 replies; 12+ messages in thread
From: Rasmus Villemoes @ 2013-08-09 17:59 UTC (permalink / raw)
To: cocci
This semantic patch replaces "return {0,1};" with "return
{false,true};" in functions returning bool.
Signed-off-by: Rasmus Villemoes <linux@rasmusvillemoes.dk>
---
v2: Simplified script, and eliminate whitespace mangling at the same
time. Thanks to Julia Lawall.
scripts/coccinelle/misc/boolreturn.cocci | 56 ++++++++++++++++++++++++++++++
1 file changed, 56 insertions(+)
create mode 100644 scripts/coccinelle/misc/boolreturn.cocci
diff --git a/scripts/coccinelle/misc/boolreturn.cocci b/scripts/coccinelle/misc/boolreturn.cocci
new file mode 100644
index 0000000..c8d494c
--- /dev/null
+++ b/scripts/coccinelle/misc/boolreturn.cocci
@@ -0,0 +1,56 @@
+/// Return statements in functions returning bool should use
+/// true/false instead of 1/0.
+//
+// Confidence: High
+
+virtual patch
+virtual report
+
+
+ at r1 depends on patch@
+identifier fn;
+typedef bool;
+symbol false;
+symbol true;
+@@
+
+bool fn ( ... )
+{
+...
+return
+(
+- 0
++ false
+|
+- 1
++ true
+)
+ ;
+...
+}
+
+ at r2 depends on !patch@
+identifier fn;
+position p;
+@@
+
+bool fn ( ... )
+{
+ ...
+return
+(
+* 0 at p
+|
+* 1 at p
+)
+ ;
+ ...
+}
+
+
+ at script:python depends on report@
+p << r2.p;
+fn << r2.fn;
+@@
+
+coccilib.report.print_report(p[0], "WARNING: return of 0/1 in function '%s' with return type bool" % fn)
--
1.7.9.5
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH v3] coccinelle: replace 0/1 with false/true in functions returning bool
2013-08-09 17:59 ` [Cocci] " Rasmus Villemoes
@ 2013-08-11 21:05 ` Rasmus Villemoes
-1 siblings, 0 replies; 12+ messages in thread
From: Rasmus Villemoes @ 2013-08-11 21:05 UTC (permalink / raw)
To: Julia Lawall; +Cc: linux-kernel, cocci, Rasmus Villemoes
This semantic patch replaces "return {0,1};" with "return
{false,true};" in functions returning bool.
Signed-off-by: Rasmus Villemoes <linux@rasmusvillemoes.dk>
---
v2: Simplified script, and eliminate whitespace mangling at the same
time. Thanks to Julia Lawall.
v3: Further improvements from Julia. In particular, it now also does
header files.
scripts/coccinelle/misc/boolreturn.cocci | 58 ++++++++++++++++++++++++++++++
1 file changed, 58 insertions(+)
create mode 100644 scripts/coccinelle/misc/boolreturn.cocci
diff --git a/scripts/coccinelle/misc/boolreturn.cocci b/scripts/coccinelle/misc/boolreturn.cocci
new file mode 100644
index 0000000..a43c7b0
--- /dev/null
+++ b/scripts/coccinelle/misc/boolreturn.cocci
@@ -0,0 +1,58 @@
+/// Return statements in functions returning bool should use
+/// true/false instead of 1/0.
+//
+// Confidence: High
+// Options: --no-includes --include-headers
+
+virtual patch
+virtual report
+virtual context
+
+@r1 depends on patch@
+identifier fn;
+typedef bool;
+symbol false;
+symbol true;
+@@
+
+bool fn ( ... )
+{
+<...
+return
+(
+- 0
++ false
+|
+- 1
++ true
+)
+ ;
+...>
+}
+
+@r2 depends on report || context@
+identifier fn;
+position p;
+@@
+
+bool fn ( ... )
+{
+<...
+return
+(
+* 0@p
+|
+* 1@p
+)
+ ;
+...>
+}
+
+
+@script:python depends on report@
+p << r2.p;
+fn << r2.fn;
+@@
+
+msg = "WARNING: return of 0/1 in function '%s' with return type bool" % fn
+coccilib.report.print_report(p[0], msg)
--
1.7.9.5
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [Cocci] [PATCH v3] coccinelle: replace 0/1 with false/true in functions returning bool
@ 2013-08-11 21:05 ` Rasmus Villemoes
0 siblings, 0 replies; 12+ messages in thread
From: Rasmus Villemoes @ 2013-08-11 21:05 UTC (permalink / raw)
To: cocci
This semantic patch replaces "return {0,1};" with "return
{false,true};" in functions returning bool.
Signed-off-by: Rasmus Villemoes <linux@rasmusvillemoes.dk>
---
v2: Simplified script, and eliminate whitespace mangling at the same
time. Thanks to Julia Lawall.
v3: Further improvements from Julia. In particular, it now also does
header files.
scripts/coccinelle/misc/boolreturn.cocci | 58 ++++++++++++++++++++++++++++++
1 file changed, 58 insertions(+)
create mode 100644 scripts/coccinelle/misc/boolreturn.cocci
diff --git a/scripts/coccinelle/misc/boolreturn.cocci b/scripts/coccinelle/misc/boolreturn.cocci
new file mode 100644
index 0000000..a43c7b0
--- /dev/null
+++ b/scripts/coccinelle/misc/boolreturn.cocci
@@ -0,0 +1,58 @@
+/// Return statements in functions returning bool should use
+/// true/false instead of 1/0.
+//
+// Confidence: High
+// Options: --no-includes --include-headers
+
+virtual patch
+virtual report
+virtual context
+
+ at r1 depends on patch@
+identifier fn;
+typedef bool;
+symbol false;
+symbol true;
+@@
+
+bool fn ( ... )
+{
+<...
+return
+(
+- 0
++ false
+|
+- 1
++ true
+)
+ ;
+...>
+}
+
+ at r2 depends on report || context@
+identifier fn;
+position p;
+@@
+
+bool fn ( ... )
+{
+<...
+return
+(
+* 0 at p
+|
+* 1@p
+)
+ ;
+...>
+}
+
+
+ at script:python depends on report@
+p << r2.p;
+fn << r2.fn;
+@@
+
+msg = "WARNING: return of 0/1 in function '%s' with return type bool" % fn
+coccilib.report.print_report(p[0], msg)
--
1.7.9.5
^ permalink raw reply related [flat|nested] 12+ messages in thread
* Re: [PATCH v3] coccinelle: replace 0/1 with false/true in functions returning bool
2013-08-11 21:05 ` [Cocci] " Rasmus Villemoes
@ 2013-08-11 21:16 ` Julia Lawall
-1 siblings, 0 replies; 12+ messages in thread
From: Julia Lawall @ 2013-08-11 21:16 UTC (permalink / raw)
To: Rasmus Villemoes; +Cc: linux-kernel, cocci, Michal Marek
Acked-by: Julia Lawall <Julia.Lawall@lip6.fr>
On Sun, 11 Aug 2013, Rasmus Villemoes wrote:
> This semantic patch replaces "return {0,1};" with "return
> {false,true};" in functions returning bool.
>
> Signed-off-by: Rasmus Villemoes <linux@rasmusvillemoes.dk>
> ---
> v2: Simplified script, and eliminate whitespace mangling at the same
> time. Thanks to Julia Lawall.
>
> v3: Further improvements from Julia. In particular, it now also does
> header files.
>
> scripts/coccinelle/misc/boolreturn.cocci | 58 ++++++++++++++++++++++++++++++
> 1 file changed, 58 insertions(+)
> create mode 100644 scripts/coccinelle/misc/boolreturn.cocci
>
> diff --git a/scripts/coccinelle/misc/boolreturn.cocci b/scripts/coccinelle/misc/boolreturn.cocci
> new file mode 100644
> index 0000000..a43c7b0
> --- /dev/null
> +++ b/scripts/coccinelle/misc/boolreturn.cocci
> @@ -0,0 +1,58 @@
> +/// Return statements in functions returning bool should use
> +/// true/false instead of 1/0.
> +//
> +// Confidence: High
> +// Options: --no-includes --include-headers
> +
> +virtual patch
> +virtual report
> +virtual context
> +
> +@r1 depends on patch@
> +identifier fn;
> +typedef bool;
> +symbol false;
> +symbol true;
> +@@
> +
> +bool fn ( ... )
> +{
> +<...
> +return
> +(
> +- 0
> ++ false
> +|
> +- 1
> ++ true
> +)
> + ;
> +...>
> +}
> +
> +@r2 depends on report || context@
> +identifier fn;
> +position p;
> +@@
> +
> +bool fn ( ... )
> +{
> +<...
> +return
> +(
> +* 0@p
> +|
> +* 1@p
> +)
> + ;
> +...>
> +}
> +
> +
> +@script:python depends on report@
> +p << r2.p;
> +fn << r2.fn;
> +@@
> +
> +msg = "WARNING: return of 0/1 in function '%s' with return type bool" % fn
> +coccilib.report.print_report(p[0], msg)
> --
> 1.7.9.5
>
>
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Cocci] [PATCH v3] coccinelle: replace 0/1 with false/true in functions returning bool
@ 2013-08-11 21:16 ` Julia Lawall
0 siblings, 0 replies; 12+ messages in thread
From: Julia Lawall @ 2013-08-11 21:16 UTC (permalink / raw)
To: cocci
Acked-by: Julia Lawall <Julia.Lawall@lip6.fr>
On Sun, 11 Aug 2013, Rasmus Villemoes wrote:
> This semantic patch replaces "return {0,1};" with "return
> {false,true};" in functions returning bool.
>
> Signed-off-by: Rasmus Villemoes <linux@rasmusvillemoes.dk>
> ---
> v2: Simplified script, and eliminate whitespace mangling at the same
> time. Thanks to Julia Lawall.
>
> v3: Further improvements from Julia. In particular, it now also does
> header files.
>
> scripts/coccinelle/misc/boolreturn.cocci | 58 ++++++++++++++++++++++++++++++
> 1 file changed, 58 insertions(+)
> create mode 100644 scripts/coccinelle/misc/boolreturn.cocci
>
> diff --git a/scripts/coccinelle/misc/boolreturn.cocci b/scripts/coccinelle/misc/boolreturn.cocci
> new file mode 100644
> index 0000000..a43c7b0
> --- /dev/null
> +++ b/scripts/coccinelle/misc/boolreturn.cocci
> @@ -0,0 +1,58 @@
> +/// Return statements in functions returning bool should use
> +/// true/false instead of 1/0.
> +//
> +// Confidence: High
> +// Options: --no-includes --include-headers
> +
> +virtual patch
> +virtual report
> +virtual context
> +
> + at r1 depends on patch@
> +identifier fn;
> +typedef bool;
> +symbol false;
> +symbol true;
> +@@
> +
> +bool fn ( ... )
> +{
> +<...
> +return
> +(
> +- 0
> ++ false
> +|
> +- 1
> ++ true
> +)
> + ;
> +...>
> +}
> +
> + at r2 depends on report || context@
> +identifier fn;
> +position p;
> +@@
> +
> +bool fn ( ... )
> +{
> +<...
> +return
> +(
> +* 0 at p
> +|
> +* 1 at p
> +)
> + ;
> +...>
> +}
> +
> +
> + at script:python depends on report@
> +p << r2.p;
> +fn << r2.fn;
> +@@
> +
> +msg = "WARNING: return of 0/1 in function '%s' with return type bool" % fn
> +coccilib.report.print_report(p[0], msg)
> --
> 1.7.9.5
>
>
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH v3] coccinelle: replace 0/1 with false/true in functions returning bool
2013-08-11 21:05 ` [Cocci] " Rasmus Villemoes
@ 2013-08-13 20:45 ` Michal Marek
-1 siblings, 0 replies; 12+ messages in thread
From: Michal Marek @ 2013-08-13 20:45 UTC (permalink / raw)
To: Rasmus Villemoes; +Cc: Julia Lawall, linux-kernel, cocci
Dne 11.8.2013 23:05, Rasmus Villemoes napsal(a):
> This semantic patch replaces "return {0,1};" with "return
> {false,true};" in functions returning bool.
>
> Signed-off-by: Rasmus Villemoes <linux@rasmusvillemoes.dk>
> ---
> v2: Simplified script, and eliminate whitespace mangling at the same
> time. Thanks to Julia Lawall.
>
> v3: Further improvements from Julia. In particular, it now also does
> header files.
Applied to kbuild.git#misc.
Michal
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Cocci] [PATCH v3] coccinelle: replace 0/1 with false/true in functions returning bool
@ 2013-08-13 20:45 ` Michal Marek
0 siblings, 0 replies; 12+ messages in thread
From: Michal Marek @ 2013-08-13 20:45 UTC (permalink / raw)
To: cocci
Dne 11.8.2013 23:05, Rasmus Villemoes napsal(a):
> This semantic patch replaces "return {0,1};" with "return
> {false,true};" in functions returning bool.
>
> Signed-off-by: Rasmus Villemoes <linux@rasmusvillemoes.dk>
> ---
> v2: Simplified script, and eliminate whitespace mangling at the same
> time. Thanks to Julia Lawall.
>
> v3: Further improvements from Julia. In particular, it now also does
> header files.
Applied to kbuild.git#misc.
Michal
^ permalink raw reply [flat|nested] 12+ messages in thread
end of thread, other threads:[~2013-08-13 20:45 UTC | newest]
Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-08-09 16:15 [PATCH/RFC] coccinelle: replace 0/1 with false/true in functions returning bool Rasmus Villemoes
2013-08-09 16:15 ` [Cocci] " Rasmus Villemoes
2013-08-09 16:18 ` Julia Lawall
2013-08-09 16:18 ` [Cocci] " Julia Lawall
2013-08-09 17:59 ` [PATCH v2] " Rasmus Villemoes
2013-08-09 17:59 ` [Cocci] " Rasmus Villemoes
2013-08-11 21:05 ` [PATCH v3] " Rasmus Villemoes
2013-08-11 21:05 ` [Cocci] " Rasmus Villemoes
2013-08-11 21:16 ` Julia Lawall
2013-08-11 21:16 ` [Cocci] " Julia Lawall
2013-08-13 20:45 ` Michal Marek
2013-08-13 20:45 ` [Cocci] " Michal Marek
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.