Blame SOURCES/0094-libsepol-silence-Wextra-semi-stmt-warning.patch

71cd55
From 9d85aa60d12e468e7fd510c2b5475b5299b71622 Mon Sep 17 00:00:00 2001
71cd55
From: Nicolas Iooss <nicolas.iooss@m4x.org>
71cd55
Date: Sat, 3 Jul 2021 16:31:17 +0200
71cd55
Subject: [PATCH] libsepol: silence -Wextra-semi-stmt warning
71cd55
71cd55
On Ubuntu 20.04, when building with clang -Werror -Wextra-semi-stmt
71cd55
(which is not the default build configuration), the compiler reports:
71cd55
71cd55
  ../cil/src/cil_binary.c:4293:22: error: empty expression statement
71cd55
  has no effect; remove unnecessary ';' to silence this warning
71cd55
  [-Werror,-Wextra-semi-stmt]
71cd55
          mix(k->target_class);
71cd55
                              ^
71cd55
  ../cil/src/cil_binary.c:4294:21: error: empty expression statement
71cd55
  has no effect; remove unnecessary ';' to silence this warning
71cd55
  [-Werror,-Wextra-semi-stmt]
71cd55
          mix(k->target_type);
71cd55
                             ^
71cd55
  ../cil/src/cil_binary.c:4295:21: error: empty expression statement
71cd55
  has no effect; remove unnecessary ';' to silence this warning
71cd55
  [-Werror,-Wextra-semi-stmt]
71cd55
          mix(k->source_type);
71cd55
                             ^
71cd55
  ../cil/src/cil_binary.c:4296:19: error: empty expression statement
71cd55
  has no effect; remove unnecessary ';' to silence this warning
71cd55
  [-Werror,-Wextra-semi-stmt]
71cd55
          mix(k->specified);
71cd55
                           ^
71cd55
71cd55
Use a do { ... } while (0) construction to silence this warning.
71cd55
71cd55
Moreover the same warning appears when using two semicolons to end a
71cd55
statement. Remove such occurrences, like what was already done in commit
71cd55
811185648af2 ("libsepol: drop repeated semicolons").
71cd55
71cd55
Signed-off-by: Nicolas Iooss <nicolas.iooss@m4x.org>
71cd55
---
71cd55
 libsepol/cil/src/cil_binary.c      |  4 ++--
71cd55
 libsepol/cil/src/cil_resolve_ast.c |  2 +-
71cd55
 libsepol/src/avtab.c               |  4 ++--
71cd55
 libsepol/tests/libsepol-tests.c    | 18 +++++++++++-------
71cd55
 4 files changed, 16 insertions(+), 12 deletions(-)
71cd55
71cd55
diff --git a/libsepol/cil/src/cil_binary.c b/libsepol/cil/src/cil_binary.c
71cd55
index 54d13f2f3945..41105c122bc3 100644
71cd55
--- a/libsepol/cil/src/cil_binary.c
71cd55
+++ b/libsepol/cil/src/cil_binary.c
71cd55
@@ -4277,7 +4277,7 @@ static unsigned int avrulex_hash(__attribute__((unused)) hashtab_t h, const_hash
71cd55
 
71cd55
 	uint32_t hash = 0;
71cd55
 
71cd55
-#define mix(input) { \
71cd55
+#define mix(input) do { \
71cd55
 	uint32_t v = input; \
71cd55
 	v *= c1; \
71cd55
 	v = (v << r1) | (v >> (32 - r1)); \
71cd55
@@ -4285,7 +4285,7 @@ static unsigned int avrulex_hash(__attribute__((unused)) hashtab_t h, const_hash
71cd55
 	hash ^= v; \
71cd55
 	hash = (hash << r2) | (hash >> (32 - r2)); \
71cd55
 	hash = hash * m + n; \
71cd55
-}
71cd55
+} while (0)
71cd55
 
71cd55
 	mix(k->target_class);
71cd55
 	mix(k->target_type);
71cd55
diff --git a/libsepol/cil/src/cil_resolve_ast.c b/libsepol/cil/src/cil_resolve_ast.c
71cd55
index 32ea64e39b21..9a02e3867659 100644
71cd55
--- a/libsepol/cil/src/cil_resolve_ast.c
71cd55
+++ b/libsepol/cil/src/cil_resolve_ast.c
71cd55
@@ -2825,7 +2825,7 @@ static int cil_build_call_args(struct cil_tree_node *call_node, struct cil_call
71cd55
 			return SEPOL_OK;
71cd55
 		} else {
71cd55
 			cil_tree_log(call_node, CIL_ERR, "Unexpected arguments");
71cd55
-			return SEPOL_ERR;;
71cd55
+			return SEPOL_ERR;
71cd55
 		}
71cd55
 	}
71cd55
 	if (call->args_tree == NULL) {
71cd55
diff --git a/libsepol/src/avtab.c b/libsepol/src/avtab.c
71cd55
index 88e9d510f981..5e16a0e9899e 100644
71cd55
--- a/libsepol/src/avtab.c
71cd55
+++ b/libsepol/src/avtab.c
71cd55
@@ -63,7 +63,7 @@ static inline int avtab_hash(struct avtab_key *keyp, uint32_t mask)
71cd55
 
71cd55
 	uint32_t hash = 0;
71cd55
 
71cd55
-#define mix(input) { \
71cd55
+#define mix(input) do { \
71cd55
 	uint32_t v = input; \
71cd55
 	v *= c1; \
71cd55
 	v = (v << r1) | (v >> (32 - r1)); \
71cd55
@@ -71,7 +71,7 @@ static inline int avtab_hash(struct avtab_key *keyp, uint32_t mask)
71cd55
 	hash ^= v; \
71cd55
 	hash = (hash << r2) | (hash >> (32 - r2)); \
71cd55
 	hash = hash * m + n; \
71cd55
-}
71cd55
+} while (0)
71cd55
 
71cd55
 	mix(keyp->target_class);
71cd55
 	mix(keyp->target_type);
71cd55
diff --git a/libsepol/tests/libsepol-tests.c b/libsepol/tests/libsepol-tests.c
71cd55
index 544c792d2ab5..dc8fd5ce5f6c 100644
71cd55
--- a/libsepol/tests/libsepol-tests.c
71cd55
+++ b/libsepol/tests/libsepol-tests.c
71cd55
@@ -36,13 +36,17 @@
71cd55
 int mls;
71cd55
 
71cd55
 #define DECLARE_SUITE(name) \
71cd55
-	suite = CU_add_suite(#name, name##_test_init, name##_test_cleanup); \
71cd55
-	if (NULL == suite) { \
71cd55
-		CU_cleanup_registry(); \
71cd55
-		return CU_get_error(); } \
71cd55
-	if (name##_add_tests(suite)) { \
71cd55
-		CU_cleanup_registry(); \
71cd55
-		return CU_get_error(); }
71cd55
+	do { \
71cd55
+		suite = CU_add_suite(#name, name##_test_init, name##_test_cleanup); \
71cd55
+		if (NULL == suite) { \
71cd55
+			CU_cleanup_registry(); \
71cd55
+			return CU_get_error(); \
71cd55
+		} \
71cd55
+		if (name##_add_tests(suite)) { \
71cd55
+			CU_cleanup_registry(); \
71cd55
+			return CU_get_error(); \
71cd55
+		} \
71cd55
+	} while (0)
71cd55
 
71cd55
 static void usage(char *progname)
71cd55
 {
71cd55
-- 
71cd55
2.32.0
71cd55