Skip to content

Commit

Permalink
NFSv4.1: work around -Wmaybe-uninitialized warning
Browse files Browse the repository at this point in the history
A bugfix introduced a harmless gcc warning in nfs4_slot_seqid_in_use
if we enable -Wmaybe-uninitialized again:

fs/nfs/nfs4session.c:203:54: error: 'cur_seq' may be used uninitialized in this function [-Werror=maybe-uninitialized]

gcc is not smart enough to conclude that the IS_ERR/PTR_ERR pair
results in a nonzero return value here. Using PTR_ERR_OR_ZERO()
instead makes this clear to the compiler.

The warning originally did not appear in v4.8 as it was globally
disabled, but the bugfix that introduced the warning got backported
to stable kernels which again enable it, and this is now the only
warning in the v4.7 builds.

Fixes: e09c978 ("NFSv4.1: Fix Oopsable condition in server callback races")
Signed-off-by: Arnd Bergmann <[email protected]>
Cc: Trond Myklebust <[email protected]>
Signed-off-by: Anna Schumaker <[email protected]>
  • Loading branch information
arndb authored and amschuma-ntap committed Oct 24, 2016
1 parent 86a6c21 commit 68a5640
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions fs/nfs/nfs4session.c
Original file line number Diff line number Diff line change
Expand Up @@ -178,12 +178,14 @@ static int nfs4_slot_get_seqid(struct nfs4_slot_table *tbl, u32 slotid,
__must_hold(&tbl->slot_tbl_lock)
{
struct nfs4_slot *slot;
int ret;

slot = nfs4_lookup_slot(tbl, slotid);
if (IS_ERR(slot))
return PTR_ERR(slot);
*seq_nr = slot->seq_nr;
return 0;
ret = PTR_ERR_OR_ZERO(slot);
if (!ret)
*seq_nr = slot->seq_nr;

return ret;
}

/*
Expand Down

0 comments on commit 68a5640

Please sign in to comment.