Commit ba5a6a19d83babe00be3711db3deee5c57587b8f
Committed by
Linus Torvalds
1 parent
1df0cada03
Exists in
master
and in
4 other branches
[PATCH] knfsd: nfsd4: fix some open argument tests
These tests always returned true; clearly that wasn't what was intended. In keeping with kernel style, make them functions instead of macros while we're at it. Signed-off-by: J. Bruce Fields <bfields@citi.umich.edu> Signed-off-by: Neil Brown <neilb@suse.de> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Showing 1 changed file with 13 additions and 4 deletions Side-by-side Diff
fs/nfsd/nfs4state.c
| ... | ... | @@ -1237,9 +1237,16 @@ |
| 1237 | 1237 | return NULL; |
| 1238 | 1238 | } |
| 1239 | 1239 | |
| 1240 | -#define TEST_ACCESS(x) ((x > 0 || x < 4)?1:0) | |
| 1241 | -#define TEST_DENY(x) ((x >= 0 || x < 5)?1:0) | |
| 1240 | +static int access_valid(u32 x) | |
| 1241 | +{ | |
| 1242 | + return (x > 0 && x < 4); | |
| 1243 | +} | |
| 1242 | 1244 | |
| 1245 | +static int deny_valid(u32 x) | |
| 1246 | +{ | |
| 1247 | + return (x >= 0 && x < 5); | |
| 1248 | +} | |
| 1249 | + | |
| 1243 | 1250 | static void |
| 1244 | 1251 | set_access(unsigned int *access, unsigned long bmap) { |
| 1245 | 1252 | int i; |
| ... | ... | @@ -1745,7 +1752,8 @@ |
| 1745 | 1752 | int status; |
| 1746 | 1753 | |
| 1747 | 1754 | status = nfserr_inval; |
| 1748 | - if (!TEST_ACCESS(open->op_share_access) || !TEST_DENY(open->op_share_deny)) | |
| 1755 | + if (!access_valid(open->op_share_access) | |
| 1756 | + || !deny_valid(open->op_share_deny)) | |
| 1749 | 1757 | goto out; |
| 1750 | 1758 | /* |
| 1751 | 1759 | * Lookup file; if found, lookup stateid and check open request, |
| ... | ... | @@ -2317,7 +2325,8 @@ |
| 2317 | 2325 | (int)current_fh->fh_dentry->d_name.len, |
| 2318 | 2326 | current_fh->fh_dentry->d_name.name); |
| 2319 | 2327 | |
| 2320 | - if (!TEST_ACCESS(od->od_share_access) || !TEST_DENY(od->od_share_deny)) | |
| 2328 | + if (!access_valid(od->od_share_access) | |
| 2329 | + || !deny_valid(od->od_share_deny)) | |
| 2321 | 2330 | return nfserr_inval; |
| 2322 | 2331 | |
| 2323 | 2332 | nfs4_lock_state(); |