Commit 54ed36e3 authored by Thomas Haller's avatar Thomas Haller
Browse files

nmtst: fix compiler warnings and make initialization of macro variables explict



clang warns about uninitialized variables @__cur_setting_name and
@__cur_property_name as used inside @__code. Before calling to @__code,
explicitly initialize the values.

    Making all in tests
    make[4]: Entering directory `./NetworkManager/libnm-core/tests'
      CC       test-general.o
    test-general.c:2730:24: error: variable '__cur_property_name' is uninitialized when used here [-Werror,-Wuninitialized]
                                  NMTST_VARIANT_DROP_PROPERTY (NM_SETTING_CONNECTION_SETTING_NAME,
                                  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    ../../include/nm-test-utils.h:1079:20: note: expanded from macro 'NMTST_VARIANT_DROP_PROPERTY'
                                && !strcmp (__cur_property_name, __property_name)) \
                                            ^~~~~~~~~~~~~~~~~~~
    ../../include/nm-test-utils.h:1023:3: note: expanded from macro 'NMTST_VARIANT_EDITOR'
                    __code; \
                    ^
    test-general.c:2729:2: note: variable '__cur_property_name' is declared here
            NMTST_VARIANT_EDITOR (connection_dict,
            ^
    ../../include/nm-test-utils.h:1015:3: note: expanded from macro 'NMTST_VARIANT_EDITOR'
                    const char *__cur_setting_name, *__cur_property_name; \
                    ^
    [...]
Signed-off-by: Thomas Haller's avatarThomas Haller <thaller@redhat.com>
parent 1aeb0c6d
...@@ -1020,13 +1020,17 @@ typedef enum { ...@@ -1020,13 +1020,17 @@ typedef enum {
g_variant_iter_init (&__connection_iter, __connection_variant); \ g_variant_iter_init (&__connection_iter, __connection_variant); \
\ \
__phase = NMTST_VARIANT_EDITOR_CONNECTION; \ __phase = NMTST_VARIANT_EDITOR_CONNECTION; \
__cur_setting_name = NULL; \
__cur_property_name = NULL; \
__code; \ __code; \
while (g_variant_iter_next (&__connection_iter, "{&sa{sv}}", &__cur_setting_name, &__setting_iter)) { \ while (g_variant_iter_next (&__connection_iter, "{&sa{sv}}", &__cur_setting_name, &__setting_iter)) { \
g_variant_builder_init (&__setting_builder, NM_VARIANT_TYPE_SETTING); \ g_variant_builder_init (&__setting_builder, NM_VARIANT_TYPE_SETTING); \
__phase = NMTST_VARIANT_EDITOR_SETTING; \ __phase = NMTST_VARIANT_EDITOR_SETTING; \
__cur_property_name = NULL; \
__code; \ __code; \
\ \
while (g_variant_iter_next (__setting_iter, "{&sv}", &__cur_property_name, &__property_val)) { \ while ( __cur_setting_name \
&& g_variant_iter_next (__setting_iter, "{&sv}", &__cur_property_name, &__property_val)) { \
__phase = NMTST_VARIANT_EDITOR_PROPERTY; \ __phase = NMTST_VARIANT_EDITOR_PROPERTY; \
__code; \ __code; \
\ \
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment