From 7bfd0375e4573bbd65deb08511c7cd4a4ffa275c Mon Sep 17 00:00:00 2001 From: Shawn Landden Date: Sun, 19 Nov 2017 10:06:10 -0800 Subject: [PATCH] tree-wide: adjust fall through comments so that gcc is happy Distcc removes comments, making the comment silencing not work. I know there was a decision against a macro in commit ec251fe7d5bc24b5d38b0853bc5969f3a0ba06e2 --- src/basic/generate-gperfs.py | 6 ++++++ src/basic/macro.h | 1 + src/basic/siphash24.c | 14 +++++++------- src/basic/time-util.c | 3 +-- src/libelogind/sd-bus/bus-message.c | 4 ++-- src/libelogind/sd-bus/bus-objects.c | 3 +-- src/libelogind/sd-id128/id128-util.c | 4 ++-- src/login/logind-gperf.gperf | 3 +++ 8 files changed, 23 insertions(+), 15 deletions(-) diff --git a/src/basic/generate-gperfs.py b/src/basic/generate-gperfs.py index d4cc9aa45..aca9ab1fe 100755 --- a/src/basic/generate-gperfs.py +++ b/src/basic/generate-gperfs.py @@ -7,6 +7,12 @@ import sys name, prefix, input = sys.argv[1:] +print("""\ +%{ +#if __GNUC__ >= 7 +_Pragma("GCC diagnostic ignored \\"-Wimplicit-fallthrough\\"") +#endif +%}""") print("""\ struct {}_name {{ const char* name; int id; }}; %null-strings diff --git a/src/basic/macro.h b/src/basic/macro.h index a51562db3..34e0657ac 100644 --- a/src/basic/macro.h +++ b/src/basic/macro.h @@ -47,6 +47,7 @@ #define _weakref_(x) __attribute__((weakref(#x))) #define _alignas_(x) __attribute__((aligned(__alignof(x)))) #define _cleanup_(x) __attribute__((cleanup(x))) +#define _fallthrough_ __attribute__((fallthrough)) /* Temporarily disable some warnings */ #define DISABLE_WARNING_DECLARATION_AFTER_STATEMENT \ diff --git a/src/basic/siphash24.c b/src/basic/siphash24.c index 69794b680..fe1413469 100644 --- a/src/basic/siphash24.c +++ b/src/basic/siphash24.c @@ -133,25 +133,25 @@ void siphash24_compress(const void *_in, size_t inlen, struct siphash *state) { switch (left) { case 7: state->padding |= ((uint64_t) in[6]) << 48; - /* fall through */ + _fallthrough_; case 6: state->padding |= ((uint64_t) in[5]) << 40; - /* fall through */ + _fallthrough_; case 5: state->padding |= ((uint64_t) in[4]) << 32; - /* fall through */ + _fallthrough_; case 4: state->padding |= ((uint64_t) in[3]) << 24; - /* fall through */ + _fallthrough_; case 3: state->padding |= ((uint64_t) in[2]) << 16; - /* fall through */ + _fallthrough_; case 2: state->padding |= ((uint64_t) in[1]) << 8; - /* fall through */ + _fallthrough_; case 1: state->padding |= ((uint64_t) in[0]); - /* fall through */ + _fallthrough_; case 0: break; } diff --git a/src/basic/time-util.c b/src/basic/time-util.c index 68cbacc30..718d2b31b 100644 --- a/src/basic/time-util.c +++ b/src/basic/time-util.c @@ -1405,8 +1405,7 @@ bool clock_supported(clockid_t clock) { if (!clock_boottime_supported()) return false; - /* fall through */ - + _fallthrough_; default: /* For everything else, check properly */ return clock_gettime(clock, &ts) >= 0; diff --git a/src/libelogind/sd-bus/bus-message.c b/src/libelogind/sd-bus/bus-message.c index 0440cbf20..28f5c66a1 100644 --- a/src/libelogind/sd-bus/bus-message.c +++ b/src/libelogind/sd-bus/bus-message.c @@ -1436,7 +1436,7 @@ int message_append_basic(sd_bus_message *m, char type, const void *p, const void case SD_BUS_TYPE_STRING: p = strempty(p); - /* Fall through... */ + _fallthrough_; case SD_BUS_TYPE_OBJECT_PATH: if (!p) return -EINVAL; @@ -1496,7 +1496,7 @@ int message_append_basic(sd_bus_message *m, char type, const void *p, const void * into the empty string */ p = strempty(p); - /* Fall through... */ + _fallthrough_; case SD_BUS_TYPE_OBJECT_PATH: if (!p) diff --git a/src/libelogind/sd-bus/bus-objects.c b/src/libelogind/sd-bus/bus-objects.c index 0c9b2d36b..e72bd1920 100644 --- a/src/libelogind/sd-bus/bus-objects.c +++ b/src/libelogind/sd-bus/bus-objects.c @@ -1755,8 +1755,7 @@ static int add_object_vtable_internal( goto fail; } - /* Fall through */ - + _fallthrough_; case _SD_BUS_VTABLE_PROPERTY: { struct vtable_member *m; diff --git a/src/libelogind/sd-id128/id128-util.c b/src/libelogind/sd-id128/id128-util.c index 2edb8df66..9fcbc7146 100644 --- a/src/libelogind/sd-id128/id128-util.c +++ b/src/libelogind/sd-id128/id128-util.c @@ -116,7 +116,7 @@ int id128_read_fd(int fd, Id128Format f, sd_id128_t *ret) { if (buffer[32] != '\n') return -EINVAL; - /* fall through */ + _fallthrough_; case 32: /* plain UUID without trailing newline */ if (f == ID128_UUID) return -EINVAL; @@ -128,7 +128,7 @@ int id128_read_fd(int fd, Id128Format f, sd_id128_t *ret) { if (buffer[36] != '\n') return -EINVAL; - /* fall through */ + _fallthrough_; case 36: /* RFC UUID without trailing newline */ if (f == ID128_PLAIN) return -EINVAL; diff --git a/src/login/logind-gperf.gperf b/src/login/logind-gperf.gperf index a3c0861e5..63ac5a2b9 100644 --- a/src/login/logind-gperf.gperf +++ b/src/login/logind-gperf.gperf @@ -1,4 +1,7 @@ %{ +#if __GNUC__ >= 7 +_Pragma("GCC diagnostic ignored \"-Wimplicit-fallthrough\"") +#endif #include #include "conf-parser.h" #include "logind.h" -- 2.30.2