build failure on netbsd-5 with gtk2+-2.20.1nb

Greg Troxel gdt at ir.bbn.com
Fri Jun 25 17:27:14 PDT 2010


I got a complaint about gvalue being used undefined, and sure enough the
code looks like that's possible at first glance.  The inference that one
or the other if branch will be taken because of g_return_val_if_fail
returning from the function is apparently too subtle for

  Using built-in specs.
  Target: i386--netbsdelf
  Configured with: /usr/src/tools/gcc/../../gnu/dist/gcc4/configure --enable-long-long --disable-multilib --enable-threads --disable-symvers --build=x86_64-unknown-netbsd4.99.72 --host=i386--netbsdelf --target=i386--netbsdelf --enable-__cxa_atexit
  Thread model: posix
  gcc version 4.1.3 20080704 prerelease (NetBSD nb2 20081120)

Here's a diff that points out the issues and makes it build for me.

diff --git a/src/main.c b/src/main.c
index adbe8a8..743d213 100644
--- a/src/main.c
+++ b/src/main.c
@@ -45,60 +45,62 @@ static GcMaster *master;
 #define GEOCLUE_MASTER_NAME "org.freedesktop.Geoclue.Master"
 
 static GValue *
 gconf_value_to_value (GConfValue *value)
 {
 	GValue *gvalue;
 
 	g_return_val_if_fail (value != NULL, NULL);
 	g_return_val_if_fail (value->type == GCONF_VALUE_STRING ||
 			      value->type == GCONF_VALUE_INT, NULL);
 
 	if (value->type == GCONF_VALUE_STRING) {
 		const char *str;
 
 		gvalue = g_new0 (GValue, 1);
 		str = gconf_value_get_string (value);
 
 		/* Don't add empty strings in the hashtable */
 		if (str != NULL && str[0] == '\0')
 			str = NULL;
 
 		g_value_init (gvalue, G_TYPE_STRING);
 		g_value_set_string (gvalue, str);
 	} else if (value->type == GCONF_VALUE_INT) {
 		int i;
 
 		gvalue = g_new0 (GValue, 1);
 		i = gconf_value_get_int (value);
 		g_value_init (gvalue, G_TYPE_INT);
 		g_value_set_int (gvalue, i);
+	} else {
+		gvalue = g_new0 (GValue, 1);
 	}
 
 	return gvalue;
 }
 
 static void
 debug_print_key (gboolean init,
 		 const char *key,
 		 GValue     *gvalue)
 {
 	const char *message;
 	char *string;
 
 	if (init)
 		message = "GConf key '%s' initialised to '%s'";
 	else
 		message = "GConf key '%s' changed to '%s'";
 
 	if (G_VALUE_TYPE (gvalue) == G_TYPE_STRING) {
 		string = g_value_dup_string (gvalue);
 	} else if (G_VALUE_TYPE (gvalue) == G_TYPE_INT) {
 		string = g_strdup_printf ("%d", g_value_get_int (gvalue));
 	} else {
 		return;
 	}
 
 	g_message (message, key, string);
 	g_free (string);
 }
 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 194 bytes
Desc: not available
URL: <http://lists.freedesktop.org/archives/geoclue/attachments/20100625/5915780f/attachment.pgp>


More information about the GeoClue mailing list