@@ -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
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@m4x.org> --- checkpolicy/checkpolicy.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-)