* [PATCH] fs/ubifs: Use an IS_ERR test rather than a NULL test
@ 2008-08-29 9:08 Julien Brunel
2008-08-29 10:35 ` Artem Bityutskiy
0 siblings, 1 reply; 2+ messages in thread
From: Julien Brunel @ 2008-08-29 9:08 UTC (permalink / raw)
To: dedekind, linux-mips, linux-kernel, kernel-janitors
From: Julien Brunel <brunel@diku.dk>
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>
Signed-off-by: Julien Brunel <brunel@diku.dk>
Signed-off-by: Julia Lawall <julia@diku.dk>
---
fs/ubifs/super.c | 4 ----
1 file changed, 4 deletions(-)
diff -u -p a/fs/ubifs/super.c b/fs/ubifs/super.c
--- a/fs/ubifs/super.c
+++ b/fs/ubifs/super.c
@@ -1027,8 +1027,6 @@ static int mount_ubifs(struct ubifs_info
sprintf(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;
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] fs/ubifs: Use an IS_ERR test rather than a NULL test
2008-08-29 9:08 [PATCH] fs/ubifs: Use an IS_ERR test rather than a NULL test Julien Brunel
@ 2008-08-29 10:35 ` Artem Bityutskiy
0 siblings, 0 replies; 2+ messages in thread
From: Artem Bityutskiy @ 2008-08-29 10:35 UTC (permalink / raw)
To: Julien Brunel; +Cc: linux-mips, linux-kernel, kernel-janitors
On Fri, 2008-08-29 at 11:08 +0200, Julien Brunel wrote:
> 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/)
Pushed to ubifs-2.6.git, thanks.
--
Best regards,
Artem Bityutskiy (Битюцкий Артём)
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2008-08-29 10:35 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-08-29 9:08 [PATCH] fs/ubifs: Use an IS_ERR test rather than a NULL test Julien Brunel
2008-08-29 10:35 ` Artem Bityutskiy
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).