From a500538fb2eb329c136923242208297442569445 Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Wed, 7 Feb 2024 15:10:33 +0100 Subject: [PATCH 1/5] core: workaround "-Wnonnull-compare" warning in nm_lldp_neighbor_tlv_get_oui() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ../src/libnm-lldp/nm-lldp-neighbor.c: In function ‘nm_lldp_neighbor_tlv_get_oui’: ../src/libnm-std-aux/nm-std-aux.h:191:12: error: ‘nonnull’ argument ‘oui’ compared to NULL [-Werror=nonnull-compare] 191 | if (expr) \ | ^ ../src/libnm-std-aux/nm-std-aux.h:202:27: note: in expansion of macro ‘_NM_BOOLEAN_EXPR_IMPL’ 202 | _NM_BOOLEAN_EXPR_IMPL(NM_UNIQ, expr)) | ^~~~~~~~~~~~~~~~~~~~~ ../src/libnm-glib-aux/nm-macros-internal.h:1693:31: note: in expansion of macro ‘NM_BOOLEAN_EXPR’ 1693 | #define _G_BOOLEAN_EXPR(expr) NM_BOOLEAN_EXPR(expr) | ^~~~~~~~~~~~~~~ /usr/include/glib-2.0/glib/gmacros.h:1244:43: note: in expansion of macro ‘_G_BOOLEAN_EXPR’ 1244 | #define G_LIKELY(expr) (__builtin_expect (_G_BOOLEAN_EXPR(expr), 1)) | ^~~~~~~~~~~~~~~ /usr/include/glib-2.0/glib/gmessages.h:661:9: note: in expansion of macro ‘G_LIKELY’ 661 | if (G_LIKELY (expr)) \ | ^~~~~~~~ ../src/libnm-lldp/nm-lldp-neighbor.c:651:5: note: in expansion of macro ‘g_return_val_if_fail’ 651 | g_return_val_if_fail(oui, -EINVAL); | ^~~~~~~~~~~~~~~~~~~~ --- src/libnm-lldp/nm-lldp-neighbor.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/libnm-lldp/nm-lldp-neighbor.c b/src/libnm-lldp/nm-lldp-neighbor.c index a2a9695e8..0379cf384 100644 --- a/src/libnm-lldp/nm-lldp-neighbor.c +++ b/src/libnm-lldp/nm-lldp-neighbor.c @@ -648,9 +648,10 @@ nm_lldp_neighbor_tlv_get_oui(NMLldpNeighbor *n, uint8_t oui[static 3], uint8_t * int r; g_return_val_if_fail(n, -EINVAL); - g_return_val_if_fail(oui, -EINVAL); g_return_val_if_fail(subtype, -EINVAL); + nm_assert(oui); + r = nm_lldp_neighbor_tlv_is_type(n, NM_LLDP_TYPE_PRIVATE); if (r < 0) return r; From ad22a96da9ae1dc3ad85ce01e9fe7fe0b49e2bc5 Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Wed, 7 Feb 2024 14:58:36 +0100 Subject: [PATCH 2/5] build: use "-Wno-nonnull-compare" for building systemd systemd uses that too. We cannot enable compiler warnings that upstream doesn't want to support. See-also: https://github.com/systemd/systemd/commit/b59bce308df746e1793b134db7fec4c298ed1f61 --- configure.ac | 6 +++++- src/libnm-systemd-core/meson.build | 1 + src/libnm-systemd-shared/meson.build | 1 + src/meson.build | 8 ++++++++ 4 files changed, 15 insertions(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index ee6bd9af7..9dc6d8199 100644 --- a/configure.ac +++ b/configure.ac @@ -1157,7 +1157,11 @@ fi NM_COMPILER_WARNINGS(AM_CFLAGS, ${more_warnings_default}) -NM_COMPILER_WARNING_FLAG(LIBSYSTEMD_NM_CFLAGS, "-Wno-gnu-variable-sized-type-not-at-end") +for w in \ + -Wno-nonnull-compare \ + ; do + NM_COMPILER_WARNING_FLAG(LIBSYSTEMD_NM_CFLAGS, "$w") +done AC_SUBST(LIBSYSTEMD_NM_CFLAGS) CC_CHECK_FLAGS_APPEND([with_cflags], [CFLAGS], [\ diff --git a/src/libnm-systemd-core/meson.build b/src/libnm-systemd-core/meson.build index 6175e42c4..7e700e646 100644 --- a/src/libnm-systemd-core/meson.build +++ b/src/libnm-systemd-core/meson.build @@ -28,6 +28,7 @@ libnm_systemd_core = static_library( top_inc, src_inc, ], + c_args: libnm_systemd_common_cflags, dependencies: [ libnm_systemd_shared_dep_inc, glib_dep, diff --git a/src/libnm-systemd-shared/meson.build b/src/libnm-systemd-shared/meson.build index b32bd7f6e..3e5d1db85 100644 --- a/src/libnm-systemd-shared/meson.build +++ b/src/libnm-systemd-shared/meson.build @@ -58,6 +58,7 @@ libnm_systemd_shared = static_library( top_inc, src_inc, ], + c_args: libnm_systemd_common_cflags, dependencies: glib_dep, ) diff --git a/src/meson.build b/src/meson.build index 92e95e68e..ceeee6a02 100644 --- a/src/meson.build +++ b/src/meson.build @@ -69,6 +69,14 @@ libn_dhcp4 = static_library( ############################################################################### +libnm_systemd_common_cflags = [ ] + +libnm_systemd_common_cflags += cc.get_supported_arguments([ + '-Wno-nonnull-compare', +]) + +############################################################################### + subdir('libnm-std-aux') subdir('libnm-glib-aux') subdir('libnm-log-null') From b1016e3be80b1e610b84eba527c95bbb9c5971f4 Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Wed, 7 Feb 2024 15:06:13 +0100 Subject: [PATCH 3/5] build: workaround -Wno-calloc-transposed-args warning in systemd code Upstream systemd fixed this compiler warning. What really needs to be done, is re-importing the upstream code. In the meantime, suppress the warning that hits on GCC 14. This is a temporary workaround! See-also: https://github.com/systemd/systemd/commit/fdd84270df0062fad68783eea8b51a6ed87b67cd --- configure.ac | 1 + src/meson.build | 1 + 2 files changed, 2 insertions(+) diff --git a/configure.ac b/configure.ac index 9dc6d8199..01a1dacf4 100644 --- a/configure.ac +++ b/configure.ac @@ -1159,6 +1159,7 @@ NM_COMPILER_WARNINGS(AM_CFLAGS, ${more_warnings_default}) for w in \ -Wno-nonnull-compare \ + -Wno-calloc-transposed-args \ ; do NM_COMPILER_WARNING_FLAG(LIBSYSTEMD_NM_CFLAGS, "$w") done diff --git a/src/meson.build b/src/meson.build index ceeee6a02..5d85dafc2 100644 --- a/src/meson.build +++ b/src/meson.build @@ -73,6 +73,7 @@ libnm_systemd_common_cflags = [ ] libnm_systemd_common_cflags += cc.get_supported_arguments([ '-Wno-nonnull-compare', + '-Wno-calloc-transposed-args', ]) ############################################################################### From ced0cf800593ba7b598618ff0578c1412a942c95 Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Wed, 7 Feb 2024 15:39:21 +0100 Subject: [PATCH 4/5] core: ignore unused result warning of audit_log_user_message() Affects build on rawhide (audit-libs-4.0-8.fc40): src/core/nm-audit-manager.c: In function 'nm_audit_log': src/core/nm-audit-manager.c:188:9: error: ignoring return value of 'audit_log_user_message' declared with attribute 'warn_unused_result' [-Werror=unused-result] 188 | audit_log_user_message(priv->auditd_fd, | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 189 | AUDIT_USYS_CONFIG, | ~~~~~~~~~~~~~~~~~~ 190 | build_message(&strbuf, BACKEND_AUDITD, fields), | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 191 | NULL, | ~~~~~ 192 | NULL, | ~~~~~ 193 | NULL, | ~~~~~ 194 | success); | ~~~~~~~~ https://github.com/linux-audit/audit-userspace/commit/86bfa9bf4f9e2fff75ca437072f62b63e027f07a --- src/core/nm-audit-manager.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/src/core/nm-audit-manager.c b/src/core/nm-audit-manager.c index 4e134d1a3..7cf529460 100644 --- a/src/core/nm-audit-manager.c +++ b/src/core/nm-audit-manager.c @@ -185,13 +185,16 @@ nm_audit_log(NMAuditManager *self, priv = NM_AUDIT_MANAGER_GET_PRIVATE(self); if (priv->auditd_fd >= 0) { - audit_log_user_message(priv->auditd_fd, - AUDIT_USYS_CONFIG, - build_message(&strbuf, BACKEND_AUDITD, fields), - NULL, - NULL, - NULL, - success); + int r; + + r = audit_log_user_message(priv->auditd_fd, + AUDIT_USYS_CONFIG, + build_message(&strbuf, BACKEND_AUDITD, fields), + NULL, + NULL, + NULL, + success); + (void) r; } #endif From 7f2a32fa11d580ee65a0458f438018de12b6ae84 Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Wed, 7 Feb 2024 15:54:08 +0100 Subject: [PATCH 5/5] config/tests: fix test failure in "/config/set-values" GKeyfile changed something about how to handle invalid escape sequences. As we don't want to test GKeyfile (per-se), just adjust to test to not hit the problem. This would fail with glib2-2.79.1-1.fc40: # ./tools/run-nm-test.sh -m src/core/tests/config/test-config -p /config/set-values TAP version 13 # random seed: R02Sb8afff1ec38ca5a1b7713e8c40eb4f56 # Start of config tests # GLib-GIO-DEBUG: _g_io_module_get_default: Found default implementation local (GLocalVfs) for ?gio-vfs? # (src/core/tests/config/test-config.c:1107) invalid value in config-data .intern.with-whitespace.key2 = (null) (instead of " b c\, d ") ./tools/run-nm-test.sh: line 307: 245847 Trace/breakpoint trap (core dumped) "${NMTST_DBUS_RUN_SESSION[@]}" "$TEST" "${TEST_ARGV[@]}" exec "src/core/tests/config/test-config" failed with exit code 133 --- src/core/tests/config/test-config.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core/tests/config/test-config.c b/src/core/tests/config/test-config.c index 054b9003f..2b27d5354 100644 --- a/src/core/tests/config/test-config.c +++ b/src/core/tests/config/test-config.c @@ -1076,7 +1076,7 @@ _set_values_intern_atomic_section_2_set(NMConfig *config, g_key_file_set_value(keyfile, NM_CONFIG_KEYFILE_GROUPPREFIX_INTERN "with-whitespace", "key2", - " b c\\, d "); + " b c\\\\, d "); *out_expected_changes = NM_CONFIG_CHANGE_CAUSE_SET_VALUES | NM_CONFIG_CHANGE_VALUES | NM_CONFIG_CHANGE_VALUES_INTERN; }