From patchwork Sat Jul 3 14:31:17 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicolas Iooss X-Patchwork-Id: 12357009 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 317DFC07E9B for ; Sat, 3 Jul 2021 14:31:52 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 188306193A for ; Sat, 3 Jul 2021 14:31:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229562AbhGCOeW (ORCPT ); Sat, 3 Jul 2021 10:34:22 -0400 Received: from mx1.polytechnique.org ([129.104.30.34]:48830 "EHLO mx1.polytechnique.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229814AbhGCOeS (ORCPT ); Sat, 3 Jul 2021 10:34:18 -0400 Received: from localhost.localdomain (85-168-38-217.rev.numericable.fr [85.168.38.217]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ssl.polytechnique.org (Postfix) with ESMTPSA id 2B2DD564DD4 for ; Sat, 3 Jul 2021 16:31:43 +0200 (CEST) From: Nicolas Iooss To: selinux@vger.kernel.org Subject: [PATCH 1/6] libsepol: silence -Wextra-semi-stmt warning Date: Sat, 3 Jul 2021 16:31:17 +0200 Message-Id: <20210703143122.1441578-1-nicolas.iooss@m4x.org> X-Mailer: git-send-email 2.32.0 MIME-Version: 1.0 X-AV-Checked: ClamAV using ClamSMTP at svoboda.polytechnique.org (Sat Jul 3 16:31:43 2021 +0200 (CEST)) X-Org-Mail: nicolas.iooss.2010@polytechnique.org Precedence: bulk List-ID: X-Mailing-List: selinux@vger.kernel.org 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 Acked-by: James Carter --- 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) { From patchwork Sat Jul 3 14:31:18 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicolas Iooss X-Patchwork-Id: 12357011 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id ED5C3C07E97 for ; Sat, 3 Jul 2021 14:31:57 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id DA3C861490 for ; Sat, 3 Jul 2021 14:31:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229924AbhGCOeZ (ORCPT ); Sat, 3 Jul 2021 10:34:25 -0400 Received: from mx1.polytechnique.org ([129.104.30.34]:58759 "EHLO mx1.polytechnique.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229865AbhGCOeV (ORCPT ); Sat, 3 Jul 2021 10:34:21 -0400 Received: from localhost.localdomain (85-168-38-217.rev.numericable.fr [85.168.38.217]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ssl.polytechnique.org (Postfix) with ESMTPSA id 34E70564DD4 for ; Sat, 3 Jul 2021 16:31:46 +0200 (CEST) From: Nicolas Iooss To: selinux@vger.kernel.org Subject: [PATCH 2/6] libselinux: silence -Wextra-semi-stmt warning Date: Sat, 3 Jul 2021 16:31:18 +0200 Message-Id: <20210703143122.1441578-2-nicolas.iooss@m4x.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210703143122.1441578-1-nicolas.iooss@m4x.org> References: <20210703143122.1441578-1-nicolas.iooss@m4x.org> MIME-Version: 1.0 X-AV-Checked: ClamAV using ClamSMTP at svoboda.polytechnique.org (Sat Jul 3 16:31:46 2021 +0200 (CEST)) X-Org-Mail: nicolas.iooss.2010@polytechnique.org Precedence: bulk List-ID: X-Mailing-List: selinux@vger.kernel.org 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 --- 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 +// - Silence clang's -Wextra-semi-stmt warning - July 2021, Nicolas Iooss /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// @@ -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; } From patchwork Sat Jul 3 14:31:19 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicolas Iooss X-Patchwork-Id: 12357013 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 27F82C07E98 for ; Sat, 3 Jul 2021 14:31:58 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 0DF7961490 for ; Sat, 3 Jul 2021 14:31:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229954AbhGCOe0 (ORCPT ); Sat, 3 Jul 2021 10:34:26 -0400 Received: from mx1.polytechnique.org ([129.104.30.34]:43726 "EHLO mx1.polytechnique.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229874AbhGCOeV (ORCPT ); Sat, 3 Jul 2021 10:34:21 -0400 Received: from localhost.localdomain (85-168-38-217.rev.numericable.fr [85.168.38.217]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ssl.polytechnique.org (Postfix) with ESMTPSA id E2CCB564DD4 for ; Sat, 3 Jul 2021 16:31:46 +0200 (CEST) From: Nicolas Iooss To: selinux@vger.kernel.org Subject: [PATCH 3/6] libsemanage: silence -Wextra-semi-stmt warning Date: Sat, 3 Jul 2021 16:31:19 +0200 Message-Id: <20210703143122.1441578-3-nicolas.iooss@m4x.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210703143122.1441578-1-nicolas.iooss@m4x.org> References: <20210703143122.1441578-1-nicolas.iooss@m4x.org> MIME-Version: 1.0 X-AV-Checked: ClamAV using ClamSMTP at svoboda.polytechnique.org (Sat Jul 3 16:31:47 2021 +0200 (CEST)) X-Org-Mail: nicolas.iooss.2010@polytechnique.org Precedence: bulk List-ID: X-Mailing-List: selinux@vger.kernel.org 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 --- 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 #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) { From patchwork Sat Jul 3 14:31:20 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicolas Iooss X-Patchwork-Id: 12357015 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id EFA66C07E97 for ; Sat, 3 Jul 2021 14:32:04 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D265261490 for ; Sat, 3 Jul 2021 14:32:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229963AbhGCOe1 (ORCPT ); Sat, 3 Jul 2021 10:34:27 -0400 Received: from mx1.polytechnique.org ([129.104.30.34]:54816 "EHLO mx1.polytechnique.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229881AbhGCOeW (ORCPT ); Sat, 3 Jul 2021 10:34:22 -0400 Received: from localhost.localdomain (85-168-38-217.rev.numericable.fr [85.168.38.217]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ssl.polytechnique.org (Postfix) with ESMTPSA id 8C8CB564DD4 for ; Sat, 3 Jul 2021 16:31:47 +0200 (CEST) From: Nicolas Iooss To: selinux@vger.kernel.org Subject: [PATCH 4/6] checkpolicy: silence -Wextra-semi-stmt warning Date: Sat, 3 Jul 2021 16:31:20 +0200 Message-Id: <20210703143122.1441578-4-nicolas.iooss@m4x.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210703143122.1441578-1-nicolas.iooss@m4x.org> References: <20210703143122.1441578-1-nicolas.iooss@m4x.org> MIME-Version: 1.0 X-AV-Checked: ClamAV using ClamSMTP at svoboda.polytechnique.org (Sat Jul 3 16:31:47 2021 +0200 (CEST)) X-Org-Mail: nicolas.iooss.2010@polytechnique.org Precedence: bulk List-ID: X-Mailing-List: selinux@vger.kernel.org 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 --- 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 From patchwork Sat Jul 3 14:31:21 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicolas Iooss X-Patchwork-Id: 12357019 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3DB97C07E98 for ; Sat, 3 Jul 2021 14:32:05 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 2A9686193A for ; Sat, 3 Jul 2021 14:32:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229999AbhGCOed (ORCPT ); Sat, 3 Jul 2021 10:34:33 -0400 Received: from mx1.polytechnique.org ([129.104.30.34]:47100 "EHLO mx1.polytechnique.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229900AbhGCOeX (ORCPT ); Sat, 3 Jul 2021 10:34:23 -0400 Received: from localhost.localdomain (85-168-38-217.rev.numericable.fr [85.168.38.217]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ssl.polytechnique.org (Postfix) with ESMTPSA id 1B543564DD4 for ; Sat, 3 Jul 2021 16:31:48 +0200 (CEST) From: Nicolas Iooss To: selinux@vger.kernel.org Subject: [PATCH 5/6] policycoreutils: silence -Wextra-semi-stmt warning Date: Sat, 3 Jul 2021 16:31:21 +0200 Message-Id: <20210703143122.1441578-5-nicolas.iooss@m4x.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210703143122.1441578-1-nicolas.iooss@m4x.org> References: <20210703143122.1441578-1-nicolas.iooss@m4x.org> MIME-Version: 1.0 X-AV-Checked: ClamAV using ClamSMTP at svoboda.polytechnique.org (Sat Jul 3 16:31:48 2021 +0200 (CEST)) X-Org-Mail: nicolas.iooss.2010@polytechnique.org Precedence: bulk List-ID: X-Mailing-List: selinux@vger.kernel.org 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 --- 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); From patchwork Sat Jul 3 14:31:22 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicolas Iooss X-Patchwork-Id: 12357017 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3523FC07E9A for ; Sat, 3 Jul 2021 14:32:05 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 1DFE461935 for ; Sat, 3 Jul 2021 14:32:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229671AbhGCOeb (ORCPT ); Sat, 3 Jul 2021 10:34:31 -0400 Received: from mx1.polytechnique.org ([129.104.30.34]:43726 "EHLO mx1.polytechnique.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229904AbhGCOeX (ORCPT ); Sat, 3 Jul 2021 10:34:23 -0400 Received: from localhost.localdomain (85-168-38-217.rev.numericable.fr [85.168.38.217]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ssl.polytechnique.org (Postfix) with ESMTPSA id AF5EF564DD4 for ; Sat, 3 Jul 2021 16:31:48 +0200 (CEST) From: Nicolas Iooss To: selinux@vger.kernel.org Subject: [PATCH 6/6] mcstrans: silence -Wextra-semi-stmt warning Date: Sat, 3 Jul 2021 16:31:22 +0200 Message-Id: <20210703143122.1441578-6-nicolas.iooss@m4x.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210703143122.1441578-1-nicolas.iooss@m4x.org> References: <20210703143122.1441578-1-nicolas.iooss@m4x.org> MIME-Version: 1.0 X-AV-Checked: ClamAV using ClamSMTP at svoboda.polytechnique.org (Sat Jul 3 16:31:48 2021 +0200 (CEST)) X-Org-Mail: nicolas.iooss.2010@polytechnique.org Precedence: bulk List-ID: X-Mailing-List: selinux@vger.kernel.org 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 --- 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);