Blame SOURCES/0003-checkpolicy-silence-Wextra-semi-stmt-warning.patch

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