Re: [PATCH] staging: rtl8188eu: core: switch with redundant cases

From: Nicholas Mc Guire
Date: Wed Feb 04 2015 - 08:16:41 EST


On Wed, 04 Feb 2015, Dan Carpenter wrote:

> Btw, what tool are you using to find these?
>
working on a set of coccinell scripts - they are not yet
really clean - but this one is simply:


virtual context
virtual patch
virtual org
virtual report

@assign@
position p;
statement S1;
@@

<+...
* if@p (...) S1 else S1
...+>

@script:python@
p << assign.p;
@@

print "%s:%s WARNING: condition with no effect" % (p[0].file,p[0].line)



I guess this is not wildly impressive - but it seems to be effective
in finding a lot of broken code. The rate of false postivs has been
supprisingly low (very few case of intentional if==else like in
./fs/kernfs/file.c:661 - which is nicely documented)

thx!
hofrat

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/