[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <8f454c56-735c-0620-ead4-b59e328b0283@web.de>
Date: Thu, 5 Sep 2019 14:32:54 +0200
From: Markus Elfring <Markus.Elfring@....de>
To: Denis Efremov <efremov@...ux.com>, cocci@...teme.lip6.fr,
kernel-janitors@...r.kernel.org
Cc: linux-kernel@...r.kernel.org,
Gilles Muller <Gilles.Muller@...6.fr>,
Julia Lawall <julia.lawall@...6.fr>,
Masahiro Yamada <yamada.masahiro@...ionext.com>,
Michal Marek <michal.lkml@...kovi.net>,
Nicolas Palix <nicolas.palix@...g.fr>
Subject: Re: [RFC PATCH] coccinelle: check for integer overflow in binary
search
> +identifier l, h, m;
Can expressions make sense for these metavariables?
> +@@
> +(
> + while (\(l < h\|l <= h\|(h - l) > 1\|(l + 1) < h\|l < (h - 1)\)) {
> + ...
> +(
> + ((l + h)@p / c)
> +|
> + ((l + h)@p >> c)
> +)
> + ...
> + }
* I suggest again to look at further possibilities to reduce undesirable
code duplication also together with the usage of SmPL disjunctions.
* The condition specification might be easier to read with a few
additional spaces (or the following variant).
* The SmPL ellipses will probably need further considerations.
+@@
+(
+ while (
+( l \( < \| <= \) h
+| (h - l) > 1
+| (h - 1) > l
+| (l + 1) < h
+) )
+ {
+ <+...
+ ((l + h)@p \( / \| >> \) c)
+ ...+>
+ }
> +@...ipt:python depends on report@
> +p << r.p;
> +@@
> +
> +msg="WARNING: custom implementation of bsearch is error-prone. "
> +msg+="Consider using lib/bsearch.c or fix the midpoint calculation "
> +msg+="as 'm = l + (h - l) / 2;' to prevent the arithmetic overflow."
> +coccilib.report.print_report(p[0], msg)
The Linux coding style supports to put a long string literal also into a single line.
Thus I find such a message construction nicer without the extra variable “msg”.
Regards,
Markus
Powered by blists - more mailing lists