lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Sun, 11 Aug 2013 23:16:37 +0200 (CEST)
From:	Julia Lawall <julia.lawall@...6.fr>
To:	Rasmus Villemoes <linux@...musvillemoes.dk>
cc:	linux-kernel@...r.kernel.org, cocci@...teme.lip6.fr,
	Michal Marek <mmarek@...e.cz>
Subject: Re: [PATCH v3] coccinelle: replace 0/1 with false/true in functions
 returning bool

Acked-by: Julia Lawall <Julia.Lawall@...6.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@...musvillemoes.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
> +)
> +  ;
> +...>
> +}
> +
> +
> +@...ipt: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
> 
> 
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ