On Ubuntu 20.04, when building with clang -Werror -Wextra-semi-stmt (which is not the default build configuration), the compiler reports: checkpolicy.c:740:33: error: empty expression statement has no effect; remove unnecessary ';' to silence this warning [-Werror,-Wextra-semi-stmt] FGETS(ans, sizeof(ans), stdin); ^ Introduce "do { } while (0)" blocks to silence such warnings. Signed-off-by: Nicolas Iooss <nicolas.iooss@xxxxxxx> --- checkpolicy/checkpolicy.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/checkpolicy/checkpolicy.c b/checkpolicy/checkpolicy.c index acf1eac41559..8af31db5c6b7 100644 --- a/checkpolicy/checkpolicy.c +++ b/checkpolicy/checkpolicy.c @@ -119,11 +119,14 @@ static __attribute__((__noreturn__)) void usage(const char *progname) } #define FGETS(out, size, in) \ -if (fgets(out,size,in)==NULL) { \ - fprintf(stderr, "fgets failed at line %d: %s\n", __LINE__,\ - strerror(errno)); \ - exit(1);\ -} +do { \ + if (fgets(out,size,in)==NULL) { \ + fprintf(stderr, "fgets failed at line %d: %s\n", __LINE__, \ + strerror(errno)); \ + exit(1);\ + } \ +} while (0) + static int print_sid(sepol_security_id_t sid, context_struct_t * context __attribute__ ((unused)), void *data -- 2.32.0