UBI: fix IS_ERR test
Linux-MTD Mailing List
linux-mtd at lists.infradead.org
Sat Oct 18 07:59:02 EDT 2008
Gitweb: http://git.infradead.org/?p=mtd-2.6.git;a=commit;h=0e4a008a4f389b468cfe8b58c7d77882a6e25695
Commit: 0e4a008a4f389b468cfe8b58c7d77882a6e25695
Parent: 7d200e88cbdff5334d23d3af8d444eb9cc041962
Author: Julien Brunel <brunel at diku.dk>
AuthorDate: Fri Sep 26 15:27:25 2008 +0200
Committer: Artem Bityutskiy <Artem.Bityutskiy at nokia.com>
CommitDate: Fri Sep 26 19:24:37 2008 +0300
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 at p0 = add_volume(...)
@protected@
expression def0.x,E;
position def0.p0;
position p;
statement S;
@@
x at p0
... when != x = E
if (!IS_ERR(x) && ...) {<... x at p ...>} else S
@unprotected@
expression def0.x,E;
identifier fld;
position def0.p0;
position p != protected.p;
@@
x at p0
... when != x = E
* x at p->fld
// </smpl>
Signed-off-by: Julien Brunel <brunel at diku.dk>
Signed-off-by: Julia Lawall <julia at diku.dk>
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy at nokia.com>
---
drivers/mtd/ubi/scan.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/drivers/mtd/ubi/scan.c b/drivers/mtd/ubi/scan.c
index 967bb44..4f2daa5 100644
--- a/drivers/mtd/ubi/scan.c
+++ b/drivers/mtd/ubi/scan.c
@@ -387,7 +387,7 @@ int ubi_scan_add_used(struct ubi_device *ubi, struct ubi_scan_info *si,
pnum, vol_id, lnum, ec, sqnum, bitflips);
sv = add_volume(si, vol_id, pnum, vid_hdr);
- if (IS_ERR(sv) < 0)
+ if (IS_ERR(sv))
return PTR_ERR(sv);
if (si->max_sqnum < sqnum)
More information about the linux-mtd-cvs
mailing list