Skip to content

Commit

Permalink
9p: use an IS_ERR test rather than a NULL test
Browse files Browse the repository at this point in the history
In case of error, the function p9_client_walk returns an ERR pointer, but
never returns a NULL pointer.  So a NULL test that comes after 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 = p9_client_walk(...)
... when != x = E
*  if (x != NULL)
S1 else S2
// </smpl>

Signed-off-by: Julien Brunel <[email protected]>
Signed-off-by: Julia Lawall <[email protected]>
Signed-off-by: Eric Van Hensbergen <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
  • Loading branch information
Julien Brunel authored and Eric Van Hensbergen committed Sep 24, 2008
1 parent 6206782 commit 62aa528
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions fs/9p/vfs_inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -626,8 +626,7 @@ static struct dentry *v9fs_vfs_lookup(struct inode *dir, struct dentry *dentry,
return NULL;

error:
if (fid)
p9_client_clunk(fid);
p9_client_clunk(fid);

return ERR_PTR(result);
}
Expand Down

0 comments on commit 62aa528

Please sign in to comment.