From c453b46b9c25ad58e368ac86d0d94efd099346d0 Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Mon, 6 Feb 2017 14:23:35 +0100 Subject: [PATCH 1/5] m4/compiler_options.m4: add line breaks for compiler options to check No change in behavior. (cherry picked from commit 6bd9f5361f5a7dbbf65f27d15f5faf71fb73bb43) --- m4/compiler_options.m4 | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/m4/compiler_options.m4 b/m4/compiler_options.m4 index 0023c36b91..e2f51c4838 100644 --- a/m4/compiler_options.m4 +++ b/m4/compiler_options.m4 @@ -61,16 +61,27 @@ if test "$GCC" = "yes" -a "$set_more_warnings" != "no"; then CFLAGS_MORE_WARNINGS="$CFLAGS_MORE_WARNINGS -Werror" fi - for option in -Wshadow -Wmissing-declarations -Wmissing-prototypes \ - -Wdeclaration-after-statement -Wformat-security \ - -Wfloat-equal -Wno-unused-parameter -Wno-sign-compare \ + for option in \ + -Wshadow \ + -Wmissing-declarations \ + -Wmissing-prototypes \ + -Wdeclaration-after-statement \ + -Wformat-security \ + -Wfloat-equal \ + -Wno-unused-parameter \ + -Wno-sign-compare \ -Wno-duplicate-decl-specifier \ -Wstrict-prototypes \ -Wno-unused-but-set-variable \ -Wno-format-y2k \ - -Wundef -Wimplicit-function-declaration \ - -Wpointer-arith -Winit-self -Wformat-nonliteral \ - -Wmissing-include-dirs -Wno-pragmas; do + -Wundef \ + -Wimplicit-function-declaration \ + -Wpointer-arith \ + -Winit-self \ + -Wformat-nonliteral \ + -Wmissing-include-dirs \ + -Wno-pragmas \ + ; do dnl GCC 4.4 does not warn when checking for -Wno-* flags (https://gcc.gnu.org/wiki/FAQ#wnowarning) _NM_COMPILER_FLAG([$(printf '%s' "$option" | sed 's/^-Wno-/-W/')], [], [CFLAGS_MORE_WARNINGS="$CFLAGS_MORE_WARNINGS $option"], []) From 55852df7c82c2a653f17721da5ec31680d3c8ce3 Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Mon, 6 Feb 2017 14:52:51 +0100 Subject: [PATCH 2/5] build: disable -Wformat-truncation warning MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The warning seems questionable and overly strict. For now, just disable it to allow building with gcc7. src/systemd/src/basic/time-util.c: In function ‘format_timespan’: src/systemd/src/basic/time-util.c:509:46: error: ‘%0*lu’ directive output between 1 and 2147483648 bytes may cause result to exceed ‘INT_MAX’ [-Werror=format-truncation=] "%s"USEC_FMT".%0*"PRI_USEC"%s", ^~~~ src/systemd/src/basic/time-util.c:509:60: note: format string is defined here "%s"USEC_FMT".%0*"PRI_USEC"%s", src/systemd/src/basic/time-util.c:509:46: note: directive argument in the range [0, 18446744073709551614] "%s"USEC_FMT".%0*"PRI_USEC"%s", ^~~~ https://mail.gnome.org/archives/networkmanager-list/2017-February/msg00001.html (cherry picked from commit 705e63a292974abeccaaabb8dd405804e676275b) --- m4/compiler_options.m4 | 1 + 1 file changed, 1 insertion(+) diff --git a/m4/compiler_options.m4 b/m4/compiler_options.m4 index e2f51c4838..11ee322fe6 100644 --- a/m4/compiler_options.m4 +++ b/m4/compiler_options.m4 @@ -81,6 +81,7 @@ if test "$GCC" = "yes" -a "$set_more_warnings" != "no"; then -Wformat-nonliteral \ -Wmissing-include-dirs \ -Wno-pragmas \ + -Wno-format-truncation \ ; do dnl GCC 4.4 does not warn when checking for -Wno-* flags (https://gcc.gnu.org/wiki/FAQ#wnowarning) _NM_COMPILER_FLAG([$(printf '%s' "$option" | sed 's/^-Wno-/-W/')], [], From 4603ce7ad0b36b81067b5dd367365340d186d3ea Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Mon, 6 Feb 2017 14:42:47 +0100 Subject: [PATCH 3/5] all: cleanup switch fall-through comments for -Wimplicit-fallthrough warning The -Wimplicit-fallthrough=3 warning is quite flexible of accepting a fall-through warning. Some comments were missing or not detected correctly. Thereby, also change all other comments to follow the exact same pattern. (cherry picked from commit 7c6c8f0d8bf394031b27f1e1d5c5220309046e38) --- libnm-core/nm-utils.c | 2 +- libnm-util/nm-utils.c | 2 +- libnm/nm-vpn-service-plugin.c | 2 +- src/devices/nm-device-ethernet.c | 4 ++-- src/devices/nm-device.c | 6 +++--- src/devices/wwan/nm-modem-broadband.c | 4 +--- src/devices/wwan/nm-modem.c | 9 +++------ src/dns/nm-dns-manager.c | 4 ++-- src/nm-config.c | 1 + src/tests/test-general.c | 4 ++-- src/vpn/nm-vpn-connection.c | 4 ++-- 11 files changed, 19 insertions(+), 23 deletions(-) diff --git a/libnm-core/nm-utils.c b/libnm-core/nm-utils.c index 4949033dd9..478a548d09 100644 --- a/libnm-core/nm-utils.c +++ b/libnm-core/nm-utils.c @@ -1070,7 +1070,7 @@ nm_utils_security_valid (NMUtilsSecurityType type, case NMU_SEC_LEAP: /* require PRIVACY bit for LEAP? */ if (adhoc) return FALSE; - /* Fall through */ + /* fall through */ case NMU_SEC_STATIC_WEP: g_assert (have_ap); if (!(ap_flags & NM_802_11_AP_FLAGS_PRIVACY)) diff --git a/libnm-util/nm-utils.c b/libnm-util/nm-utils.c index fcb6bfd4e5..04deecf986 100644 --- a/libnm-util/nm-utils.c +++ b/libnm-util/nm-utils.c @@ -697,7 +697,7 @@ nm_utils_security_valid (NMUtilsSecurityType type, case NMU_SEC_LEAP: /* require PRIVACY bit for LEAP? */ if (adhoc) return FALSE; - /* Fall through */ + /* fall through */ case NMU_SEC_STATIC_WEP: g_assert (have_ap); if (!(ap_flags & NM_802_11_AP_FLAGS_PRIVACY)) diff --git a/libnm/nm-vpn-service-plugin.c b/libnm/nm-vpn-service-plugin.c index 91451ed0f1..0b47bf5373 100644 --- a/libnm/nm-vpn-service-plugin.c +++ b/libnm/nm-vpn-service-plugin.c @@ -217,7 +217,7 @@ nm_vpn_service_plugin_disconnect (NMVpnServicePlugin *plugin, GError **err) break; case NM_VPN_SERVICE_STATE_STARTING: _emit_failure (plugin, NM_VPN_PLUGIN_FAILURE_CONNECT_FAILED); - /* fallthru */ + /* fall through */ case NM_VPN_SERVICE_STATE_STARTED: nm_vpn_service_plugin_set_state (plugin, NM_VPN_SERVICE_STATE_STOPPING); ret = NM_VPN_SERVICE_PLUGIN_GET_CLASS (plugin)->disconnect (plugin, err); diff --git a/src/devices/nm-device-ethernet.c b/src/devices/nm-device-ethernet.c index 327e54a8b6..5df16df0ea 100644 --- a/src/devices/nm-device-ethernet.c +++ b/src/devices/nm-device-ethernet.c @@ -1171,7 +1171,7 @@ dcb_state (NMDevice *device, gboolean timeout) break; } _LOGD (LOGD_DCB, "dcb_state() preconfig down falling through"); - /* carrier never went down? fall through */ + /* fall through */ case DCB_WAIT_CARRIER_PRECONFIG_UP: if (timeout || carrier) { _LOGD (LOGD_DCB, "dcb_state() preconfig up configuring DCB"); @@ -1195,7 +1195,7 @@ dcb_state (NMDevice *device, gboolean timeout) break; } _LOGD (LOGD_DCB, "dcb_state() postconfig down falling through"); - /* carrier never went down? fall through */ + /* fall through */ case DCB_WAIT_CARRIER_POSTCONFIG_UP: if (timeout || carrier) { _LOGD (LOGD_DCB, "dcb_state() postconfig up starting IP"); diff --git a/src/devices/nm-device.c b/src/devices/nm-device.c index 1fcf965c36..adce2fcf9c 100644 --- a/src/devices/nm-device.c +++ b/src/devices/nm-device.c @@ -5340,7 +5340,7 @@ dhcp4_state_changed (NMDhcpClient *client, /* Ignore expiry before we even have a lease (NAK, old lease, etc) */ if (priv->ip4_state == IP_CONF) break; - /* Fall through */ + /* fall through */ case NM_DHCP_STATE_DONE: case NM_DHCP_STATE_FAIL: dhcp4_fail (self, FALSE); @@ -6159,7 +6159,7 @@ dhcp6_state_changed (NMDhcpClient *client, */ if (priv->dhcp6.mode == NM_NDISC_DHCP_LEVEL_OTHERCONF) break; - /* Otherwise, fall through */ + /* fall through */ case NM_DHCP_STATE_FAIL: dhcp6_fail (self, FALSE); break; @@ -10336,7 +10336,7 @@ device_ipx_changed (NMPlatform *platform, priv->dad6_failed_addrs = g_slist_append (priv->dad6_failed_addrs, g_memdup (addr, sizeof (NMPlatformIP6Address))); } - /* fallthrough */ + /* fall through */ case NMP_OBJECT_TYPE_IP6_ROUTE: if (nm_device_get_unmanaged_flags (self, NM_UNMANAGED_PLATFORM_INIT)) { priv->queued_ip6_config_pending = TRUE; diff --git a/src/devices/wwan/nm-modem-broadband.c b/src/devices/wwan/nm-modem-broadband.c index e1fc45467c..7dfd38c57b 100644 --- a/src/devices/wwan/nm-modem-broadband.c +++ b/src/devices/wwan/nm-modem-broadband.c @@ -489,7 +489,6 @@ connect_context_step (NMModemBroadband *self) } ctx->step++; /* fall through */ - case CONNECT_STEP_WAIT_FOR_READY: { GError *error = NULL; @@ -527,9 +526,8 @@ connect_context_step (NMModemBroadband *self) } ctx->step++; - /* fall through */ } - + /* fall through */ case CONNECT_STEP_CONNECT: if (ctx->ip_types_i < ctx->ip_types->len) { NMModemIPType current; diff --git a/src/devices/wwan/nm-modem.c b/src/devices/wwan/nm-modem.c index 04c95a2bed..1dec0dd12f 100644 --- a/src/devices/wwan/nm-modem.c +++ b/src/devices/wwan/nm-modem.c @@ -1127,8 +1127,7 @@ deactivate_step (DeactivateContext *ctx) switch (ctx->step) { case DEACTIVATE_CONTEXT_STEP_FIRST: ctx->step++; - /* Fall down */ - + /* fall through */ case DEACTIVATE_CONTEXT_STEP_CLEANUP: /* Make sure we keep a ref to the PPP manager if there is one */ if (priv->ppp_manager) @@ -1136,8 +1135,7 @@ deactivate_step (DeactivateContext *ctx) /* Run cleanup */ NM_MODEM_GET_CLASS (ctx->self)->deactivate_cleanup (ctx->self, ctx->device); ctx->step++; - /* Fall down */ - + /* fall through */ case DEACTIVATE_CONTEXT_STEP_PPP_MANAGER_STOP: /* If we have a PPP manager, stop it */ if (ctx->ppp_manager) { @@ -1148,8 +1146,7 @@ deactivate_step (DeactivateContext *ctx) return; } ctx->step++; - /* Fall down */ - + /* fall through */ case DEACTIVATE_CONTEXT_STEP_MM_DISCONNECT: /* Disconnect asynchronously */ NM_MODEM_GET_CLASS (ctx->self)->disconnect (ctx->self, diff --git a/src/dns/nm-dns-manager.c b/src/dns/nm-dns-manager.c index dfd2fce19e..55e04180b7 100644 --- a/src/dns/nm-dns-manager.c +++ b/src/dns/nm-dns-manager.c @@ -1566,7 +1566,7 @@ _check_resconf_immutable (NMDnsManagerResolvConfManager rc_manager) case NM_DNS_MANAGER_RESOLV_CONF_MAN_UNKNOWN: case NM_DNS_MANAGER_RESOLV_CONF_MAN_IMMUTABLE: nm_assert_not_reached (); - /* fall-through */ + /* fall through */ case NM_DNS_MANAGER_RESOLV_CONF_MAN_UNMANAGED: return NM_DNS_MANAGER_RESOLV_CONF_MAN_UNMANAGED; default: @@ -1586,7 +1586,7 @@ _check_resconf_immutable (NMDnsManagerResolvConfManager rc_manager) case NM_DNS_MANAGER_RESOLV_CONF_MAN_UNMANAGED: case NM_DNS_MANAGER_RESOLV_CONF_MAN_IMMUTABLE: nm_assert_not_reached (); - /* fall-through */ + /* fall through */ case NM_DNS_MANAGER_RESOLV_CONF_MAN_FILE: case NM_DNS_MANAGER_RESOLV_CONF_MAN_RESOLVCONF: case NM_DNS_MANAGER_RESOLV_CONF_MAN_NETCONFIG: diff --git a/src/nm-config.c b/src/nm-config.c index bc8a3ea522..c68a842996 100644 --- a/src/nm-config.c +++ b/src/nm-config.c @@ -1046,6 +1046,7 @@ _string_append_val (GString *str, const char *value) case '#': case ':': g_string_append_c (str, '+'); + /* fall through */ default: g_string_append_c (str, *value); } diff --git a/src/tests/test-general.c b/src/tests/test-general.c index 53c9c0d8f6..81d8e05c1e 100644 --- a/src/tests/test-general.c +++ b/src/tests/test-general.c @@ -1291,7 +1291,7 @@ test_nm_utils_strbuf_append (void) nm_utils_strbuf_append_c (&t_buf, &t_len, str[0]); break; } - /* fall-through */ + /* fall through */ case 1: nm_utils_strbuf_append_str (&t_buf, &t_len, str); break; @@ -1300,7 +1300,7 @@ test_nm_utils_strbuf_append (void) nm_utils_strbuf_append (&t_buf, &t_len, "%c", str[0]); break; } - /* fall-through */ + /* fall through */ case 3: nm_utils_strbuf_append (&t_buf, &t_len, "%s", str); break; diff --git a/src/vpn/nm-vpn-connection.c b/src/vpn/nm-vpn-connection.c index fb9aae8a06..3d4536e702 100644 --- a/src/vpn/nm-vpn-connection.c +++ b/src/vpn/nm-vpn-connection.c @@ -637,7 +637,7 @@ _set_vpn_state (NMVpnConnection *self, /* Tear down and clean up the connection */ call_plugin_disconnect (self); vpn_cleanup (self, parent_dev); - /* Fall through */ + /* fall through */ default: priv->secrets_idx = SECRETS_REQ_SYSTEM; break; @@ -1514,7 +1514,7 @@ nm_vpn_connection_ip4_config_get (NMVpnConnection *self, GVariant *dict) switch (g_variant_n_children (v)) { case 5: g_variant_get_child (v, 4, "u", &route.pref_src); - /* fallthrough */ + /* fall through */ case 4: g_variant_get_child (v, 0, "u", &route.network); g_variant_get_child (v, 1, "u", &plen); From 23d9fbb8589a3395b88e4b2f2551406878ad9aa4 Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Mon, 6 Feb 2017 17:54:28 +0100 Subject: [PATCH 4/5] systemd: backport fall-through comments for -Wimplicit-fallthrough warning --- src/systemd/src/basic/siphash24.c | 7 +++++++ src/systemd/src/basic/time-util.c | 2 +- src/systemd/src/libsystemd-network/sd-dhcp6-client.c | 2 +- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/systemd/src/basic/siphash24.c b/src/systemd/src/basic/siphash24.c index 4db444f584..e4b1cb1081 100644 --- a/src/systemd/src/basic/siphash24.c +++ b/src/systemd/src/basic/siphash24.c @@ -129,18 +129,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/systemd/src/basic/time-util.c b/src/systemd/src/basic/time-util.c index f6de8ca51d..fa48878715 100644 --- a/src/systemd/src/basic/time-util.c +++ b/src/systemd/src/basic/time-util.c @@ -1277,7 +1277,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/systemd/src/libsystemd-network/sd-dhcp6-client.c b/src/systemd/src/libsystemd-network/sd-dhcp6-client.c index 4615cb4061..fa508d68d7 100644 --- a/src/systemd/src/libsystemd-network/sd-dhcp6-client.c +++ b/src/systemd/src/libsystemd-network/sd-dhcp6-client.c @@ -1003,7 +1003,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: From 7c5a4c684234201f446b0a20d087e8801901c152 Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Mon, 6 Feb 2017 14:42:01 +0100 Subject: [PATCH 5/5] build: enable -Wimplicit-fallthrough warning from gcc7 (cherry picked from commit 4b9cebd8ad3d9c353b7a2a80c9001fa5d1642206) --- m4/compiler_options.m4 | 1 + 1 file changed, 1 insertion(+) diff --git a/m4/compiler_options.m4 b/m4/compiler_options.m4 index 11ee322fe6..5f04644534 100644 --- a/m4/compiler_options.m4 +++ b/m4/compiler_options.m4 @@ -62,6 +62,7 @@ if test "$GCC" = "yes" -a "$set_more_warnings" != "no"; then fi for option in \ + -Wimplicit-fallthrough \ -Wshadow \ -Wmissing-declarations \ -Wmissing-prototypes \