From: Nicolas Iooss <nicolas.iooss@m4x.org>
To: selinux@vger.kernel.org
Subject: [PATCH 4/6] checkpolicy: silence -Wextra-semi-stmt warning
Date: Sat, 3 Jul 2021 16:31:20 +0200 [thread overview]
Message-ID: <20210703143122.1441578-4-nicolas.iooss@m4x.org> (raw)
In-Reply-To: <20210703143122.1441578-1-nicolas.iooss@m4x.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 <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
next prev parent reply other threads:[~2021-07-03 14:32 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
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 [this message]
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210703143122.1441578-4-nicolas.iooss@m4x.org \
--to=nicolas.iooss@m4x.org \
--cc=selinux@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.