Fix build with GCC 10

This commit is contained in:
Beniamino Galvani 2020-02-03 16:15:23 +01:00
parent 7ff623281c
commit c4c77b9ac1
2 changed files with 362 additions and 2 deletions

View File

@ -0,0 +1,357 @@
From 9ac10979452aa90c86f9d3cfe08d4d34cb74b921 Mon Sep 17 00:00:00 2001
From: Beniamino Galvani <bgalvani@redhat.com>
Date: Sat, 1 Feb 2020 11:38:08 +0100
Subject: [PATCH 1/6] 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 <anonymous> 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')
(cherry picked from commit c11ac34f4c565018aa1a5fcbdef72d5b8b2f6070)
(cherry picked from commit 7ba2040caac53d202ba1825b29833f8fa5320711)
---
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 943310955..17c6fcdf2 100644
--- a/clients/cloud-setup/nm-http-client.c
+++ b/clients/cloud-setup/nm-http-client.c
@@ -693,8 +693,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 ccac63766..e941fe7ef 100644
--- a/src/nm-connectivity.c
+++ b/src/nm-connectivity.c
@@ -686,7 +686,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:
--
2.21.1
From 756a7f312e9186af76903f9f99f60bf6d591158f Mon Sep 17 00:00:00 2001
From: Beniamino Galvani <bgalvani@redhat.com>
Date: Sat, 1 Feb 2020 11:38:25 +0100
Subject: [PATCH 2/6] 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.
(cherry picked from commit d2d6a68697556877b30703e412852ac5032957e9)
(cherry picked from commit 311872ddca7b73c88510ec382c65b8e1f3c266f5)
---
Makefile.am | 1 +
libnm-core/meson.build | 5 ++++-
2 files changed, 5 insertions(+), 1 deletion(-)
diff --git a/Makefile.am b/Makefile.am
index 089af4172..d5cbcf54c 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -1008,6 +1008,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 4c72590e7..469d4161f 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,
)
--
2.21.1
From 762739406d2687e427dcd776b5688bc1ee44e260 Mon Sep 17 00:00:00 2001
From: Beniamino Galvani <bgalvani@redhat.com>
Date: Sat, 1 Feb 2020 11:38:57 +0100
Subject: [PATCH 3/6] 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.
(cherry picked from commit 6345a661535bd4aaf62b2ba4bee129762abb2954)
(cherry picked from commit a7c1b324fdef0131b936c91eed49745c512266db)
---
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 4f0da581d..f907d298d 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);
--
2.21.1
From f1b98cbfc6466e8163f14d0e4725dbc115a2cae4 Mon Sep 17 00:00:00 2001
From: Beniamino Galvani <bgalvani@redhat.com>
Date: Sat, 1 Feb 2020 11:39:16 +0100
Subject: [PATCH 4/6] 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.
(cherry picked from commit 5076fc0ca0e22b3db7987df561922d9efa840f26)
(cherry picked from commit c02b0181cf37ce1bfc6552dc07777a101116d719)
---
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 f907d298d..492572833 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;
}
--
2.21.1
From 35e77b518612fe1a4383ebccc18241a6957f3d5b Mon Sep 17 00:00:00 2001
From: Beniamino Galvani <bgalvani@redhat.com>
Date: Sat, 1 Feb 2020 11:39:35 +0100
Subject: [PATCH 5/6] clients: add missing 'extern' keyword
(cherry picked from commit 482e5f04ea25a9ef9d3c6e347b7e3aecd27c4df4)
(cherry picked from commit 1bb93b72899393f7f2bb92e52fd76fe23b1ff185)
---
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 f06dd3db9..c728a1502 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;
/*****************************************************************************/
--
2.21.1
From 6cecab7c13dab90d84d62a49b032574c22391177 Mon Sep 17 00:00:00 2001
From: Beniamino Galvani <bgalvani@redhat.com>
Date: Sat, 1 Feb 2020 13:30:19 +0100
Subject: [PATCH 6/6] 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]
(cherry picked from commit b2620e798a3f97e00b949bbb40c5fb0f277a77e9)
(cherry picked from commit 972b0db460ed3be15efee8e615a59a2c6ad60b74)
---
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 991233088..f8698e6d2 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
--
2.21.1

View File

@ -7,7 +7,7 @@
%global epoch_version 1
%global rpm_version 1.22.6
%global real_version 1.22.6
%global release_version 1
%global release_version 2
%global snapshot %{nil}
%global git_sha %{nil}
@ -135,7 +135,7 @@ Source4: 20-connectivity-fedora.conf
Source5: 20-connectivity-redhat.conf
Source6: 70-nm-connectivity.conf
#Patch1: 0001-some.patch
Patch1: 0001-fix-build-with-gcc10.patch
Requires(post): systemd
Requires(post): /usr/sbin/update-alternatives
@ -1053,6 +1053,9 @@ fi
%changelog
* Mon Feb 3 2020 Beniamino Galvani <bgalvani@redhat.com> - 1:1.22.6-2
- Fix build with GCC 10
* Mon Feb 3 2020 Beniamino Galvani <bgalvani@redhat.com> - 1:1.22.6-1
- Update to 1.22.6