Skip to content

Commit

Permalink
NFS: Deletion of unnecessary checks before the function call "nfs_put…
Browse files Browse the repository at this point in the history
…_client"

The nfs_put_client() function tests whether its argument is NULL and then
returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
Signed-off-by: Trond Myklebust <trond.myklebust@primarydata.com>
  • Loading branch information
Markus Elfring authored and Trond Myklebust committed Nov 25, 2014
1 parent 1306729 commit fe0bf11
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 12 deletions.
3 changes: 1 addition & 2 deletions fs/nfs/filelayout/filelayoutdev.c
Original file line number Diff line number Diff line change
Expand Up @@ -204,8 +204,7 @@ destroy_ds(struct nfs4_pnfs_ds *ds)
ifdebug(FACILITY)
print_ds(ds);

if (ds->ds_clp)
nfs_put_client(ds->ds_clp);
nfs_put_client(ds->ds_clp);

while (!list_empty(&ds->ds_addrs)) {
da = list_first_entry(&ds->ds_addrs,
Expand Down
15 changes: 5 additions & 10 deletions fs/nfs/nfs4client.c
Original file line number Diff line number Diff line change
Expand Up @@ -498,8 +498,7 @@ int nfs40_walk_client_list(struct nfs_client *new,
atomic_inc(&pos->cl_count);
spin_unlock(&nn->nfs_client_lock);

if (prev)
nfs_put_client(prev);
nfs_put_client(prev);
prev = pos;

status = nfs_wait_client_init_complete(pos);
Expand All @@ -517,8 +516,7 @@ int nfs40_walk_client_list(struct nfs_client *new,
atomic_inc(&pos->cl_count);
spin_unlock(&nn->nfs_client_lock);

if (prev)
nfs_put_client(prev);
nfs_put_client(prev);
prev = pos;

status = nfs4_proc_setclientid_confirm(pos, &clid, cred);
Expand Down Expand Up @@ -549,8 +547,7 @@ int nfs40_walk_client_list(struct nfs_client *new,

/* No match found. The server lost our clientid */
out:
if (prev)
nfs_put_client(prev);
nfs_put_client(prev);
dprintk("NFS: <-- %s status = %d\n", __func__, status);
return status;
}
Expand Down Expand Up @@ -641,8 +638,7 @@ int nfs41_walk_client_list(struct nfs_client *new,
atomic_inc(&pos->cl_count);
spin_unlock(&nn->nfs_client_lock);

if (prev)
nfs_put_client(prev);
nfs_put_client(prev);
prev = pos;

status = nfs_wait_client_init_complete(pos);
Expand Down Expand Up @@ -675,8 +671,7 @@ int nfs41_walk_client_list(struct nfs_client *new,
/* No matching nfs_client found. */
spin_unlock(&nn->nfs_client_lock);
dprintk("NFS: <-- %s status = %d\n", __func__, status);
if (prev)
nfs_put_client(prev);
nfs_put_client(prev);
return status;
}
#endif /* CONFIG_NFS_V4_1 */
Expand Down

0 comments on commit fe0bf11

Please sign in to comment.