From c11ac34f4c565018aa1a5fcbdef72d5b8b2f6070 Mon Sep 17 00:00:00 2001 From: Beniamino Galvani Date: Sat, 1 Feb 2020 11:38:08 +0100 Subject: [PATCH 1/8] all: remove wrong CURL option initialization MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit curl_multi_setopt() accepts CURLMOPT_* options, not CURLOPT_* ones. Found by GCC 10: clients/cloud-setup/nm-http-client.c:700:38: error: implicit conversion from ‘enum ’ to ‘CURLMoption’ [-Werror=enum-conversion] 700 | curl_multi_setopt (priv->mhandle, CURLOPT_VERBOSE, 1); Fixes: 69f048bf0ca3 ('cloud-setup: add tool for automatic IP configuration in cloud') --- clients/cloud-setup/nm-http-client.c | 2 -- src/nm-connectivity.c | 1 - 2 files changed, 3 deletions(-) diff --git a/clients/cloud-setup/nm-http-client.c b/clients/cloud-setup/nm-http-client.c index 9ceb26c3b2..35f41fe775 100644 --- a/clients/cloud-setup/nm-http-client.c +++ b/clients/cloud-setup/nm-http-client.c @@ -696,8 +696,6 @@ constructed (GObject *object) curl_multi_setopt (priv->mhandle, CURLMOPT_SOCKETDATA, self); curl_multi_setopt (priv->mhandle, CURLMOPT_TIMERFUNCTION, _mhandle_timerfunction_cb); curl_multi_setopt (priv->mhandle, CURLMOPT_TIMERDATA, self); - if (NM_CURL_DEBUG) - curl_multi_setopt (priv->mhandle, CURLOPT_VERBOSE, 1); } G_OBJECT_CLASS (nm_http_client_parent_class)->constructed (object); diff --git a/src/nm-connectivity.c b/src/nm-connectivity.c index 207af583ce..a7a827797c 100644 --- a/src/nm-connectivity.c +++ b/src/nm-connectivity.c @@ -690,7 +690,6 @@ do_curl_request (NMConnectivityCheckHandle *cb_data) curl_multi_setopt (mhandle, CURLMOPT_SOCKETDATA, cb_data); curl_multi_setopt (mhandle, CURLMOPT_TIMERFUNCTION, multi_timer_cb); curl_multi_setopt (mhandle, CURLMOPT_TIMERDATA, cb_data); - curl_multi_setopt (mhandle, CURLOPT_VERBOSE, 1); switch (cb_data->addr_family) { case AF_INET: From d2d6a68697556877b30703e412852ac5032957e9 Mon Sep 17 00:00:00 2001 From: Beniamino Galvani Date: Sat, 1 Feb 2020 11:38:25 +0100 Subject: [PATCH 2/8] build: use -fcommon when building libnm-core Building with GCC 10 gives the following error: multiple definition of_nm_jansson_json_object_iter_key'; libnm/.libs/liblibnm.a(libnm_core_la-nm-json.o):/builddir/build/BUILD/NetworkManager-1.23.1/libnm-core/nm-json.c:24: first defined here /usr/bin/ld: libnm/.libs/liblibnm.a(libnm_core_la-nm-team-utils.o):/usr/include/jansson.h:202: multiple definition of _nm_jansson_json_object_iter'; This happens because GCC 10 defaults to -fno-common and so multiple definitions of the same global variable are not merged together. _nm_jansson_json_* symbols are defined in nm-json.c as void pointers and, due to the following macros in nm-json.h: #define json_object_iter_next (*_nm_jansson_json_object_iter_next) ... the function declaration in jansson.h: void *json_object_iter_next(json_t *object, void *iter); becomes a global variable as well: void *(*_nm_jansson_json_object_iter_next)(json_t *object, void *iter); So, the symbol is present in nm-json.o and all other object files that include nm-json.h, and -fcommon is required. Without it, it would be necessary to define the symbols only in one place (for example, nm-json.c), but then static inline functions from the jannson.h header would still refer to the original (missing) jansson functions. For the moment, just use -fcommon. --- Makefile.am | 1 + libnm-core/meson.build | 5 ++++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/Makefile.am b/Makefile.am index c7cb8a70e3..a6293c96fe 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1084,6 +1084,7 @@ libnm_core_libnm_core_la_CPPFLAGS = \ if WITH_JSON_VALIDATION libnm_core_libnm_core_la_CPPFLAGS += $(JANSSON_CFLAGS) +libnm_core_libnm_core_la_CFLAGS = -fcommon endif libnm_core_libnm_core_la_SOURCES = \ diff --git a/libnm-core/meson.build b/libnm-core/meson.build index 27d6e2c8cc..42340f6457 100644 --- a/libnm-core/meson.build +++ b/libnm-core/meson.build @@ -188,9 +188,12 @@ links = [ libnm_libnm_core_intern, ] +libnm_core_c_args = common_c_flags + if enable_json_validation libnm_core_sources += files('nm-json.c') deps += jansson_dep + libnm_core_c_args += ['-fcommon'] endif libnm_core = static_library( @@ -198,7 +201,7 @@ libnm_core = static_library( sources: libnm_core_sources + libnm_core_enum_sources + nm_meta_setting_source + [nm_version_macro_header], include_directories: top_inc, dependencies: deps, - c_args: common_c_flags, + c_args: libnm_core_c_args, link_with: links, ) From 207e971863976aa96b319ca652190cfc3bc2b5c0 Mon Sep 17 00:00:00 2001 From: Beniamino Galvani Date: Sat, 1 Feb 2020 11:38:41 +0100 Subject: [PATCH 3/8] build: remove duplicate definition in Makefile Fix the following warning: Makefile.am:3671: warning: $(src_devices_wifi_libnm_device_plugin_wifi_la_OBJECTS) was already defined in condition TRUE, which includes condition WITH_WIFI ... Makefile.am:1075: ... '$(src_devices_wifi_libnm_device_plugin_wifi_la_OBJECTS)' previously defined here --- Makefile.am | 2 -- 1 file changed, 2 deletions(-) diff --git a/Makefile.am b/Makefile.am index a6293c96fe..b9813f3aba 100644 --- a/Makefile.am +++ b/Makefile.am @@ -3668,8 +3668,6 @@ src_devices_wifi_libnm_device_plugin_wifi_la_LIBADD = \ src/devices/wifi/libnm-wifi-base.la \ $(GLIB_LIBS) -$(src_devices_wifi_libnm_device_plugin_wifi_la_OBJECTS): $(libnm_core_lib_h_pub_mkenums) - check-local-devices-wifi: src/devices/wifi/libnm-device-plugin-wifi.la $(srcdir)/tools/check-exports.sh $(builddir)/src/devices/wifi/.libs/libnm-device-plugin-wifi.so "$(srcdir)/linker-script-devices.ver" $(call check_so_symbols,$(builddir)/src/devices/wifi/.libs/libnm-device-plugin-wifi.so) From 6345a661535bd4aaf62b2ba4bee129762abb2954 Mon Sep 17 00:00:00 2001 From: Beniamino Galvani Date: Sat, 1 Feb 2020 11:38:57 +0100 Subject: [PATCH 4/8] platform: fix GCC warning about zero-lenght array (1) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit GCC 10 complains about accesses to elements of zero-length arrays that overlap other members of the same object: src/platform/nm-platform-utils.c: In function ‘ethtool_get_stringset’: src/platform/nm-platform-utils.c:355:27: error: array subscript 0 is outside the bounds of an interior zero-length array ‘__u32[0]’ {aka ‘unsigned int[0]’} [-Werror=zero-length-bounds] 355 | len = sset_info.info.data[0]; | ~~~~~~~~~~~~~~~~~~~^~~ In file included from src/platform/nm-platform-utils.c:12: /usr/include/linux/ethtool.h:647:8: note: while referencing ‘data’ 647 | __u32 data[0]; | ^~~~ Fix this warning. --- src/platform/nm-platform-utils.c | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/src/platform/nm-platform-utils.c b/src/platform/nm-platform-utils.c index 4f0da581d0..f907d298d1 100644 --- a/src/platform/nm-platform-utils.c +++ b/src/platform/nm-platform-utils.c @@ -335,24 +335,25 @@ _ethtool_call_once (int ifindex, gpointer edata, gsize edata_size) static struct ethtool_gstrings * ethtool_get_stringset (SocketHandle *shandle, int stringset_id) { - struct { - struct ethtool_sset_info info; - guint32 sentinel; - } sset_info = { - .info.cmd = ETHTOOL_GSSET_INFO, - .info.reserved = 0, - .info.sset_mask = (1ULL << stringset_id), - }; + char buf[sizeof (struct ethtool_sset_info) + sizeof (guint32)]; + struct ethtool_sset_info *sset_info; gs_free struct ethtool_gstrings *gstrings = NULL; gsize gstrings_len; guint32 i, len; - if (_ethtool_call_handle (shandle, &sset_info, sizeof (sset_info)) < 0) + sset_info = (struct ethtool_sset_info *) buf; + *sset_info = (struct ethtool_sset_info) { + .cmd = ETHTOOL_GSSET_INFO, + .reserved = 0, + .sset_mask = (1ULL << stringset_id), + }; + + if (_ethtool_call_handle (shandle, sset_info, sizeof (*sset_info)) < 0) return NULL; - if (!sset_info.info.sset_mask) + if (!sset_info->sset_mask) return NULL; - len = sset_info.info.data[0]; + len = sset_info->data[0]; gstrings_len = sizeof (*gstrings) + (len * ETH_GSTRING_LEN); gstrings = g_malloc0 (gstrings_len); From 5076fc0ca0e22b3db7987df561922d9efa840f26 Mon Sep 17 00:00:00 2001 From: Beniamino Galvani Date: Sat, 1 Feb 2020 11:39:16 +0100 Subject: [PATCH 5/8] platform: fix GCC warning about zero-lenght array (2) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit GCC 10 complains about accesses to elements of zero-length arrays that overlap other members of the same object: src/platform/nm-platform-utils.c: In function ‘nmp_utils_ethtool_get_permanent_address’: src/platform/nm-platform-utils.c:854:29: error: array subscript 0 is outside the bounds of an interior zero-length array ‘__u8[0]’ {aka ‘unsigned char[0]’} [-Werror=zero-length-bounds] 854 | if (NM_IN_SET (edata.e.data[0], 0, 0xFF)) { ./shared/nm-glib-aux/nm-macros-internal.h:731:20: note: in definition of macro ‘_NM_IN_SET_EVAL_N’ Fix this warning. --- src/platform/nm-platform-utils.c | 31 ++++++++++++++++--------------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/src/platform/nm-platform-utils.c b/src/platform/nm-platform-utils.c index f907d298d1..492572833e 100644 --- a/src/platform/nm-platform-utils.c +++ b/src/platform/nm-platform-utils.c @@ -832,41 +832,42 @@ nmp_utils_ethtool_get_permanent_address (int ifindex, guint8 *buf, size_t *length) { - struct { - struct ethtool_perm_addr e; - guint8 _extra_data[NM_UTILS_HWADDR_LEN_MAX + 1]; - } edata = { - .e.cmd = ETHTOOL_GPERMADDR, - .e.size = NM_UTILS_HWADDR_LEN_MAX, - }; + char ebuf[sizeof (struct ethtool_perm_addr) + NM_UTILS_HWADDR_LEN_MAX + 1]; + struct ethtool_perm_addr *edata; guint i; g_return_val_if_fail (ifindex > 0, FALSE); - if (_ethtool_call_once (ifindex, &edata, sizeof (edata)) < 0) + edata = (struct ethtool_perm_addr *) ebuf; + *edata = (struct ethtool_perm_addr) { + .cmd = ETHTOOL_GPERMADDR, + .size = NM_UTILS_HWADDR_LEN_MAX, + }; + + if (_ethtool_call_once (ifindex, edata, sizeof (*edata)) < 0) return FALSE; - if (edata.e.size > NM_UTILS_HWADDR_LEN_MAX) + if (edata->size > NM_UTILS_HWADDR_LEN_MAX) return FALSE; - if (edata.e.size < 1) + if (edata->size < 1) return FALSE; - if (NM_IN_SET (edata.e.data[0], 0, 0xFF)) { + if (NM_IN_SET (edata->data[0], 0, 0xFF)) { /* Some drivers might return a permanent address of all zeros. * Reject that (rh#1264024) * * Some drivers return a permanent address of all ones. Reject that too */ - for (i = 1; i < edata.e.size; i++) { - if (edata.e.data[0] != edata.e.data[i]) + for (i = 1; i < edata->size; i++) { + if (edata->data[0] != edata->data[i]) goto not_all_0or1; } return FALSE; } not_all_0or1: - memcpy (buf, edata.e.data, edata.e.size); - *length = edata.e.size; + memcpy (buf, edata->data, edata->size); + *length = edata->size; return TRUE; } From 482e5f04ea25a9ef9d3c6e347b7e3aecd27c4df4 Mon Sep 17 00:00:00 2001 From: Beniamino Galvani Date: Sat, 1 Feb 2020 11:39:35 +0100 Subject: [PATCH 6/8] clients: add missing 'extern' keyword --- clients/common/nm-meta-setting-desc.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/clients/common/nm-meta-setting-desc.h b/clients/common/nm-meta-setting-desc.h index f06dd3db91..c728a1502c 100644 --- a/clients/common/nm-meta-setting-desc.h +++ b/clients/common/nm-meta-setting-desc.h @@ -516,7 +516,7 @@ struct _NMMetaPropertyTypDataNested { guint nested_len; }; -const NMMetaPropertyTypDataNested nm_meta_property_typ_data_bond; +extern const NMMetaPropertyTypDataNested nm_meta_property_typ_data_bond; /*****************************************************************************/ From f3baa7b1d5496564f4119f85b295d56cb940a964 Mon Sep 17 00:00:00 2001 From: Beniamino Galvani Date: Sat, 1 Feb 2020 11:40:04 +0100 Subject: [PATCH 7/8] ifcfg-rh: add missing 'extern' keyword Add missing 'extern' keyword to fix the following error caused by GCC 10 defaulting to -fno-common: src/settings/plugins/ifcfg-rh/.libs/libnms-ifcfg-rh-core.a(libnms_ifcfg_rh_core_la-shvar.o):/root/NetworkManager/src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-utils.h:36: multiple definition of `nms_ifcfg_well_known_keys'; src/settings/plugins/ifcfg-rh/.libs/libnm_settings_plugin_ifcfg_rh_la-nms-ifcfg-rh-plugin.o:/root/NetworkManager/src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-utils.h:36: first defined here --- src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-utils.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-utils.h b/src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-utils.h index 4aed0dff51..ae0573e115 100644 --- a/src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-utils.h +++ b/src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-utils.h @@ -33,7 +33,7 @@ typedef struct { NMSIfcfgKeyTypeFlags key_flags; } NMSIfcfgKeyTypeInfo; -const NMSIfcfgKeyTypeInfo nms_ifcfg_well_known_keys[227]; +extern const NMSIfcfgKeyTypeInfo nms_ifcfg_well_known_keys[227]; const NMSIfcfgKeyTypeInfo *nms_ifcfg_well_known_key_find_info (const char *key, gssize *out_idx); From b2620e798a3f97e00b949bbb40c5fb0f277a77e9 Mon Sep 17 00:00:00 2001 From: Beniamino Galvani Date: Sat, 1 Feb 2020 13:30:19 +0100 Subject: [PATCH 8/8] n-dhcp4: fix uninitialized variable MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Properly initialize 'overload' when the space in the file section ends. shared/n-dhcp4/src/n-dhcp4-outgoing.c: In function ‘n_dhcp4_outgoing_append’: shared/n-dhcp4/src/n-dhcp4-outgoing.c:198:17: error: ‘overload’ may be used uninitialized in this function [-Werror=maybe-uninitialized] --- shared/n-dhcp4/src/n-dhcp4-outgoing.c | 1 + 1 file changed, 1 insertion(+) diff --git a/shared/n-dhcp4/src/n-dhcp4-outgoing.c b/shared/n-dhcp4/src/n-dhcp4-outgoing.c index 9912330886..f8698e6d27 100644 --- a/shared/n-dhcp4/src/n-dhcp4-outgoing.c +++ b/shared/n-dhcp4/src/n-dhcp4-outgoing.c @@ -277,6 +277,7 @@ int n_dhcp4_outgoing_append(NDhcp4Outgoing *outgoing, return 0; } + overload = outgoing->overload; if (overload & N_DHCP4_OVERLOAD_SNAME) outgoing->i_message = offsetof(NDhcp4Message, sname); else