From 21b6ff368438bd3e809c2fabe73038eb305df296 Mon Sep 17 00:00:00 2001 From: Zbigniew Jędrzejewski-Szmek Date: Fri, 27 Jan 2017 00:15:07 -0500 Subject: microhttpd-util: silence warnings about deprecated options --- src/journal-remote/journal-gatewayd.c | 9 ++++----- src/journal-remote/journal-remote.c | 4 ++-- src/journal-remote/microhttpd-util.h | 16 ++++++++++++++-- 3 files changed, 20 insertions(+), 9 deletions(-) (limited to 'src') diff --git a/src/journal-remote/journal-gatewayd.c b/src/journal-remote/journal-gatewayd.c index 8ad9738edf..b7c4257f49 100644 --- a/src/journal-remote/journal-gatewayd.c +++ b/src/journal-remote/journal-gatewayd.c @@ -1028,10 +1028,9 @@ int main(int argc, char *argv[]) { { MHD_OPTION_END, 0, NULL }}; int opts_pos = 2; - /* We force MHD_USE_PIPE_FOR_SHUTDOWN here, in order - * to make sure libmicrohttpd doesn't use shutdown() - * on our listening socket, which would break socket - * re-activation. See + /* We force MHD_USE_ITC here, in order to make sure + * libmicrohttpd doesn't use shutdown() on our listening + * socket, which would break socket re-activation. See * * https://lists.gnu.org/archive/html/libmicrohttpd/2015-09/msg00014.html * https://github.com/systemd/systemd/pull/1286 @@ -1040,7 +1039,7 @@ int main(int argc, char *argv[]) { int flags = MHD_USE_DEBUG | MHD_USE_DUAL_STACK | - MHD_USE_PIPE_FOR_SHUTDOWN | + MHD_USE_ITC | MHD_USE_POLL | MHD_USE_THREAD_PER_CONNECTION; diff --git a/src/journal-remote/journal-remote.c b/src/journal-remote/journal-remote.c index d86c3681b1..d0d8d936e3 100644 --- a/src/journal-remote/journal-remote.c +++ b/src/journal-remote/journal-remote.c @@ -648,9 +648,9 @@ static int setup_microhttpd_server(RemoteServer *s, int flags = MHD_USE_DEBUG | MHD_USE_DUAL_STACK | - MHD_USE_EPOLL_LINUX_ONLY | + MHD_USE_EPOLL | MHD_USE_PEDANTIC_CHECKS | - MHD_USE_PIPE_FOR_SHUTDOWN; + MHD_USE_ITC; const union MHD_DaemonInfo *info; int r, epoll_fd; diff --git a/src/journal-remote/microhttpd-util.h b/src/journal-remote/microhttpd-util.h index af26ab69fe..49def4f630 100644 --- a/src/journal-remote/microhttpd-util.h +++ b/src/journal-remote/microhttpd-util.h @@ -24,13 +24,25 @@ #include "macro.h" +/* Those defines are added when options are renamed, hence the check for the *old* name. */ + /* Compatiblity with libmicrohttpd < 0.9.38 */ #ifndef MHD_HTTP_NOT_ACCEPTABLE -#define MHD_HTTP_NOT_ACCEPTABLE MHD_HTTP_METHOD_NOT_ACCEPTABLE +# define MHD_HTTP_NOT_ACCEPTABLE MHD_HTTP_METHOD_NOT_ACCEPTABLE +#endif + +/* Renamed in µhttpd 0.9.52 */ +#ifndef MHD_USE_EPOLL_LINUX_ONLY +# define MHD_USE_EPOLL MHD_USE_EPOLL_LINUX_ONLY +#endif + +/* Renamed in µhttpd 0.9.51 */ +#ifndef MHD_USE_PIPE_FOR_SHUTDOWN +# define MHD_USE_ITC MHD_USE_PIPE_FOR_SHUTDOWN #endif #if MHD_VERSION < 0x00094203 -#define MHD_create_response_from_fd_at_offset64 MHD_create_response_from_fd_at_offset +# define MHD_create_response_from_fd_at_offset64 MHD_create_response_from_fd_at_offset #endif void microhttpd_logger(void *arg, const char *fmt, va_list ap) _printf_(2, 0); -- cgit v1.2.3-54-g00ecf From 70954c50e799fcf446544e69beb446e844e3596b Mon Sep 17 00:00:00 2001 From: Zbigniew Jędrzejewski-Szmek Date: Fri, 27 Jan 2017 00:25:20 -0500 Subject: pid1: remove duplicate const attribute gcc 7 started warning about this. --- src/core/job.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/core/job.c b/src/core/job.c index f7c4c59c32..00f7d7998f 100644 --- a/src/core/job.c +++ b/src/core/job.c @@ -697,7 +697,7 @@ _pure_ static const char *job_get_status_message_format(Unit *u, JobType t, JobR static void job_print_status_message(Unit *u, JobType t, JobResult result) { static const struct { const char *color, *word; - } const statuses[_JOB_RESULT_MAX] = { + } statuses[_JOB_RESULT_MAX] = { [JOB_DONE] = { ANSI_GREEN, " OK " }, [JOB_TIMEOUT] = { ANSI_HIGHLIGHT_RED, " TIME " }, [JOB_FAILED] = { ANSI_HIGHLIGHT_RED, "FAILED" }, -- cgit v1.2.3-54-g00ecf From 9ce6d1b319f8655100af6ecf5fd57e4558d57dd1 Mon Sep 17 00:00:00 2001 From: Zbigniew Jędrzejewski-Szmek Date: Fri, 27 Jan 2017 00:45:38 -0500 Subject: nspawn: fix clobbering of selinux context arg First bug fixed by gcc 7. Yikes. --- src/nspawn/nspawn.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'src') diff --git a/src/nspawn/nspawn.c b/src/nspawn/nspawn.c index 532be148a6..18d42908ff 100644 --- a/src/nspawn/nspawn.c +++ b/src/nspawn/nspawn.c @@ -676,9 +676,8 @@ static int parse_argv(int argc, char *argv[]) { r = free_and_strdup(&arg_machine, optarg); if (r < 0) return log_oom(); - - break; } + break; case 'Z': arg_selinux_context = optarg; -- cgit v1.2.3-54-g00ecf From ec251fe7d5bc24b5d38b0853bc5969f3a0ba06e2 Mon Sep 17 00:00:00 2001 From: Zbigniew Jędrzejewski-Szmek Date: Fri, 27 Jan 2017 00:50:10 -0500 Subject: 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(-) (limited to 'src') diff --git a/src/basic/siphash24.c b/src/basic/siphash24.c index 8c1cdc3db6..4bb41786c8 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 7a5b29d77e..1310c76336 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 3cae6b31bb..a7b9ada65c 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 c6b28dd9c5..5ee14669d2 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 d3e0214731..e45d1905e7 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 e81215f7d7..6444b0ce94 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 bc5e92f8fe..efeadf0cd4 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 18d42908ff..4913907b69 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)); -- cgit v1.2.3-54-g00ecf From ae50101aabf1c162cbab6d87062e3c6dc0a5f055 Mon Sep 17 00:00:00 2001 From: Zbigniew Jędrzejewski-Szmek Date: Fri, 27 Jan 2017 01:08:08 -0500 Subject: journal/lookup3: silence gcc 7 implicit-fallthrough warning This file doesn't include any of our headers, so just use the pragma without defining it in macros.h --- src/journal/lookup3.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src') diff --git a/src/journal/lookup3.c b/src/journal/lookup3.c index d8f1a4977d..ec725ce46c 100644 --- a/src/journal/lookup3.c +++ b/src/journal/lookup3.c @@ -48,6 +48,10 @@ on 1 byte), but shoehorning those bytes into integers efficiently is messy. # include /* attempt to define endianness */ #endif +#if __GNUC__ >= 7 +_Pragma("GCC diagnostic ignored \"-Wimplicit-fallthrough\"") +#endif + /* * My best guess at if you are big-endian or little-endian. This may * need adjustment. -- cgit v1.2.3-54-g00ecf From 2c5248e2454da53dd7378d167324e917bbe99088 Mon Sep 17 00:00:00 2001 From: Zbigniew Jędrzejewski-Szmek Date: Tue, 31 Jan 2017 19:35:04 -0500 Subject: MurmurHash: all /* fall through */ comments --- src/basic/MurmurHash2.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/basic/MurmurHash2.c b/src/basic/MurmurHash2.c index 9020793930..a282a21201 100644 --- a/src/basic/MurmurHash2.c +++ b/src/basic/MurmurHash2.c @@ -69,9 +69,9 @@ uint32_t MurmurHash2 ( const void * key, int len, uint32_t seed ) switch(len) { - case 3: h ^= data[2] << 16; - case 2: h ^= data[1] << 8; - case 1: h ^= data[0]; + case 3: h ^= data[2] << 16; /* fall through */ + case 2: h ^= data[1] << 8; /* fall through */ + case 1: h ^= data[0]; /* fall through */ h *= m; }; -- cgit v1.2.3-54-g00ecf From 6154d33de3f15bbd5d5df718103af9c37ba0a768 Mon Sep 17 00:00:00 2001 From: Zbigniew Jędrzejewski-Szmek Date: Tue, 31 Jan 2017 19:55:33 -0500 Subject: nss-util: silence warning about deprecated RES_USE_INET6 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit src/nss-resolve/nss-resolve.c: In function ‘_nss_resolve_gethostbyname_r’: src/nss-resolve/nss-resolve.c:680:13: warning: RES_USE_INET6 is deprecated NSS_GETHOSTBYNAME_FALLBACKS(resolve); ^~~~~~~~~~~~~~~~~~~~~~~~~ In glibc bz #19582, RES_USE_INET6 was deprecated. This might make sense for clients, but they didn't take into account nss module implementations which *must* continue to support the option. glibc internally defines DEPRECATED_RES_USE_INET6 which can be used without emitting a warning, but it's not exported publicly. Let's do the same, and just copy the definition to our header. --- src/basic/nss-util.h | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/basic/nss-util.h b/src/basic/nss-util.h index e7844fff96..9d927a8227 100644 --- a/src/basic/nss-util.h +++ b/src/basic/nss-util.h @@ -27,6 +27,10 @@ #define NSS_SIGNALS_BLOCK SIGALRM,SIGVTALRM,SIGPIPE,SIGCHLD,SIGTSTP,SIGIO,SIGHUP,SIGUSR1,SIGUSR2,SIGPROF,SIGURG,SIGWINCH +#ifndef DEPRECATED_RES_USE_INET6 +# define DEPRECATED_RES_USE_INET6 0x00002000 +#endif + #define NSS_GETHOSTBYNAME_PROTOTYPES(module) \ enum nss_status _nss_##module##_gethostbyname4_r( \ const char *name, \ @@ -92,7 +96,7 @@ enum nss_status _nss_##module##_gethostbyname_r( \ int *errnop, int *h_errnop) { \ enum nss_status ret = NSS_STATUS_NOTFOUND; \ \ - if (_res.options & RES_USE_INET6) \ + if (_res.options & DEPRECATED_RES_USE_INET6) \ ret = _nss_##module##_gethostbyname3_r( \ name, \ AF_INET6, \ -- cgit v1.2.3-54-g00ecf