linux-user: avoid -Werror=int-in-bool-context
PATCH 1/1 linux-user: avoid -Werror=int-in-bool-context
linux-user is failing to compile on Fedora 43:
../linux-user/strace.c:57:66: error: enum constant in boolean context [-Werror=int-in-bool-context]
57 | #define FLAG_BASIC(V, M, N) { V, M | QEMU_BUILD_BUG_ON_ZERO(!(M)), N }
The warning does not seem to useful and we could even disable it, but the workaround is simple in this case.
--- linux-user/strace.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
linux-user/strace.c +1 -1
@@ -54,7 +54,7 @@ struct flags { };/* No 'struct flags' element should have a zero mask. */ -#define FLAG_BASIC (V ,M ,N ) { V, M | QEMU_BUILD_BUG_ON_ZERO(!(M)), N } +#define FLAG_BASIC (V ,M ,N ) { V, M | QEMU_BUILD_BUG_ON_ZERO((M) == 0), N }/* common flags for all architectures */ #define FLAG_GENERIC_MASK (V ,M ) FLAG_BASIC(V, M, #V)
Signature · 1 line
2.51.0
Quoted 8 lines · Paolo Bonzini
linux-user is failing to compile on Fedora 43:
../linux-user/strace.c:57:66: error: enum constant in boolean context [-Werror=int-in-bool-context]
57 | #defineFLAG_BASIC(V, M, N){ V, M | QEMU_BUILD_BUG_ON_ZERO(!(M)), N }The warning does not seem to useful and we could even disable it, but the workaround is simple in this case.
Quoted 6 lines
Cc Richard Henderson <[email protected]>Signed-off-by Paolo Bonzini <[email protected]>--- linux-user/strace.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
With regards,
Daniel
Signature · 3 lines
|: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o- https://fstop138.berrange.com :| |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|
Quoted 8 lines · Paolo Bonzini
linux-user is failing to compile on Fedora 43:
../linux-user/strace.c:57:66: error: enum constant in boolean context [-Werror=int-in-bool-context]
57 | #defineFLAG_BASIC(V, M, N){ V, M | QEMU_BUILD_BUG_ON_ZERO(!(M)), N }The warning does not seem to useful and we could even disable it, but the workaround is simple in this case.
I'm surprised this is the only place in the codebase where we treat an int as a bool...
-- PMM
Quoted 4 lines · Peter Maydell
Quoted 3 lines · Paolo Bonzini
linux-user is failing to compile on Fedora 43:
Quoted 8 lines
Quoted 5 lines
../linux-user/strace.c:57:66: error: enum constant in boolean context [-Werror=int-in-bool-context]
57 | #defineFLAG_BASIC(V, M, N){ V, M | QEMU_BUILD_BUG_ON_ZERO(!(M)), N }The warning does not seem to useful and we could even disable it, but the workaround is simple in this case.
I'm surprised this is the only place in the codebase where we treat an int as a bool...
It definitely isn't. Idiomatic C...
Quoted 4 lines · Peter Maydell
Quoted 3 lines · Paolo Bonzini
linux-user is failing to compile on Fedora 43:
Quoted 8 lines
Quoted 5 lines
../linux-user/strace.c:57:66: error: enum constant in boolean context [-Werror=int-in-bool-context]57 | #define FLAG_BASIC(V, M, N) { V, M | QEMU_BUILD_BUG_ON_ZERO(!(M)), N }The warning does not seem to useful and we could even disable it, but the workaround is simple in this case.
I'm surprised this is the only place in the codebase where we treat an int as a bool...
There are some heuristics about suspicious uses. Examples in the documentation include "if (a <= b ? 2 : 3)" and "1 << a" in boolean context.
Paolo