summaryrefslogtreecommitdiff
path: root/src/libnm-client-test
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2022-02-18 20:34:17 +0100
committerThomas Haller <thaller@redhat.com>2022-02-21 19:50:52 +0100
commitdab2ee8ac5c025cc8f3dcb0f0aae7bcecab961e4 (patch)
tree15dc71e87d6a6c6edb8f1877a46f4b399322a974 /src/libnm-client-test
parent445dcd9d9b3bfe61da5860e6cc9f1e598a3ae376 (diff)
downloadNetworkManager-dab2ee8ac5c025cc8f3dcb0f0aae7bcecab961e4.tar.gz
all: suppress wrong gcc-12 warning "-Wdangling-pointer"
gcc-12.0.1-0.8.fc36 is annoying with false positives. It's related to g_error() and its `for(;;) ;`. For example: ../src/libnm-glib-aux/nm-shared-utils.c: In function 'nm_utils_parse_inaddr_bin_full': ../src/libnm-glib-aux/nm-shared-utils.c:1145:26: error: dangling pointer to 'error' may be used [-Werror=dangling-pointer=] 1145 | error->message); | ^~ /usr/include/glib-2.0/glib/gmessages.h:343:32: note: in definition of macro 'g_error' 343 | __VA_ARGS__); \ | ^~~~~~~~~~~ ../src/libnm-glib-aux/nm-shared-utils.c:1133:31: note: 'error' declared here 1133 | gs_free_error GError *error = NULL; | ^~~~~ /usr/include/glib-2.0/glib/gmessages.h:341:25: error: dangling pointer to 'addrbin' may be used [-Werror=dangling-pointer=] 341 | g_log (G_LOG_DOMAIN, \ | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 342 | G_LOG_LEVEL_ERROR, \ | ~~~~~~~~~~~~~~~~~~~~~~~ 343 | __VA_ARGS__); \ | ~~~~~~~~~~~~ ../src/libnm-glib-aux/nm-shared-utils.c:1141:13: note: in expansion of macro 'g_error' 1141 | g_error("unexpected assertion failure: could parse \"%s\" as %s, but not accepted by " | ^~~~~~~ ../src/libnm-glib-aux/nm-shared-utils.c:1112:14: note: 'addrbin' declared here 1112 | NMIPAddr addrbin; | ^~~~~~~ I think the warning could potentially be useful and prevent real bugs. So don't disable it altogether, but go through the effort to suppress it at the places where it currently happens. Note that NM_PRAGMA_WARNING_DISABLE_DANGLING_POINTER macro only expands to suppressing the warning with __GNUC__ equal to 12. The purpose is to only suppress the warning where we know we want to. Hopefully other gcc versions don't have this problem. I guess, we could also write a NM_COMPILER_WARNING() check in "m4/compiler_options.m4", to disable the warning if we detect it. But that seems too cumbersome.
Diffstat (limited to 'src/libnm-client-test')
-rw-r--r--src/libnm-client-test/nm-test-utils-impl.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/src/libnm-client-test/nm-test-utils-impl.c b/src/libnm-client-test/nm-test-utils-impl.c
index ef98d9c221..ad642d2530 100644
--- a/src/libnm-client-test/nm-test-utils-impl.c
+++ b/src/libnm-client-test/nm-test-utils-impl.c
@@ -159,7 +159,9 @@ nmtstc_service_init(void)
* via pygobject. */
return NULL;
}
+ NM_PRAGMA_WARNING_DISABLE_DANGLING_POINTER
g_error("test service %s exited with error code %d", NMTSTC_NM_SERVICE, data.exit_code);
+ NM_PRAGMA_WARNING_REENABLE
}
}