* [PATCH 1/6] libsepol: silence -Wextra-semi-stmt warning
@ 2021-07-03 14:31 Nicolas Iooss
2021-07-03 14:31 ` [PATCH 2/6] libselinux: " Nicolas Iooss
` (5 more replies)
0 siblings, 6 replies; 8+ messages in thread
From: Nicolas Iooss @ 2021-07-03 14:31 UTC (permalink / raw)
To: selinux
On Ubuntu 20.04, when building with clang -Werror -Wextra-semi-stmt
(which is not the default build configuration), the compiler reports:
../cil/src/cil_binary.c:4293:22: error: empty expression statement
has no effect; remove unnecessary ';' to silence this warning
[-Werror,-Wextra-semi-stmt]
mix(k->target_class);
^
../cil/src/cil_binary.c:4294:21: error: empty expression statement
has no effect; remove unnecessary ';' to silence this warning
[-Werror,-Wextra-semi-stmt]
mix(k->target_type);
^
../cil/src/cil_binary.c:4295:21: error: empty expression statement
has no effect; remove unnecessary ';' to silence this warning
[-Werror,-Wextra-semi-stmt]
mix(k->source_type);
^
../cil/src/cil_binary.c:4296:19: error: empty expression statement
has no effect; remove unnecessary ';' to silence this warning
[-Werror,-Wextra-semi-stmt]
mix(k->specified);
^
Use a do { ... } while (0) construction to silence this warning.
Moreover the same warning appears when using two semicolons to end a
statement. Remove such occurrences, like what was already done in commit
811185648af2 ("libsepol: drop repeated semicolons").
Signed-off-by: Nicolas Iooss <nicolas.iooss@m4x.org>
---
libsepol/cil/src/cil_binary.c | 4 ++--
libsepol/cil/src/cil_resolve_ast.c | 2 +-
libsepol/src/avtab.c | 4 ++--
libsepol/tests/libsepol-tests.c | 18 +++++++++++-------
4 files changed, 16 insertions(+), 12 deletions(-)
diff --git a/libsepol/cil/src/cil_binary.c b/libsepol/cil/src/cil_binary.c
index 54d13f2f3945..41105c122bc3 100644
--- a/libsepol/cil/src/cil_binary.c
+++ b/libsepol/cil/src/cil_binary.c
@@ -4277,7 +4277,7 @@ static unsigned int avrulex_hash(__attribute__((unused)) hashtab_t h, const_hash
uint32_t hash = 0;
-#define mix(input) { \
+#define mix(input) do { \
uint32_t v = input; \
v *= c1; \
v = (v << r1) | (v >> (32 - r1)); \
@@ -4285,7 +4285,7 @@ static unsigned int avrulex_hash(__attribute__((unused)) hashtab_t h, const_hash
hash ^= v; \
hash = (hash << r2) | (hash >> (32 - r2)); \
hash = hash * m + n; \
-}
+} while (0)
mix(k->target_class);
mix(k->target_type);
diff --git a/libsepol/cil/src/cil_resolve_ast.c b/libsepol/cil/src/cil_resolve_ast.c
index 32ea64e39b21..9a02e3867659 100644
--- a/libsepol/cil/src/cil_resolve_ast.c
+++ b/libsepol/cil/src/cil_resolve_ast.c
@@ -2825,7 +2825,7 @@ static int cil_build_call_args(struct cil_tree_node *call_node, struct cil_call
return SEPOL_OK;
} else {
cil_tree_log(call_node, CIL_ERR, "Unexpected arguments");
- return SEPOL_ERR;;
+ return SEPOL_ERR;
}
}
if (call->args_tree == NULL) {
diff --git a/libsepol/src/avtab.c b/libsepol/src/avtab.c
index 88e9d510f981..5e16a0e9899e 100644
--- a/libsepol/src/avtab.c
+++ b/libsepol/src/avtab.c
@@ -63,7 +63,7 @@ static inline int avtab_hash(struct avtab_key *keyp, uint32_t mask)
uint32_t hash = 0;
-#define mix(input) { \
+#define mix(input) do { \
uint32_t v = input; \
v *= c1; \
v = (v << r1) | (v >> (32 - r1)); \
@@ -71,7 +71,7 @@ static inline int avtab_hash(struct avtab_key *keyp, uint32_t mask)
hash ^= v; \
hash = (hash << r2) | (hash >> (32 - r2)); \
hash = hash * m + n; \
-}
+} while (0)
mix(keyp->target_class);
mix(keyp->target_type);
diff --git a/libsepol/tests/libsepol-tests.c b/libsepol/tests/libsepol-tests.c
index 544c792d2ab5..dc8fd5ce5f6c 100644
--- a/libsepol/tests/libsepol-tests.c
+++ b/libsepol/tests/libsepol-tests.c
@@ -36,13 +36,17 @@
int mls;
#define DECLARE_SUITE(name) \
- suite = CU_add_suite(#name, name##_test_init, name##_test_cleanup); \
- if (NULL == suite) { \
- CU_cleanup_registry(); \
- return CU_get_error(); } \
- if (name##_add_tests(suite)) { \
- CU_cleanup_registry(); \
- return CU_get_error(); }
+ do { \
+ suite = CU_add_suite(#name, name##_test_init, name##_test_cleanup); \
+ if (NULL == suite) { \
+ CU_cleanup_registry(); \
+ return CU_get_error(); \
+ } \
+ if (name##_add_tests(suite)) { \
+ CU_cleanup_registry(); \
+ return CU_get_error(); \
+ } \
+ } while (0)
static void usage(char *progname)
{
--
2.32.0
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH 2/6] libselinux: silence -Wextra-semi-stmt warning
2021-07-03 14:31 [PATCH 1/6] libsepol: silence -Wextra-semi-stmt warning Nicolas Iooss
@ 2021-07-03 14:31 ` Nicolas Iooss
2021-07-03 14:31 ` [PATCH 3/6] libsemanage: " Nicolas Iooss
` (4 subsequent siblings)
5 siblings, 0 replies; 8+ messages in thread
From: Nicolas Iooss @ 2021-07-03 14:31 UTC (permalink / raw)
To: selinux
On Ubuntu 20.04, when building with clang -Werror -Wextra-semi-stmt
(which is not the default build configuration), the compiler reports:
sha1.c:90:21: error: empty expression statement has no effect;
remove unnecessary ';' to silence this warning
[-Werror,-Wextra-semi-stmt]
R0(a,b,c,d,e, 0); R0(e,a,b,c,d, 1); R0(d,e,a,b,c, 2); R0(c,d,e,a,b, 3);
^
In file included from selinux_restorecon.c:39:
./label_file.h:458:15: error: empty expression statement has no
effect; remove unnecessary ';' to silence this warning
[-Werror,-Wextra-semi-stmt]
lineno);
^
Introduce "do { } while (0)" blocks to silence such warnings.
Signed-off-by: Nicolas Iooss <nicolas.iooss@m4x.org>
---
libselinux/src/avc_internal.h | 22 +++++++++++++-------
libselinux/src/label_internal.h | 10 +++++----
libselinux/src/load_policy.c | 2 +-
libselinux/src/procattr.c | 4 ++--
libselinux/src/sha1.c | 11 +++++-----
libselinux/utils/matchpathcon.c | 2 +-
libselinux/utils/selabel_lookup_best_match.c | 2 +-
7 files changed, 31 insertions(+), 22 deletions(-)
diff --git a/libselinux/src/avc_internal.h b/libselinux/src/avc_internal.h
index da67affc9307..a9a4aa0b3c42 100644
--- a/libselinux/src/avc_internal.h
+++ b/libselinux/src/avc_internal.h
@@ -85,10 +85,12 @@ static inline void avc_free(void *ptr)
/* this is a macro in order to use the variadic capability. */
#define avc_log(type, format...) \
- if (avc_func_log) \
- avc_func_log(format); \
- else \
- selinux_log(type, format);
+ do { \
+ if (avc_func_log) \
+ avc_func_log(format); \
+ else \
+ selinux_log(type, format); \
+ } while (0)
static inline void avc_suppl_audit(void *ptr, security_class_t class,
char *buf, size_t len)
@@ -137,14 +139,18 @@ static inline void avc_free_lock(void *lock)
#ifdef AVC_CACHE_STATS
#define avc_cache_stats_incr(field) \
- cache_stats.field ++;
+ do { \
+ cache_stats.field ++; \
+ } while (0)
#define avc_cache_stats_add(field, num) \
- cache_stats.field += num;
+ do { \
+ cache_stats.field += num; \
+ } while (0)
#else
-#define avc_cache_stats_incr(field)
-#define avc_cache_stats_add(field, num)
+#define avc_cache_stats_incr(field) do {} while (0)
+#define avc_cache_stats_add(field, num) do {} while (0)
#endif
diff --git a/libselinux/src/label_internal.h b/libselinux/src/label_internal.h
index 361b443cb9c4..782c6aa8cc0c 100644
--- a/libselinux/src/label_internal.h
+++ b/libselinux/src/label_internal.h
@@ -128,10 +128,12 @@ extern int myprintf_compat;
extern void __attribute__ ((format(printf, 1, 2)))
(*myprintf) (const char *fmt, ...) ;
-#define COMPAT_LOG(type, fmt...) if (myprintf_compat) \
- myprintf(fmt); \
- else \
- selinux_log(type, fmt);
+#define COMPAT_LOG(type, fmt...) do { \
+ if (myprintf_compat) \
+ myprintf(fmt); \
+ else \
+ selinux_log(type, fmt); \
+ } while (0)
extern int
compat_validate(struct selabel_handle *rec,
diff --git a/libselinux/src/load_policy.c b/libselinux/src/load_policy.c
index 0034fa53d6e6..5857b821e80e 100644
--- a/libselinux/src/load_policy.c
+++ b/libselinux/src/load_policy.c
@@ -80,7 +80,7 @@ int selinux_mkload_policy(int preservebools __attribute__((unused)))
if (libsepolh) {
usesepol = 1;
dlerror();
-#define DLERR() if ((errormsg = dlerror())) goto dlclose;
+#define DLERR() do { if ((errormsg = dlerror())) goto dlclose; } while (0)
vers_max = dlsym(libsepolh, "sepol_policy_kern_vers_max");
DLERR();
vers_min = dlsym(libsepolh, "sepol_policy_kern_vers_min");
diff --git a/libselinux/src/procattr.c b/libselinux/src/procattr.c
index 840570525f5f..6552ee01bca8 100644
--- a/libselinux/src/procattr.c
+++ b/libselinux/src/procattr.c
@@ -146,7 +146,7 @@ static int getprocattrcon_raw(char ** context,
default:
errno = ENOENT;
return -1;
- };
+ }
if (prev_context && prev_context != UNSET) {
*context = strdup(prev_context);
@@ -240,7 +240,7 @@ static int setprocattrcon_raw(const char * context,
default:
errno = ENOENT;
return -1;
- };
+ }
if (!context && !*prev_context)
return 0;
diff --git a/libselinux/src/sha1.c b/libselinux/src/sha1.c
index 664bbcf26eef..a848467785f3 100644
--- a/libselinux/src/sha1.c
+++ b/libselinux/src/sha1.c
@@ -16,6 +16,7 @@
// sha1.c:73:33: error: cast from 'uint8_t *' (aka 'unsigned char *') to 'CHAR64LONG16 *' increases required alignment from 1 to 4 [-Werror,-Wcast-align]
// CHAR64LONG16* block = (CHAR64LONG16*) workspace;
// William Roberts <william.c.roberts@intel.com>
+// - Silence clang's -Wextra-semi-stmt warning - July 2021, Nicolas Iooss <nicolas.iooss@m4x.org>
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@@ -49,11 +50,11 @@ typedef union
^block->l[(i+2)&15]^block->l[i&15],1))
// (R0+R1), R2, R3, R4 are the different operations used in SHA1
-#define R0(v,w,x,y,z,i) z += ((w&(x^y))^y) + blk0(i)+ 0x5A827999 + rol(v,5); w=rol(w,30);
-#define R1(v,w,x,y,z,i) z += ((w&(x^y))^y) + blk(i) + 0x5A827999 + rol(v,5); w=rol(w,30);
-#define R2(v,w,x,y,z,i) z += (w^x^y) + blk(i) + 0x6ED9EBA1 + rol(v,5); w=rol(w,30);
-#define R3(v,w,x,y,z,i) z += (((w|x)&y)|(w&x)) + blk(i) + 0x8F1BBCDC + rol(v,5); w=rol(w,30);
-#define R4(v,w,x,y,z,i) z += (w^x^y) + blk(i) + 0xCA62C1D6 + rol(v,5); w=rol(w,30);
+#define R0(v,w,x,y,z,i) do { z += ((w&(x^y))^y) + blk0(i)+ 0x5A827999 + rol(v,5); w=rol(w,30); } while (0)
+#define R1(v,w,x,y,z,i) do { z += ((w&(x^y))^y) + blk(i) + 0x5A827999 + rol(v,5); w=rol(w,30); } while (0)
+#define R2(v,w,x,y,z,i) do { z += (w^x^y) + blk(i) + 0x6ED9EBA1 + rol(v,5); w=rol(w,30); } while (0)
+#define R3(v,w,x,y,z,i) do { z += (((w|x)&y)|(w&x)) + blk(i) + 0x8F1BBCDC + rol(v,5); w=rol(w,30); } while (0)
+#define R4(v,w,x,y,z,i) do { z += (w^x^y) + blk(i) + 0xCA62C1D6 + rol(v,5); w=rol(w,30); } while (0)
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
diff --git a/libselinux/utils/matchpathcon.c b/libselinux/utils/matchpathcon.c
index a07e160dee71..1d713c01f81c 100644
--- a/libselinux/utils/matchpathcon.c
+++ b/libselinux/utils/matchpathcon.c
@@ -65,7 +65,7 @@ static mode_t string_to_mode(char *s)
return S_IFREG;
default:
return -1;
- };
+ }
return -1;
}
diff --git a/libselinux/utils/selabel_lookup_best_match.c b/libselinux/utils/selabel_lookup_best_match.c
index 6a7174233667..2cddc6cde051 100644
--- a/libselinux/utils/selabel_lookup_best_match.c
+++ b/libselinux/utils/selabel_lookup_best_match.c
@@ -47,7 +47,7 @@ static mode_t string_to_mode(char *s)
return S_IFSOCK;
case 'f':
return S_IFREG;
- };
+ }
return 0;
}
--
2.32.0
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH 3/6] libsemanage: silence -Wextra-semi-stmt warning
2021-07-03 14:31 [PATCH 1/6] libsepol: silence -Wextra-semi-stmt warning Nicolas Iooss
2021-07-03 14:31 ` [PATCH 2/6] libselinux: " Nicolas Iooss
@ 2021-07-03 14:31 ` Nicolas Iooss
2021-07-03 14:31 ` [PATCH 4/6] checkpolicy: " Nicolas Iooss
` (3 subsequent siblings)
5 siblings, 0 replies; 8+ messages in thread
From: Nicolas Iooss @ 2021-07-03 14:31 UTC (permalink / raw)
To: selinux
On Ubuntu 20.04, when building with clang -Werror -Wextra-semi-stmt
(which is not the default build configuration), the compiler reports:
genhomedircon.c:742:67: error: empty expression statement has no
effect; remove unnecessary ';' to silence this warning
[-Werror,-Wextra-semi-stmt]
const semanage_seuser_t **u2 = (const semanage_seuser_t **) arg2;;
^
Signed-off-by: Nicolas Iooss <nicolas.iooss@m4x.org>
---
libsemanage/src/genhomedircon.c | 2 +-
libsemanage/tests/libsemanage-tests.c | 18 +++++++++++-------
2 files changed, 12 insertions(+), 8 deletions(-)
diff --git a/libsemanage/src/genhomedircon.c b/libsemanage/src/genhomedircon.c
index d08c88de99a7..7ca9afc3c1c7 100644
--- a/libsemanage/src/genhomedircon.c
+++ b/libsemanage/src/genhomedircon.c
@@ -740,7 +740,7 @@ static int write_user_context(genhomedircon_settings_t * s, FILE * out,
static int seuser_sort_func(const void *arg1, const void *arg2)
{
const semanage_seuser_t **u1 = (const semanage_seuser_t **) arg1;
- const semanage_seuser_t **u2 = (const semanage_seuser_t **) arg2;;
+ const semanage_seuser_t **u2 = (const semanage_seuser_t **) arg2;
const char *name1 = semanage_seuser_get_name(*u1);
const char *name2 = semanage_seuser_get_name(*u2);
diff --git a/libsemanage/tests/libsemanage-tests.c b/libsemanage/tests/libsemanage-tests.c
index 2ae4a21be52a..ee1767034c28 100644
--- a/libsemanage/tests/libsemanage-tests.c
+++ b/libsemanage/tests/libsemanage-tests.c
@@ -41,13 +41,17 @@
#include <stdlib.h>
#define DECLARE_SUITE(name) \
- suite = CU_add_suite(#name, name##_test_init, name##_test_cleanup); \
- if (NULL == suite) { \
- CU_cleanup_registry(); \
- return CU_get_error(); } \
- if (name##_add_tests(suite)) { \
- CU_cleanup_registry(); \
- return CU_get_error(); }
+ do { \
+ suite = CU_add_suite(#name, name##_test_init, name##_test_cleanup); \
+ if (NULL == suite) { \
+ CU_cleanup_registry(); \
+ return CU_get_error(); \
+ } \
+ if (name##_add_tests(suite)) { \
+ CU_cleanup_registry(); \
+ return CU_get_error(); \
+ } \
+ } while (0)
static void usage(char *progname)
{
--
2.32.0
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH 4/6] checkpolicy: silence -Wextra-semi-stmt warning
2021-07-03 14:31 [PATCH 1/6] libsepol: silence -Wextra-semi-stmt warning Nicolas Iooss
2021-07-03 14:31 ` [PATCH 2/6] libselinux: " Nicolas Iooss
2021-07-03 14:31 ` [PATCH 3/6] libsemanage: " Nicolas Iooss
@ 2021-07-03 14:31 ` Nicolas Iooss
2021-07-03 14:31 ` [PATCH 5/6] policycoreutils: " Nicolas Iooss
` (2 subsequent siblings)
5 siblings, 0 replies; 8+ messages in thread
From: Nicolas Iooss @ 2021-07-03 14:31 UTC (permalink / raw)
To: selinux
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(-)
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
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH 5/6] policycoreutils: silence -Wextra-semi-stmt warning
2021-07-03 14:31 [PATCH 1/6] libsepol: silence -Wextra-semi-stmt warning Nicolas Iooss
` (2 preceding siblings ...)
2021-07-03 14:31 ` [PATCH 4/6] checkpolicy: " Nicolas Iooss
@ 2021-07-03 14:31 ` Nicolas Iooss
2021-07-03 14:31 ` [PATCH 6/6] mcstrans: " Nicolas Iooss
2021-07-06 15:40 ` [PATCH 1/6] libsepol: " James Carter
5 siblings, 0 replies; 8+ messages in thread
From: Nicolas Iooss @ 2021-07-03 14:31 UTC (permalink / raw)
To: selinux
On Ubuntu 20.04, when building with clang -Werror -Wextra-semi-stmt
(which is not the default build configuration), the compiler reports:
secon.c:686:3: error: empty expression statement has no effect;
remove unnecessary ';' to silence this warning
[-Werror,-Wextra-semi-stmt]
};
^
Signed-off-by: Nicolas Iooss <nicolas.iooss@m4x.org>
---
policycoreutils/newrole/newrole.c | 2 +-
policycoreutils/secon/secon.c | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/policycoreutils/newrole/newrole.c b/policycoreutils/newrole/newrole.c
index 36e2ba9c25d9..0264531acef4 100644
--- a/policycoreutils/newrole/newrole.c
+++ b/policycoreutils/newrole/newrole.c
@@ -96,7 +96,7 @@
#define USAGE_STRING "USAGE: newrole [ -r role ] [ -t type ] [ -l level ] [ -p ] [ -V ] [ -- args ]"
#ifdef USE_PAM
-#define PAM_SERVICE_CONFIG "/etc/selinux/newrole_pam.conf";
+#define PAM_SERVICE_CONFIG "/etc/selinux/newrole_pam.conf"
#endif
#define DEFAULT_PATH "/usr/bin:/bin"
diff --git a/policycoreutils/secon/secon.c b/policycoreutils/secon/secon.c
index d257a9a1ca6c..a0957d0914e1 100644
--- a/policycoreutils/secon/secon.c
+++ b/policycoreutils/secon/secon.c
@@ -683,7 +683,7 @@ static void disp_con(const char *scon_raw)
color.range_bg = strtok(NULL, " ");
color.valid = 1;
- };
+ }
if (!(con = context_new(scon)))
errx(EXIT_FAILURE, "Couldn't create context from: %s", scon);
--
2.32.0
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH 6/6] mcstrans: silence -Wextra-semi-stmt warning
2021-07-03 14:31 [PATCH 1/6] libsepol: silence -Wextra-semi-stmt warning Nicolas Iooss
` (3 preceding siblings ...)
2021-07-03 14:31 ` [PATCH 5/6] policycoreutils: " Nicolas Iooss
@ 2021-07-03 14:31 ` Nicolas Iooss
2021-07-06 15:40 ` [PATCH 1/6] libsepol: " James Carter
5 siblings, 0 replies; 8+ messages in thread
From: Nicolas Iooss @ 2021-07-03 14:31 UTC (permalink / raw)
To: selinux
On Ubuntu 20.04, when building with clang -Werror -Wextra-semi-stmt
(which is not the default build configuration), the compiler reports:
mcstransd.c:72:35: error: empty expression statement has no effect;
remove unnecessary ';' to silence this warning
[-Werror,-Wextra-semi-stmt]
log_debug("%s\n", "cleanup_exit");
^
Replace the empty log_debug substitution with a do { ... } while (0)
construction to silence this warning.
Signed-off-by: Nicolas Iooss <nicolas.iooss@m4x.org>
---
mcstrans/src/mcstrans.c | 2 +-
mcstrans/src/mcstransd.c | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/mcstrans/src/mcstrans.c b/mcstrans/src/mcstrans.c
index c0fc14e40d2f..e92dfddb0d20 100644
--- a/mcstrans/src/mcstrans.c
+++ b/mcstrans/src/mcstrans.c
@@ -43,7 +43,7 @@
#ifdef DEBUG
#define log_debug(fmt, ...) fprintf(stderr, fmt, __VA_ARGS__)
#else
-#define log_debug(fmt, ...) ;
+#define log_debug(fmt, ...) do {} while (0)
#endif
static unsigned int maxbit=0;
diff --git a/mcstrans/src/mcstransd.c b/mcstrans/src/mcstransd.c
index 07c052fd4998..59c152e73be1 100644
--- a/mcstrans/src/mcstransd.c
+++ b/mcstrans/src/mcstransd.c
@@ -40,7 +40,7 @@
//#define log_debug(fmt, ...) syslog(LOG_DEBUG, fmt, __VA_ARGS__)
#define log_debug(fmt, ...) fprintf(stderr, fmt, __VA_ARGS__)
#else
-#define log_debug(fmt, ...) ;
+#define log_debug(fmt, ...) do {} while (0)
#endif
extern int init_translations(void);
--
2.32.0
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH 1/6] libsepol: silence -Wextra-semi-stmt warning
2021-07-03 14:31 [PATCH 1/6] libsepol: silence -Wextra-semi-stmt warning Nicolas Iooss
` (4 preceding siblings ...)
2021-07-03 14:31 ` [PATCH 6/6] mcstrans: " Nicolas Iooss
@ 2021-07-06 15:40 ` James Carter
2021-07-07 16:35 ` James Carter
5 siblings, 1 reply; 8+ messages in thread
From: James Carter @ 2021-07-06 15:40 UTC (permalink / raw)
To: Nicolas Iooss; +Cc: SElinux list
On Sat, Jul 3, 2021 at 10:32 AM Nicolas Iooss <nicolas.iooss@m4x.org> wrote:
>
> On Ubuntu 20.04, when building with clang -Werror -Wextra-semi-stmt
> (which is not the default build configuration), the compiler reports:
>
> ../cil/src/cil_binary.c:4293:22: error: empty expression statement
> has no effect; remove unnecessary ';' to silence this warning
> [-Werror,-Wextra-semi-stmt]
> mix(k->target_class);
> ^
> ../cil/src/cil_binary.c:4294:21: error: empty expression statement
> has no effect; remove unnecessary ';' to silence this warning
> [-Werror,-Wextra-semi-stmt]
> mix(k->target_type);
> ^
> ../cil/src/cil_binary.c:4295:21: error: empty expression statement
> has no effect; remove unnecessary ';' to silence this warning
> [-Werror,-Wextra-semi-stmt]
> mix(k->source_type);
> ^
> ../cil/src/cil_binary.c:4296:19: error: empty expression statement
> has no effect; remove unnecessary ';' to silence this warning
> [-Werror,-Wextra-semi-stmt]
> mix(k->specified);
> ^
>
> Use a do { ... } while (0) construction to silence this warning.
>
> Moreover the same warning appears when using two semicolons to end a
> statement. Remove such occurrences, like what was already done in commit
> 811185648af2 ("libsepol: drop repeated semicolons").
>
> Signed-off-by: Nicolas Iooss <nicolas.iooss@m4x.org>
For all six patches:
Acked-by: James Carter <jwcart2@gmail.com>
> ---
> libsepol/cil/src/cil_binary.c | 4 ++--
> libsepol/cil/src/cil_resolve_ast.c | 2 +-
> libsepol/src/avtab.c | 4 ++--
> libsepol/tests/libsepol-tests.c | 18 +++++++++++-------
> 4 files changed, 16 insertions(+), 12 deletions(-)
>
> diff --git a/libsepol/cil/src/cil_binary.c b/libsepol/cil/src/cil_binary.c
> index 54d13f2f3945..41105c122bc3 100644
> --- a/libsepol/cil/src/cil_binary.c
> +++ b/libsepol/cil/src/cil_binary.c
> @@ -4277,7 +4277,7 @@ static unsigned int avrulex_hash(__attribute__((unused)) hashtab_t h, const_hash
>
> uint32_t hash = 0;
>
> -#define mix(input) { \
> +#define mix(input) do { \
> uint32_t v = input; \
> v *= c1; \
> v = (v << r1) | (v >> (32 - r1)); \
> @@ -4285,7 +4285,7 @@ static unsigned int avrulex_hash(__attribute__((unused)) hashtab_t h, const_hash
> hash ^= v; \
> hash = (hash << r2) | (hash >> (32 - r2)); \
> hash = hash * m + n; \
> -}
> +} while (0)
>
> mix(k->target_class);
> mix(k->target_type);
> diff --git a/libsepol/cil/src/cil_resolve_ast.c b/libsepol/cil/src/cil_resolve_ast.c
> index 32ea64e39b21..9a02e3867659 100644
> --- a/libsepol/cil/src/cil_resolve_ast.c
> +++ b/libsepol/cil/src/cil_resolve_ast.c
> @@ -2825,7 +2825,7 @@ static int cil_build_call_args(struct cil_tree_node *call_node, struct cil_call
> return SEPOL_OK;
> } else {
> cil_tree_log(call_node, CIL_ERR, "Unexpected arguments");
> - return SEPOL_ERR;;
> + return SEPOL_ERR;
> }
> }
> if (call->args_tree == NULL) {
> diff --git a/libsepol/src/avtab.c b/libsepol/src/avtab.c
> index 88e9d510f981..5e16a0e9899e 100644
> --- a/libsepol/src/avtab.c
> +++ b/libsepol/src/avtab.c
> @@ -63,7 +63,7 @@ static inline int avtab_hash(struct avtab_key *keyp, uint32_t mask)
>
> uint32_t hash = 0;
>
> -#define mix(input) { \
> +#define mix(input) do { \
> uint32_t v = input; \
> v *= c1; \
> v = (v << r1) | (v >> (32 - r1)); \
> @@ -71,7 +71,7 @@ static inline int avtab_hash(struct avtab_key *keyp, uint32_t mask)
> hash ^= v; \
> hash = (hash << r2) | (hash >> (32 - r2)); \
> hash = hash * m + n; \
> -}
> +} while (0)
>
> mix(keyp->target_class);
> mix(keyp->target_type);
> diff --git a/libsepol/tests/libsepol-tests.c b/libsepol/tests/libsepol-tests.c
> index 544c792d2ab5..dc8fd5ce5f6c 100644
> --- a/libsepol/tests/libsepol-tests.c
> +++ b/libsepol/tests/libsepol-tests.c
> @@ -36,13 +36,17 @@
> int mls;
>
> #define DECLARE_SUITE(name) \
> - suite = CU_add_suite(#name, name##_test_init, name##_test_cleanup); \
> - if (NULL == suite) { \
> - CU_cleanup_registry(); \
> - return CU_get_error(); } \
> - if (name##_add_tests(suite)) { \
> - CU_cleanup_registry(); \
> - return CU_get_error(); }
> + do { \
> + suite = CU_add_suite(#name, name##_test_init, name##_test_cleanup); \
> + if (NULL == suite) { \
> + CU_cleanup_registry(); \
> + return CU_get_error(); \
> + } \
> + if (name##_add_tests(suite)) { \
> + CU_cleanup_registry(); \
> + return CU_get_error(); \
> + } \
> + } while (0)
>
> static void usage(char *progname)
> {
> --
> 2.32.0
>
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 1/6] libsepol: silence -Wextra-semi-stmt warning
2021-07-06 15:40 ` [PATCH 1/6] libsepol: " James Carter
@ 2021-07-07 16:35 ` James Carter
0 siblings, 0 replies; 8+ messages in thread
From: James Carter @ 2021-07-07 16:35 UTC (permalink / raw)
To: Nicolas Iooss; +Cc: SElinux list
On Tue, Jul 6, 2021 at 11:40 AM James Carter <jwcart2@gmail.com> wrote:
>
> On Sat, Jul 3, 2021 at 10:32 AM Nicolas Iooss <nicolas.iooss@m4x.org> wrote:
> >
> > On Ubuntu 20.04, when building with clang -Werror -Wextra-semi-stmt
> > (which is not the default build configuration), the compiler reports:
> >
> > ../cil/src/cil_binary.c:4293:22: error: empty expression statement
> > has no effect; remove unnecessary ';' to silence this warning
> > [-Werror,-Wextra-semi-stmt]
> > mix(k->target_class);
> > ^
> > ../cil/src/cil_binary.c:4294:21: error: empty expression statement
> > has no effect; remove unnecessary ';' to silence this warning
> > [-Werror,-Wextra-semi-stmt]
> > mix(k->target_type);
> > ^
> > ../cil/src/cil_binary.c:4295:21: error: empty expression statement
> > has no effect; remove unnecessary ';' to silence this warning
> > [-Werror,-Wextra-semi-stmt]
> > mix(k->source_type);
> > ^
> > ../cil/src/cil_binary.c:4296:19: error: empty expression statement
> > has no effect; remove unnecessary ';' to silence this warning
> > [-Werror,-Wextra-semi-stmt]
> > mix(k->specified);
> > ^
> >
> > Use a do { ... } while (0) construction to silence this warning.
> >
> > Moreover the same warning appears when using two semicolons to end a
> > statement. Remove such occurrences, like what was already done in commit
> > 811185648af2 ("libsepol: drop repeated semicolons").
> >
> > Signed-off-by: Nicolas Iooss <nicolas.iooss@m4x.org>
>
> For all six patches:
> Acked-by: James Carter <jwcart2@gmail.com>
>
All six patches have been merged.
Thanks,
Jim
> > ---
> > libsepol/cil/src/cil_binary.c | 4 ++--
> > libsepol/cil/src/cil_resolve_ast.c | 2 +-
> > libsepol/src/avtab.c | 4 ++--
> > libsepol/tests/libsepol-tests.c | 18 +++++++++++-------
> > 4 files changed, 16 insertions(+), 12 deletions(-)
> >
> > diff --git a/libsepol/cil/src/cil_binary.c b/libsepol/cil/src/cil_binary.c
> > index 54d13f2f3945..41105c122bc3 100644
> > --- a/libsepol/cil/src/cil_binary.c
> > +++ b/libsepol/cil/src/cil_binary.c
> > @@ -4277,7 +4277,7 @@ static unsigned int avrulex_hash(__attribute__((unused)) hashtab_t h, const_hash
> >
> > uint32_t hash = 0;
> >
> > -#define mix(input) { \
> > +#define mix(input) do { \
> > uint32_t v = input; \
> > v *= c1; \
> > v = (v << r1) | (v >> (32 - r1)); \
> > @@ -4285,7 +4285,7 @@ static unsigned int avrulex_hash(__attribute__((unused)) hashtab_t h, const_hash
> > hash ^= v; \
> > hash = (hash << r2) | (hash >> (32 - r2)); \
> > hash = hash * m + n; \
> > -}
> > +} while (0)
> >
> > mix(k->target_class);
> > mix(k->target_type);
> > diff --git a/libsepol/cil/src/cil_resolve_ast.c b/libsepol/cil/src/cil_resolve_ast.c
> > index 32ea64e39b21..9a02e3867659 100644
> > --- a/libsepol/cil/src/cil_resolve_ast.c
> > +++ b/libsepol/cil/src/cil_resolve_ast.c
> > @@ -2825,7 +2825,7 @@ static int cil_build_call_args(struct cil_tree_node *call_node, struct cil_call
> > return SEPOL_OK;
> > } else {
> > cil_tree_log(call_node, CIL_ERR, "Unexpected arguments");
> > - return SEPOL_ERR;;
> > + return SEPOL_ERR;
> > }
> > }
> > if (call->args_tree == NULL) {
> > diff --git a/libsepol/src/avtab.c b/libsepol/src/avtab.c
> > index 88e9d510f981..5e16a0e9899e 100644
> > --- a/libsepol/src/avtab.c
> > +++ b/libsepol/src/avtab.c
> > @@ -63,7 +63,7 @@ static inline int avtab_hash(struct avtab_key *keyp, uint32_t mask)
> >
> > uint32_t hash = 0;
> >
> > -#define mix(input) { \
> > +#define mix(input) do { \
> > uint32_t v = input; \
> > v *= c1; \
> > v = (v << r1) | (v >> (32 - r1)); \
> > @@ -71,7 +71,7 @@ static inline int avtab_hash(struct avtab_key *keyp, uint32_t mask)
> > hash ^= v; \
> > hash = (hash << r2) | (hash >> (32 - r2)); \
> > hash = hash * m + n; \
> > -}
> > +} while (0)
> >
> > mix(keyp->target_class);
> > mix(keyp->target_type);
> > diff --git a/libsepol/tests/libsepol-tests.c b/libsepol/tests/libsepol-tests.c
> > index 544c792d2ab5..dc8fd5ce5f6c 100644
> > --- a/libsepol/tests/libsepol-tests.c
> > +++ b/libsepol/tests/libsepol-tests.c
> > @@ -36,13 +36,17 @@
> > int mls;
> >
> > #define DECLARE_SUITE(name) \
> > - suite = CU_add_suite(#name, name##_test_init, name##_test_cleanup); \
> > - if (NULL == suite) { \
> > - CU_cleanup_registry(); \
> > - return CU_get_error(); } \
> > - if (name##_add_tests(suite)) { \
> > - CU_cleanup_registry(); \
> > - return CU_get_error(); }
> > + do { \
> > + suite = CU_add_suite(#name, name##_test_init, name##_test_cleanup); \
> > + if (NULL == suite) { \
> > + CU_cleanup_registry(); \
> > + return CU_get_error(); \
> > + } \
> > + if (name##_add_tests(suite)) { \
> > + CU_cleanup_registry(); \
> > + return CU_get_error(); \
> > + } \
> > + } while (0)
> >
> > static void usage(char *progname)
> > {
> > --
> > 2.32.0
> >
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2021-07-07 16:36 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-03 14:31 [PATCH 1/6] libsepol: silence -Wextra-semi-stmt warning Nicolas Iooss
2021-07-03 14:31 ` [PATCH 2/6] libselinux: " Nicolas Iooss
2021-07-03 14:31 ` [PATCH 3/6] libsemanage: " Nicolas Iooss
2021-07-03 14:31 ` [PATCH 4/6] checkpolicy: " Nicolas Iooss
2021-07-03 14:31 ` [PATCH 5/6] policycoreutils: " Nicolas Iooss
2021-07-03 14:31 ` [PATCH 6/6] mcstrans: " Nicolas Iooss
2021-07-06 15:40 ` [PATCH 1/6] libsepol: " James Carter
2021-07-07 16:35 ` James Carter
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.