posix-acl: avoid -Wempty-body warning
PATCH 1/1 posix-acl: avoid -Wempty-body warning
From: Arnd Bergmann <[email protected]>
The fallthrough comment for an ignored cmpxchg() return value produces a harmless warning with 'make W=1':
fs/posix_acl.c: In function 'get_acl':fs/posix_acl.c:127:36: error: suggest braces around empty body in an 'if' statement [-Werror=empty-body]
127 | /* fall through */ ;
| ^
Rewrite it as gcc suggests as a step towards a clean W=1 build. On most architectures, we could just drop the if() entirely, but in some cases this causes a different warning.
--- fs/posix_acl.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
fs/posix_acl.c +3 -2
@@ -123,8 +123,9 @@ struct posix_acl *get_acl(struct inode *inode, int type)* to just call ->get_acl to fetch the ACL ourself. (This is going to * be an unlikely race.) */ -if (cmpxchg (p,ACL_NOT_CACHED , sentinel) !=ACL_NOT_CACHED ) -/* fall through */ ; +if (cmpxchg (p,ACL_NOT_CACHED , sentinel) !=ACL_NOT_CACHED ) { +/* fall through */ + }/* * Normally, the ACL returned by ->get_acl will be cached.
Signature · 1 line
2.29.2
Quoted 5 lines · Arnd Bergmann
From: Arnd Bergmann <[email protected]>
The fallthrough comment for an ignored
cmpxchg()return value produces a harmless warning with 'make W=1':
Quoted 8 lines
fs/posix_acl.c: In function 'get_acl':fs/posix_acl.c:127:36: error: suggest braces around empty body in an 'if' statement [-Werror=empty-body]
127 | /* fall through */ ;
| ^Rewrite it as gcc suggests as a step towards a clean W=1 build. On most architectures, we could just drop the
if()entirely, but in some cases this causes a different warning.
And you don't see the warning for the second unconditional cmpxchg(p, sentinel, ACL_NOT_CACHED);
below?
Quoted 3 lines
Signed-off-by Arnd Bergmann <[email protected]>---
In any case that should be fine,
Quoted 11 lines · Christian Brauner
Quoted 10 lines · Arnd Bergmann
From: Arnd Bergmann <[email protected]>
The fallthrough comment for an ignored
cmpxchg()return value produces a harmless warning with 'make W=1':
fs/posix_acl.c: In function 'get_acl':fs/posix_acl.c:127:36: error: suggest braces around empty body in an 'if' statement [-Werror=empty-body]
127 | /* fall through */ ;
| ^
Quoted 7 lines
Quoted 3 lines
Rewrite it as gcc suggests as a step towards a clean W=1 build. On most architectures, we could just drop the
if()entirely, but in some cases this causes a different warning.And you don't see the warning for the second unconditional
cmpxchg(p, sentinel, ACL_NOT_CACHED);
below?
I would have expected both to show that warning, didn't notice the other one. I now see that all architectures use statement expressions for cmpxchg() and xchg() these days, after we fixed m68k, alpha and ia64, so the changelog text here no longer makes sense.
Should I just remove the if() then?
Arnd
Quoted 21 lines · Arnd Bergmann
Quoted 11 lines · Christian Brauner
Quoted 10 lines · Arnd Bergmann
From: Arnd Bergmann <[email protected]>
The fallthrough comment for an ignored
cmpxchg()return value produces a harmless warning with 'make W=1':
fs/posix_acl.c: In function 'get_acl':fs/posix_acl.c:127:36: error: suggest braces around empty body in an 'if' statement [-Werror=empty-body]
127 | /* fall through */ ;
| ^Quoted 7 lines
Quoted 3 lines
Rewrite it as gcc suggests as a step towards a clean W=1 build. On most architectures, we could just drop the
if()entirely, but in some cases this causes a different warning.And you don't see the warning for the second unconditional
cmpxchg(p, sentinel, ACL_NOT_CACHED);
below?
Quoted 6 lines
I would have expected both to show that warning, didn't notice the other one. I now see that all architectures use statement expressions for
cmpxchg()andxchg()these days, after we fixed m68k, alpha and ia64, so the changelog text here no longer makes sense.Should I just remove the
if()then?
I think so. It seems like the straightforward thing to do. The comment above this cmpxchg() also explains clearly what the expectations are. At least to me the visual hint due to the "!= ACL_NOT_CACHED" check in the if condition doesn't provide any additional clarity.
Christian