summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2020-11-02 16:25:53 +0100
committerThomas Haller <thaller@redhat.com>2020-11-02 22:29:55 +0100
commitbad69e546bfbc05299d018f13f61bbff5138f633 (patch)
treeea208b516ca0d91ad85184e08010801f47537f51
parent0152b5b2587d745a15a7b63cbdd7c246d5600658 (diff)
downloadNetworkManager-bad69e546bfbc05299d018f13f61bbff5138f633.tar.gz
libnm/tests: include "nm-default.h" for "libnm-core/tests/nm-core-tests-enum-types.c"
With glib2-2.67.0-1.fc34.x86_64.rpm, clang-11.0.0-2.fc34.x86_64.rpm, the generated code emits a compiler warning: libnm-core/tests/nm-core-tests-enum-types.c:17:7: error: passing 'typeof (*(&g_define_type_id__volatile)) *' (aka 'volatile unsigned long *') to parameter of type 'gsize *' (aka 'unsigned long *') discards qualifiers [-Werror,-Wincompatible-pointer-types-discards-qualifiers] if (g_once_init_enter (&g_define_type_id__volatile)) ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/glib-2.0/glib/gthread.h:260:7: note: expanded from macro 'g_once_init_enter' (!g_atomic_pointer_get (location) && \ ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/glib-2.0/glib/gatomic.h:112:38: note: expanded from macro 'g_atomic_pointer_get' __atomic_load (gapg_temp_atomic, &gapg_temp_newval, __ATOMIC_SEQ_CST); \ ^~~~~~~~~~~~~~~~~ libnm-core/tests/nm-core-tests-enum-types.c:40:7: error: passing 'typeof (*(&g_define_type_id__volatile)) *' (aka 'volatile unsigned long *') to parameter of type 'gsize *' (aka 'unsigned long *') discards qualifiers [-Werror,-Wincompatible-pointer-types-discards-qualifiers] if (g_once_init_enter (&g_define_type_id__volatile)) ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/glib-2.0/glib/gthread.h:260:7: note: expanded from macro 'g_once_init_enter' (!g_atomic_pointer_get (location) && \ ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/glib-2.0/glib/gatomic.h:112:38: note: expanded from macro 'g_atomic_pointer_get' __atomic_load (gapg_temp_atomic, &gapg_temp_newval, __ATOMIC_SEQ_CST); \ ^~~~~~~~~~~~~~~~~ libnm-core/tests/nm-core-tests-enum-types.c:63:7: error: passing 'typeof (*(&g_define_type_id__volatile)) *' (aka 'volatile unsigned long *') to parameter of type 'gsize *' (aka 'unsigned long *') discards qualifiers [-Werror,-Wincompatible-pointer-types-discards-qualifiers] if (g_once_init_enter (&g_define_type_id__volatile)) ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/glib-2.0/glib/gthread.h:260:7: note: expanded from macro 'g_once_init_enter' (!g_atomic_pointer_get (location) && \ ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/glib-2.0/glib/gatomic.h:112:38: note: expanded from macro 'g_atomic_pointer_get' __atomic_load (gapg_temp_atomic, &gapg_temp_newval, __ATOMIC_SEQ_CST); \ ^~~~~~~~~~~~~~~~~ We could pass "-Wincompatible-pointer-types-discards-qualifiers" as CFLAGS when building this file. However, we have a workaround in our "nm-glib-aux/nm-glib.h", so we can instead include "nm-default.h". At first glance, that might look like the less preferable solution. However, this file is only there for unit tests, and we also include "nm-default.h" for other sources that are generated with "glib-mkenums". So, doing it also for our tests becomes the preferable solution.
-rw-r--r--Makefile.am1
1 files changed, 1 insertions, 0 deletions
diff --git a/Makefile.am b/Makefile.am
index e95cfddacb..6e5b9446af 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -1220,6 +1220,7 @@ GLIB_GENERATED += \
libnm-core/tests/nm-core-tests-enum-types.h \
libnm-core/tests/nm-core-tests-enum-types.c
nm_core_tests_enum_types_sources = libnm-core/tests/test-general-enums.h
+nm_core_tests_enum_types_MKENUMS_C_FLAGS = --fhead '\#include "nm-default.h"\n'
libnm-core/tests/nm-core-tests-enum-types.h.stamp: libnm-core/tests/.dirstamp
libnm-core/tests/nm-core-tests-enum-types.c.stamp: libnm-core/tests/.dirstamp