[glib: 2/3] Fix compiler warning about uninitialized variable in desktop-app-info test



commit bd75dffc0075d6ea11022fe1fd11fbda12aa968a
Author: Sebastian Dröge <sebastian centricular com>
Date:   Thu Jan 24 16:37:23 2019 +0200

    Fix compiler warning about uninitialized variable in desktop-app-info test
    
    It would always be initialized but initialize it to NULL to silence the
    compiler, and also check that it is not NULL anymore when we expect it
    to contain a valid value.
    
    ../gio/tests/desktop-app-info.c: In function ‘test_fallback’:
    ../gio/tests/desktop-app-info.c:191:18: warning: ‘app’ may be used uninitialized in this function 
[-Wmaybe-uninitialized]
       g_assert_true (g_app_info_equal (info1, app));
                      ^~~~~~~~~~~~~~~~

 gio/tests/desktop-app-info.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
---
diff --git a/gio/tests/desktop-app-info.c b/gio/tests/desktop-app-info.c
index dd41af842..ed2f89111 100644
--- a/gio/tests/desktop-app-info.c
+++ b/gio/tests/desktop-app-info.c
@@ -155,7 +155,7 @@ test_default (void)
 static void
 test_fallback (void)
 {
-  GAppInfo *info1, *info2, *app;
+  GAppInfo *info1, *info2, *app = NULL;
   GList *apps, *recomm, *fallback, *list, *l, *m;
   GError *error = NULL;
   gint old_length;
@@ -188,6 +188,7 @@ test_fallback (void)
       if (g_app_info_equal (info1, app))
         break;
     }
+  g_assert_nonnull (app);
   g_assert_true (g_app_info_equal (info1, app));
 
   /* and that Test2 is among the fallback apps */


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]