Skip to content

Commit

Permalink
nfsd4: clean up access_valid, deny_valid checks.
Browse files Browse the repository at this point in the history
Document these checks a little better and inline, as suggested by Neil
Brown (note both functions have two callers).  Remove an obviously bogus
check while we're there (checking whether unsigned value is negative).

Signed-off-by: J. Bruce Fields <bfields@citi.umich.edu>
Cc: Neil Brown <neilb@suse.de>
  • Loading branch information
J. Bruce Fields committed Feb 1, 2008
1 parent b39c18f commit 8838dc4
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions fs/nfsd/nfs4state.c
Original file line number Diff line number Diff line change
Expand Up @@ -1157,14 +1157,19 @@ find_file(struct inode *ino)
return NULL;
}

static int access_valid(u32 x)
static inline int access_valid(u32 x)
{
return (x > 0 && x < 4);
if (x < NFS4_SHARE_ACCESS_READ)
return 0;
if (x > NFS4_SHARE_ACCESS_BOTH)
return 0;
return 1;
}

static int deny_valid(u32 x)
static inline int deny_valid(u32 x)
{
return (x >= 0 && x < 5);
/* Note: unlike access bits, deny bits may be zero. */
return x <= NFS4_SHARE_DENY_BOTH;
}

static void
Expand Down

0 comments on commit 8838dc4

Please sign in to comment.