diff options
author | Thomas Haller <thaller@redhat.com> | 2022-02-18 20:21:46 +0100 |
---|---|---|
committer | Thomas Haller <thaller@redhat.com> | 2022-02-21 19:50:52 +0100 |
commit | 445dcd9d9b3bfe61da5860e6cc9f1e598a3ae376 (patch) | |
tree | 44a388bc76d62dc51f405bfd563935cedcb962af | |
parent | cc28aac0dec2fe51176cfce4822f27a76da416ac (diff) | |
download | NetworkManager-445dcd9d9b3bfe61da5860e6cc9f1e598a3ae376.tar.gz |
glib-aux: add NM_PRAGMA_WARNING_DISABLE_DANGLING_POINTER macro for workaround
New gcc-12.0.1-0.8.fc36 on Fedora rawhide likes to emit false
"-Wdangling-pointer" warnings with some g_error() uses. It seems
related to g_error()'s `for(;;) ;`.
As workaround, add a macro to suppress the warning.
But only do that for gcc-12. This bug hopefully gets fixed
and we don't want to suppress useful warnings too eagerly.
https://bugzilla.redhat.com/show_bug.cgi?id=2056613
-rw-r--r-- | src/libnm-glib-aux/nm-macros-internal.h | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/src/libnm-glib-aux/nm-macros-internal.h b/src/libnm-glib-aux/nm-macros-internal.h index eec3445972..3ccf9dea22 100644 --- a/src/libnm-glib-aux/nm-macros-internal.h +++ b/src/libnm-glib-aux/nm-macros-internal.h @@ -202,6 +202,18 @@ _nm_auto_freev(gpointer ptr) /*****************************************************************************/ +/* Seems gcc-12 has a tendency for false-positive -Wdangling-pointer warnings with + * g_error()'s `for(;;);`. + * + * Work around that, but it's only for gcc 12 (for now). */ +#if defined(__GNUC__) && __GNUC__ == 12 +#define NM_PRAGMA_WARNING_DISABLE_DANGLING_POINTER NM_PRAGMA_WARNING_DISABLE("-Wdangling-pointer") +#else +#define NM_PRAGMA_WARNING_DISABLE_DANGLING_POINTER NM_PRAGMA_DIAGNOSTICS_PUSH +#endif + +/*****************************************************************************/ + /** * NM_G_ERROR_MSG: * @error: (allow-none): the #GError instance |