From ec251fe7d5bc24b5d38b0853bc5969f3a0ba06e2 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= Date: Fri, 27 Jan 2017 00:50:10 -0500 Subject: [PATCH] tree-wide: adjust fall through comments so that gcc is happy gcc 7 adds -Wimplicit-fallthrough=3 to -Wextra. There are a few ways we could deal with that. After we take into account the need to stay compatible with older versions of the compiler (and other compilers), I don't think adding __attribute__((fallthrough)), even as a macro, is worth the trouble. It sticks out too much, a comment is just as good. But gcc has some very specific requiremnts how the comment should look. Adjust it the specific form that it likes. I don't think the extra stuff we had in those comments was adding much value. (Note: the documentation seems to be wrong, and seems to describe a different pattern from the one that is actually used. I guess either the docs or the code will have to change before gcc 7 is finalized.) --- src/basic/siphash24.c | 7 +++++++ src/basic/time-util.c | 2 +- src/core/socket.c | 1 + src/core/timer.c | 3 ++- src/journal/journal-file.c | 2 +- src/libsystemd-network/sd-dhcp6-client.c | 2 +- src/libsystemd/sd-device/sd-device.c | 2 +- src/nspawn/nspawn.c | 2 +- 8 files changed, 15 insertions(+), 6 deletions(-) diff --git a/src/basic/siphash24.c b/src/basic/siphash24.c index 8c1cdc3db6a..4bb41786c8b 100644 --- a/src/basic/siphash24.c +++ b/src/basic/siphash24.c @@ -127,18 +127,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 */ case 6: state->padding |= ((uint64_t) in[5]) << 40; + /* fall through */ case 5: state->padding |= ((uint64_t) in[4]) << 32; + /* fall through */ case 4: state->padding |= ((uint64_t) in[3]) << 24; + /* fall through */ case 3: state->padding |= ((uint64_t) in[2]) << 16; + /* fall through */ case 2: state->padding |= ((uint64_t) in[1]) << 8; + /* fall through */ case 1: state->padding |= ((uint64_t) in[0]); + /* fall through */ case 0: break; } diff --git a/src/basic/time-util.c b/src/basic/time-util.c index 7a5b29d77e5..1310c76336e 100644 --- a/src/basic/time-util.c +++ b/src/basic/time-util.c @@ -1271,7 +1271,7 @@ bool clock_supported(clockid_t clock) { if (!clock_boottime_supported()) return false; - /* fall through, after checking the cached value for CLOCK_BOOTTIME. */ + /* fall through */ default: /* For everything else, check properly */ diff --git a/src/core/socket.c b/src/core/socket.c index 3cae6b31bbc..a7b9ada65ca 100644 --- a/src/core/socket.c +++ b/src/core/socket.c @@ -2668,6 +2668,7 @@ const char* socket_port_type_to_string(SocketPort *p) { if (socket_address_family(&p->address) == AF_NETLINK) return "Netlink"; + /* fall through */ default: return NULL; } diff --git a/src/core/timer.c b/src/core/timer.c index c6b28dd9c59..5ee14669d2a 100644 --- a/src/core/timer.c +++ b/src/core/timer.c @@ -422,7 +422,8 @@ static void timer_enter_waiting(Timer *t, bool initial) { } /* In a container we don't want to include the time the host * was already up when the container started, so count from - * our own startup. Fall through. */ + * our own startup. */ + /* fall through */ case TIMER_STARTUP: base = UNIT(t)->manager->userspace_timestamp.monotonic; break; diff --git a/src/journal/journal-file.c b/src/journal/journal-file.c index d3e02147318..e45d1905e7e 100644 --- a/src/journal/journal-file.c +++ b/src/journal/journal-file.c @@ -285,7 +285,7 @@ static int journal_file_set_online(JournalFile *f) { continue; /* Canceled restart from offlining, must wait for offlining to complete however. */ - /* fall through to wait */ + /* fall through */ default: { int r; diff --git a/src/libsystemd-network/sd-dhcp6-client.c b/src/libsystemd-network/sd-dhcp6-client.c index e81215f7d77..6444b0ce94b 100644 --- a/src/libsystemd-network/sd-dhcp6-client.c +++ b/src/libsystemd-network/sd-dhcp6-client.c @@ -999,7 +999,7 @@ static int client_receive_message( break; } - /* fall through for Soliciation Rapid Commit option check */ + /* fall through */ /* for Soliciation Rapid Commit option check */ case DHCP6_STATE_REQUEST: case DHCP6_STATE_RENEW: case DHCP6_STATE_REBIND: diff --git a/src/libsystemd/sd-device/sd-device.c b/src/libsystemd/sd-device/sd-device.c index bc5e92f8fe6..efeadf0cd4b 100644 --- a/src/libsystemd/sd-device/sd-device.c +++ b/src/libsystemd/sd-device/sd-device.c @@ -560,7 +560,7 @@ int device_read_uevent_file(sd_device *device) { value = &uevent[i]; state = VALUE; - /* fall through to handle empty property */ + /* fall through */ /* to handle empty property */ case VALUE: if (strchr(NEWLINE, uevent[i])) { uevent[i] = '\0'; diff --git a/src/nspawn/nspawn.c b/src/nspawn/nspawn.c index 18d42908ff2..4913907b69d 100644 --- a/src/nspawn/nspawn.c +++ b/src/nspawn/nspawn.c @@ -1917,7 +1917,7 @@ static int wait_for_container(pid_t pid, ContainerStatus *container) { return 0; } - /* CLD_KILLED fallthrough */ + /* fall through */ case CLD_DUMPED: log_error("Container %s terminated by signal %s.", arg_machine, signal_to_string(status.si_status)); -- 2.39.2