utils: fix maybe-uninitialized in "nm-udev-utils.c"

CC       shared/nm-utils/libnm_core_libnm_core_la-nm-udev-utils.lo
    In file included from ./shared/nm-utils/nm-glib.h:27:0,
                     from ./shared/nm-utils/nm-macros-internal.h:29,
                     from ./shared/nm-default.h:178,
                     from shared/nm-utils/nm-udev-utils.c:21:
    shared/nm-utils/nm-udev-utils.c: In function ‘nm_udev_client_enumerate_new’:
    ./shared/nm-utils/gsystem-local-alloc.h:53:50: error: ‘to_free’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
     GS_DEFINE_CLEANUP_FUNCTION(void*, gs_local_free, g_free)
                                                      ^~~~~~
    shared/nm-utils/nm-udev-utils.c:147:18: note: ‘to_free’ was declared here
        gs_free char *to_free;
                      ^~~~~~~
    In file included from ./shared/nm-utils/nm-glib.h:27:0,
                     from ./shared/nm-utils/nm-macros-internal.h:29,
                     from ./shared/nm-default.h:178,
                     from shared/nm-utils/nm-udev-utils.c:21:
    shared/nm-utils/nm-udev-utils.c: In function ‘nm_udev_client_new’:
    ./shared/nm-utils/gsystem-local-alloc.h:53:50: error: ‘to_free’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
     GS_DEFINE_CLEANUP_FUNCTION(void*, gs_local_free, g_free)
                                                      ^~~~~~
    shared/nm-utils/nm-udev-utils.c:243:20: note: ‘to_free’ was declared here
          gs_free char *to_free;
                        ^~~~~~~

Fixes: e32839838e
This commit is contained in:
Thomas Haller 2017-05-10 15:31:15 +02:00
parent 5dd335584c
commit 0893c3756e

View file

@ -144,7 +144,7 @@ nm_udev_utils_enumerate (struct udev *uclient,
for (n = 0; subsystems[n]; n++) {
const char *subsystem;
const char *devtype;
gs_free char *to_free;
gs_free char *to_free = NULL;
_subsystem_split (subsystems[n], &subsystem, &devtype, &to_free);
@ -240,7 +240,7 @@ nm_udev_client_new (const char *const*subsystems,
/* install subsystem filters to only wake up for certain events */
for (n = 0; self->subsystems[n]; n++) {
if (self->monitor) {
gs_free char *to_free;
gs_free char *to_free = NULL;
const char *subsystem;
const char *devtype;