[libosinfo] Fix warnings in OsinfoLoader boolean support

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

 



I always build with -O0, which sometimes makes me some warnings. The newly
introduced boolean support in OsinfoLoader triggers some warnings when building with the
default flags:

osinfo_loader.c: In function 'osinfo_loader_boolean':
osinfo_loader.c:200:255: error: return makes integer from pointer without a cast [-Werror]
     g_return_val_if_fail(ctxt != NULL, NULL);
                                                                                                                                                                                                                                                               ^
osinfo_loader.c:201:257: error: return makes integer from pointer without a cast [-Werror]
     g_return_val_if_fail(xpath != NULL, NULL);
                                                                                                                                                                                                                                                                 ^
osinfo_loader.c: In function 'osinfo_loader_entity.isra.8':
osinfo_loader.c:331:48: error: 'value_bool' may be used uninitialized in this function [-Werror=maybe-uninitialized]
                 osinfo_entity_set_param_boolean(entity, keys[i].name, value_bool);
---
 osinfo/osinfo_loader.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/osinfo/osinfo_loader.c b/osinfo/osinfo_loader.c
index 0be18b8..b6dffba 100644
--- a/osinfo/osinfo_loader.c
+++ b/osinfo/osinfo_loader.c
@@ -197,8 +197,8 @@ osinfo_loader_boolean(const char *xpath,
     int i;
     gboolean ret = FALSE;
 
-    g_return_val_if_fail(ctxt != NULL, NULL);
-    g_return_val_if_fail(xpath != NULL, NULL);
+    g_return_val_if_fail(ctxt != NULL, FALSE);
+    g_return_val_if_fail(xpath != NULL, FALSE);
 
     count = osinfo_loader_nodeset(xpath, ctxt, &nodes, err);
 
@@ -280,7 +280,7 @@ static void osinfo_loader_entity(OsinfoLoader *loader,
     /* Standard well-known keys first, allow single value only */
     for (i = 0 ; keys != NULL && keys[i].name != NULL; i++) {
         gchar *value_str = NULL;
-        gboolean value_bool;
+        gboolean value_bool = FALSE;
         gchar *xpath = NULL;
         int j;
 
-- 
1.8.4.2

_______________________________________________
Libosinfo mailing list
Libosinfo@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libosinfo




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Fedora Users]     [Fedora Maintainers]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]

  Powered by Linux