[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <1472927739.5018.13.camel@perches.com>
Date: Sat, 03 Sep 2016 11:35:39 -0700
From: Joe Perches <joe@...ches.com>
To: Julia Lawall <julia.lawall@...6.fr>,
Dan Carpenter <error27@...il.com>
Cc: LKML <linux-kernel@...r.kernel.org>
Subject: Possible code defects: macros and precedence
There are many nominally incorrect macro definitions
in linux-kernel source where parentheses are not used
for various macros arguments with calculations.
Does coccinelle or smatch have the ability to detect
potential macro misuse where arguments passed to the
macro are not correctly parenthesized by the macro?
Something like:
#define A 1
#define B 2
#define shift(val) (val << 1)
where a use is:
int c = shift(A | B)
where the actual result is 5 but the expected result is 6?
Can either tool suggest changing the macro to
#define shift(val) ((val) << 1)
?
Powered by blists - more mailing lists