fs/ubifs: Use an IS_ERR test rather than a NULL test
Subsystems (3)
PATCH 1/1 fs/ubifs: Use an IS_ERR test rather than a NULL test
From: Julien Brunel <[email protected]>
In case of error, the function kthread_create returns an ERR pointer, but never returns a NULL pointer. So a NULL test that comes before an IS_ERR test should be deleted.
The semantic match that finds this problem is as follows:
(http://www.emn.fr/x-info/coccinelle/)
// <smpl>
@match_bad_null_test@
expression x, E;
statement S1,S2;
@@
x = kthread_create(...)
... when != x = E
* if (x = NULL)
S1 else S2
// </smpl>
--- fs/ubifs/super.c | 4 ---- 1 file changed, 4 deletions(-)
fs/ubifs/super.c +0 -4
@@ -1027,8 +1027,6 @@ static int mount_ubifs(struct ubifs_infosprintf (c->bgt_name,BGT_NAME_PATTERN , c->vi.ubi_num, c->vi.vol_id); c->bgt =kthread_create (ubifs_bg_thread, c, c->bgt_name); -if (!c->bgt) - c->bgt =ERR_PTR (-EINVAL );if (IS_ERR (c->bgt)) { err =PTR_ERR (c->bgt); c->bgt =NULL ;
@@ -1340,8 +1338,6 @@ static int ubifs_remount_rw(struct ubifs/* Create background thread */ c->bgt =kthread_create (ubifs_bg_thread, c, c->bgt_name); -if (!c->bgt) - c->bgt =ERR_PTR (-EINVAL );if (IS_ERR (c->bgt)) { err =PTR_ERR (c->bgt); c->bgt =NULL ;
Artem Bityutskiy
AppliedQuoted 6 lines · Julien Brunel
In case of error, the function
kthread_createreturns an ERR pointer, but never returns a NULL pointer. So a NULL test that comes before anIS_ERRtest should be deleted.The semantic match that finds this problem is as follows:
(http://www.emn.fr/x-info/coccinelle/)
Pushed to ubifs-2.6.git, thanks.
Signature · 2 lines
Best regards, Artem Bityutskiy (Битюцкий Артём)