UBI: fix IS_ERR test
authorJulien Brunel <brunel@diku.dk>
Fri, 26 Sep 2008 13:27:25 +0000 (15:27 +0200)
committerGrazvydas Ignotas <notasas@gmail.com>
Fri, 17 Jul 2009 13:04:07 +0000 (16:04 +0300)
commitc806adb33d2d69b2ca3e8e251084861cf346e196
treec139b7b53723c71f2eb713bc2d74e1ef93331823
parentaa4452aed9cae1522ff69af2f78d22f297a4b3e9
UBI: fix IS_ERR test

In case of error, the function add_volume returns an ERR pointer. The
result of IS_ERR, which is supposed to be used in a test as it is, is
here checked to be less than zero, which seems odd. We suggest to
replace this test by a simple IS_ERR test.

A simplified version of the semantic match that finds this problem is
as follows:
(http://www.emn.fr/x-info/coccinelle/)

// <smpl>
@def0@
expression x;
position p0;
@@
x@p0 = add_volume(...)

@protected@
expression def0.x,E;
position def0.p0;
position p;
statement S;
@@
x@p0
... when != x = E
if (!IS_ERR(x) && ...) {<... x@p ...>} else S

@unprotected@
expression def0.x,E;
identifier fld;
position def0.p0;
position p != protected.p;
@@
x@p0
... when != x = E
* x@p->fld
// </smpl>

Signed-off-by: Julien Brunel <brunel@diku.dk>
Signed-off-by: Julia Lawall <julia@diku.dk>
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
drivers/mtd/ubi/scan.c