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]
Message-ID: <alpine.DEB.2.02.1112202317450.1933@hadrien>
Date:	Tue, 20 Dec 2011 23:19:12 +0100 (CET)
From:	Julia Lawall <julia.lawall@...6.fr>
To:	Lars-Peter Clausen <lars@...afoo.de>
cc:	Gilles Muller <Gilles.Muller@...6.fr>,
	Nicolas Palix <npalix.work@...il.com>,
	linux-kernel@...r.kernel.org, cocci@...u.dk,
	Michal Marek <mmarek@...e.cz>
Subject: Re: [Cocci] [PATCH 1/2] coccinelle: Add patch for replacing open-coded
 PTR_RET

On Mon, 19 Dec 2011, Lars-Peter Clausen wrote:

> The PTR_RET function returns the error value of its parameter if it is an
> ERR_PTR, otherwise it returns 0. This patch adds a semantic patch which finds
> open-coded instances of this check and replaces them.
>
> Signed-off-by: Lars-Peter Clausen <lars@...afoo.de>

Acked-by: Julia Lawall <julia.lawall@...6.fr>

> ---
> scripts/coccinelle/api/ptr_ret.cocci |   55 ++++++++++++++++++++++++++++++++++
> 1 files changed, 55 insertions(+), 0 deletions(-)
> create mode 100644 scripts/coccinelle/api/ptr_ret.cocci
>
> diff --git a/scripts/coccinelle/api/ptr_ret.cocci b/scripts/coccinelle/api/ptr_ret.cocci
> new file mode 100644
> index 0000000..dfd9b1f
> --- /dev/null
> +++ b/scripts/coccinelle/api/ptr_ret.cocci
> @@ -0,0 +1,55 @@
> +///
> +/// Use PTR_RET function instead of open coding it
> +///
> +// Confidence: High
> +// Options:
> +//
> +// Keywords: IS_ERR, PTR_ERR, PTR_RET
> +// Version min: 2.6.39
> +//
> +
> +virtual context
> +virtual patch
> +virtual org
> +virtual report
> +
> +@...ends on context@
> +expression x;
> +@@
> +*if (IS_ERR(x))
> +*	return PTR_ERR(x);
> +*return 0;
> +
> +@...ends on patch@
> +expression x;
> +@@
> +-if (IS_ERR(x))
> +-	return PTR_ERR(x);
> +-return 0;
> ++return PTR_RET(x);
> +
> +@r depends on org || report@
> +expression x;
> +position p;
> +@@
> +
> + if (IS_ERR@p(x))
> +	return PTR_ERR(x);
> + return 0;
> +
> +@...ipt:python depends on org@
> +p << r.p;
> +x << r.x;
> +@@
> +
> +msg="WARNING PTR_RET can be used with %s" % (x)
> +msg_safe=msg.replace("[","@(").replace("]",")")
> +coccilib.org.print_todo(p[0], msg_safe)
> +
> +@...ipt:python depends on report@
> +p << r.p;
> +x << r.x;
> +@@
> +
> +msg="WARNING: PTR_RET can be used with %s" % (x)
> +coccilib.report.print_report(p[0], msg)
> -- 
> 1.7.7.3
>
>
> _______________________________________________
> Cocci mailing list
> Cocci@...u.dk
> http://lists.diku.dk/mailman/listinfo/cocci
> (Web access from inside DIKUs LAN only)
>
--
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