Skip to content
  • Will Thompson's avatar
    gio-test: fix leak & maybe-uninitialized warning · b45d911c
    Will Thompson authored
    GCC 8 on F29 complains:
    
    ../tests/gio-test.c: In function ‘main’:
    ../tests/gio-test.c:375:7: warning: ‘id’ may be used uninitialized in this function [-Wmaybe-uninitialized]
           g_free (id);
           ^~~~~~~~~~~
    
    In the normal case, when run without arguments, 'id' will be assigned
    exactly once, so all is fine. If run with argument '0', 'id' will never
    be assigned, so the warning is legit; but in that case the test program
    will never exit. If run with any argument greater than 1, 'id' will be
    assigned more than once but only the last incarnation will be freed.
    
    Tweak the scope of the variable to match its use, and arrange for it to
    be freed when its watch is destroyed.
    b45d911c