Blame SOURCES/imsettings-fix-memleak-and-crash.patch

cbb3ed
From e1d1ef02dbaf24261f06d095b08290f1a1ad36ae Mon Sep 17 00:00:00 2001
cbb3ed
From: Akira TAGOH <akira@tagoh.org>
cbb3ed
Date: Tue, 15 Oct 2013 13:03:50 +0900
cbb3ed
Subject: [PATCH 1/3] Fix for -Wformat
cbb3ed
cbb3ed
---
cbb3ed
 imsettings-daemon/imsettings-server.c | 9 +++++----
cbb3ed
 1 file changed, 5 insertions(+), 4 deletions(-)
cbb3ed
cbb3ed
diff --git a/imsettings-daemon/imsettings-server.c b/imsettings-daemon/imsettings-server.c
cbb3ed
index 79aa308..c229dd0 100644
cbb3ed
--- a/imsettings-daemon/imsettings-server.c
cbb3ed
+++ b/imsettings-daemon/imsettings-server.c
cbb3ed
@@ -119,7 +119,7 @@ _notify_cb(IMSettingsProc *proc,
cbb3ed
 	notify_notification_show(priv->notify, &err;;
cbb3ed
 
cbb3ed
 	if (err) {
cbb3ed
-		g_warning(err->message);
cbb3ed
+		g_warning("%s", err->message);
cbb3ed
 		g_error_free(err);
cbb3ed
 	}
cbb3ed
 }
cbb3ed
@@ -712,7 +712,7 @@ imsettings_server_cb_switch_im(IMSettingsServer  *server,
cbb3ed
 		g_clear_error(error);
cbb3ed
 		g_set_error(error, IMSETTINGS_GERROR, IMSETTINGS_GERROR_IM_NOT_FOUND,
cbb3ed
 			    _("No such input method on your system: %s"), module);
cbb3ed
-		g_warning((*error)->message);
cbb3ed
+		g_warning("%s", (*error)->message);
cbb3ed
 
cbb3ed
 		return FALSE;
cbb3ed
 	}
cbb3ed
@@ -721,7 +721,7 @@ imsettings_server_cb_switch_im(IMSettingsServer  *server,
cbb3ed
 	if (!*info) {
cbb3ed
 		g_set_error(error, IMSETTINGS_GERROR, IMSETTINGS_GERROR_OOM,
cbb3ed
 			    _("Out of memory"));
cbb3ed
-		g_warning((*error)->message);
cbb3ed
+		g_warning("%s", (*error)->message);
cbb3ed
 
cbb3ed
 		return FALSE;
cbb3ed
 	}
cbb3ed
@@ -746,7 +746,7 @@ imsettings_server_cb_switch_im(IMSettingsServer  *server,
cbb3ed
 	} else if (match) {
cbb3ed
 		g_set_error(error, IMSETTINGS_GERROR, IMSETTINGS_GERROR_NOT_TARGETED_DESKTOP,
cbb3ed
 			    _("Current desktop isn't targeted by IMSettings."));
cbb3ed
-		g_warning((*error)->message);
cbb3ed
+		g_warning("%s", (*error)->message);
cbb3ed
 
cbb3ed
 		return FALSE;
cbb3ed
 	}
cbb3ed
@@ -1222,6 +1222,7 @@ imsettings_server_bus_method_call(GDBusConnection       *connection,
cbb3ed
 		g_dbus_method_invocation_return_error(invocation,
cbb3ed
 						      IMSETTINGS_GERROR,
cbb3ed
 						      err->code,
cbb3ed
+						      "%s",
cbb3ed
 						      err->message);
cbb3ed
 		g_error_free(err);
cbb3ed
 	} else {
cbb3ed
-- 
cbb3ed
1.8.3.1
cbb3ed
cbb3ed
From 5833b104e6a4be022c41eb111bb1e3b61b0d2322 Mon Sep 17 00:00:00 2001
cbb3ed
From: Akira TAGOH <akira@tagoh.org>
cbb3ed
Date: Wed, 16 Oct 2013 11:44:25 +0900
cbb3ed
Subject: [PATCH 2/3] Fix memory leaks
cbb3ed
cbb3ed
---
cbb3ed
 imsettings-daemon/imsettings-server.c |   5 ++
cbb3ed
 imsettings/imsettings-info.c          | 127 +++++++++++++++++-----------------
cbb3ed
 utils/imsettings-list.c               |   1 +
cbb3ed
 3 files changed, 70 insertions(+), 63 deletions(-)
cbb3ed
cbb3ed
diff --git a/imsettings-daemon/imsettings-server.c b/imsettings-daemon/imsettings-server.c
cbb3ed
index c229dd0..1c52782 100644
cbb3ed
--- a/imsettings-daemon/imsettings-server.c
cbb3ed
+++ b/imsettings-daemon/imsettings-server.c
cbb3ed
@@ -596,6 +596,8 @@ imsettings_server_cb_get_info_variants(IMSettingsServer  *server,
cbb3ed
 			n = imsettings_info_get_filename(info);
cbb3ed
 			if (g_strcmp0(module, IMSETTINGS_USER_SPECIFIC_SHORT_DESC) == 0) {
cbb3ed
 				g_variant_builder_add(vb, "{sv}", module, v);
cbb3ed
+			} else {
cbb3ed
+				g_variant_unref(v);
cbb3ed
 			}
cbb3ed
 			g_object_unref(info);
cbb3ed
 		}
cbb3ed
@@ -613,6 +615,8 @@ imsettings_server_cb_get_info_variants(IMSettingsServer  *server,
cbb3ed
 			n = imsettings_info_get_filename(info);
cbb3ed
 			if (g_strcmp0(module, IMSETTINGS_USER_SPECIFIC_SHORT_DESC) == 0) {
cbb3ed
 				g_variant_builder_add(vb, "{sv}", module, v);
cbb3ed
+			} else {
cbb3ed
+				g_variant_unref(v);
cbb3ed
 			}
cbb3ed
 			g_object_unref(info);
cbb3ed
 		}
cbb3ed
@@ -667,6 +671,7 @@ imsettings_server_cb_get_info_variant(IMSettingsServer  *server,
cbb3ed
 				break;
cbb3ed
 			}
cbb3ed
 			g_free(conf);
cbb3ed
+			g_variant_unref(vv);
cbb3ed
 		}
cbb3ed
 		g_variant_unref(v);
cbb3ed
 	}
cbb3ed
diff --git a/imsettings/imsettings-info.c b/imsettings/imsettings-info.c
cbb3ed
index 33f7d74..cbbefcb 100644
cbb3ed
--- a/imsettings/imsettings-info.c
cbb3ed
+++ b/imsettings/imsettings-info.c
cbb3ed
@@ -317,77 +317,77 @@ imsettings_info_variant_new(const gchar *filename,
cbb3ed
 
cbb3ed
 	G_LOCK (info);
cbb3ed
 
cbb3ed
-	if ((fp = popen(cmd->str, "r")) != NULL) {
cbb3ed
-		vb = g_variant_builder_new(G_VARIANT_TYPE ("a{sv}"));
cbb3ed
-
cbb3ed
-		while (!feof(fp)) {
cbb3ed
-			if ((p = fgets(buffer, 255, fp)) != NULL) {
cbb3ed
-				gchar *key = NULL, *val = NULL;
cbb3ed
-				GVariant *v = NULL;
cbb3ed
-				GQuark q;
cbb3ed
-
cbb3ed
-				if (!_parse_param(p, &key, &val)) {
cbb3ed
-					g_warning("Failed to parse a line in %s: %s",
cbb3ed
-						  filename, p);
cbb3ed
-					goto bail;
cbb3ed
-				}
cbb3ed
-				q = g_quark_try_string(key);
cbb3ed
-				if (q == 0)
cbb3ed
-					goto unknown_param;
cbb3ed
-				for (i = 0; i < LAST_IMSETTINGS_INFO; i++) {
cbb3ed
-					if (__xinput_tokens[i] == q)
cbb3ed
-						break;
cbb3ed
-				}
cbb3ed
-				switch (i) {
cbb3ed
-				    case IMSETTINGS_INFO_GTK_IM_MODULE:
cbb3ed
-				    case IMSETTINGS_INFO_QT_IM_MODULE:
cbb3ed
-				    case IMSETTINGS_INFO_XIM:
cbb3ed
-				    case IMSETTINGS_INFO_XIM_PROGRAM:
cbb3ed
-				    case IMSETTINGS_INFO_XIM_ARGS:
cbb3ed
-				    case IMSETTINGS_INFO_PREFERENCE_PROGRAM:
cbb3ed
-				    case IMSETTINGS_INFO_PREFERENCE_ARGS:
cbb3ed
-				    case IMSETTINGS_INFO_AUXILIARY_PROGRAM:
cbb3ed
-				    case IMSETTINGS_INFO_AUXILIARY_ARGS:
cbb3ed
-				    case IMSETTINGS_INFO_SHORT_DESC:
cbb3ed
-				    case IMSETTINGS_INFO_LONG_DESC:
cbb3ed
-				    case IMSETTINGS_INFO_ICON:
cbb3ed
-				    case IMSETTINGS_INFO_LANG:
cbb3ed
-				    case IMSETTINGS_INFO_FILENAME:
cbb3ed
-				    case IMSETTINGS_INFO_NOT_RUN:
cbb3ed
-					    v = g_variant_new_string(val);
cbb3ed
-					    break;
cbb3ed
-				    case IMSETTINGS_INFO_IMSETTINGS_IGNORE_ME:
cbb3ed
-				    case IMSETTINGS_INFO_IMSETTINGS_IS_SCRIPT:
cbb3ed
-				    case IMSETTINGS_INFO_IS_XIM:
cbb3ed
-					    v = g_variant_new_boolean((g_ascii_strcasecmp(val, "true") == 0 ||
cbb3ed
-								       g_ascii_strcasecmp(val, "yes") == 0 ||
cbb3ed
-								       g_ascii_strcasecmp(val, "1") == 0));
cbb3ed
-					    break;
cbb3ed
-				    default:
cbb3ed
-				    unknown_param:
cbb3ed
-					    g_warning("Unknown parameter: %s = %s",
cbb3ed
-						      key, val);
cbb3ed
-					    v = NULL;
cbb3ed
-					    break;
cbb3ed
-				}
cbb3ed
-				if (v)
cbb3ed
-					g_variant_builder_add(vb, "{sv}",
cbb3ed
-							      key, v);
cbb3ed
-			  bail:
cbb3ed
-				g_free(key);
cbb3ed
-				g_free(val);
cbb3ed
+	if ((fp = popen(cmd->str, "r")) == NULL)
cbb3ed
+		goto error;
cbb3ed
+
cbb3ed
+	vb = g_variant_builder_new(G_VARIANT_TYPE ("a{sv}"));
cbb3ed
+
cbb3ed
+	while (!feof(fp)) {
cbb3ed
+		if ((p = fgets(buffer, 255, fp)) != NULL) {
cbb3ed
+			gchar *key = NULL, *val = NULL;
cbb3ed
+			GVariant *v = NULL;
cbb3ed
+			GQuark q;
cbb3ed
+
cbb3ed
+			if (!_parse_param(p, &key, &val)) {
cbb3ed
+				g_warning("Failed to parse a line in %s: %s",
cbb3ed
+					  filename, p);
cbb3ed
+				goto bail;
cbb3ed
+			}
cbb3ed
+			q = g_quark_try_string(key);
cbb3ed
+			if (q == 0)
cbb3ed
+				goto unknown_param;
cbb3ed
+			for (i = 0; i < LAST_IMSETTINGS_INFO; i++) {
cbb3ed
+				if (__xinput_tokens[i] == q)
cbb3ed
+					break;
cbb3ed
 			}
cbb3ed
+			switch (i) {
cbb3ed
+			    case IMSETTINGS_INFO_GTK_IM_MODULE:
cbb3ed
+			    case IMSETTINGS_INFO_QT_IM_MODULE:
cbb3ed
+			    case IMSETTINGS_INFO_XIM:
cbb3ed
+			    case IMSETTINGS_INFO_XIM_PROGRAM:
cbb3ed
+			    case IMSETTINGS_INFO_XIM_ARGS:
cbb3ed
+			    case IMSETTINGS_INFO_PREFERENCE_PROGRAM:
cbb3ed
+			    case IMSETTINGS_INFO_PREFERENCE_ARGS:
cbb3ed
+			    case IMSETTINGS_INFO_AUXILIARY_PROGRAM:
cbb3ed
+			    case IMSETTINGS_INFO_AUXILIARY_ARGS:
cbb3ed
+			    case IMSETTINGS_INFO_SHORT_DESC:
cbb3ed
+			    case IMSETTINGS_INFO_LONG_DESC:
cbb3ed
+			    case IMSETTINGS_INFO_ICON:
cbb3ed
+			    case IMSETTINGS_INFO_LANG:
cbb3ed
+			    case IMSETTINGS_INFO_FILENAME:
cbb3ed
+			    case IMSETTINGS_INFO_NOT_RUN:
cbb3ed
+				    v = g_variant_new_string(val);
cbb3ed
+				    break;
cbb3ed
+			    case IMSETTINGS_INFO_IMSETTINGS_IGNORE_ME:
cbb3ed
+			    case IMSETTINGS_INFO_IMSETTINGS_IS_SCRIPT:
cbb3ed
+			    case IMSETTINGS_INFO_IS_XIM:
cbb3ed
+				    v = g_variant_new_boolean((g_ascii_strcasecmp(val, "true") == 0 ||
cbb3ed
+							       g_ascii_strcasecmp(val, "yes") == 0 ||
cbb3ed
+							       g_ascii_strcasecmp(val, "1") == 0));
cbb3ed
+				    break;
cbb3ed
+			    default:
cbb3ed
+			    unknown_param:
cbb3ed
+				    g_warning("Unknown parameter: %s = %s",
cbb3ed
+					      key, val);
cbb3ed
+				    v = NULL;
cbb3ed
+				    break;
cbb3ed
+			}
cbb3ed
+			if (v)
cbb3ed
+				g_variant_builder_add(vb, "{sv}",
cbb3ed
+						      key, v);
cbb3ed
+		  bail:
cbb3ed
+			g_free(key);
cbb3ed
+			g_free(val);
cbb3ed
 		}
cbb3ed
-
cbb3ed
-		pclose(fp);
cbb3ed
 	}
cbb3ed
+
cbb3ed
+	pclose(fp);
cbb3ed
 	value = g_variant_builder_end(vb);
cbb3ed
+	g_variant_builder_unref(vb);
cbb3ed
 
cbb3ed
 	G_UNLOCK (info);
cbb3ed
 
cbb3ed
   error:
cbb3ed
-	if (vb)
cbb3ed
-		g_variant_builder_unref(vb);
cbb3ed
 	g_string_free(cmd, TRUE);
cbb3ed
 
cbb3ed
 	return value;
cbb3ed
@@ -461,6 +461,7 @@ imsettings_info_new(GVariant *parameters)
cbb3ed
 				    g_warning("Unknown parameter: %s", key);
cbb3ed
 				    break;
cbb3ed
 			}
cbb3ed
+			g_variant_unref(val);
cbb3ed
 		}
cbb3ed
 		g_variant_iter_free(iter);
cbb3ed
 	}
cbb3ed
diff --git a/utils/imsettings-list.c b/utils/imsettings-list.c
cbb3ed
index 0504224..07bc085 100644
cbb3ed
--- a/utils/imsettings-list.c
cbb3ed
+++ b/utils/imsettings-list.c
cbb3ed
@@ -107,6 +107,7 @@ main(int    argc,
cbb3ed
 		    strcmp(&key[len - slen], XINPUT_SUFFIX) == 0)
cbb3ed
 			continue;
cbb3ed
 		info = imsettings_info_new(vv);
cbb3ed
+		g_variant_unref(vv);
cbb3ed
 		name = imsettings_info_get_short_desc(info);
cbb3ed
 		imname = imsettings_info_get_im_name(info);
cbb3ed
 		subimname = imsettings_info_get_sub_im_name(info);
cbb3ed
-- 
cbb3ed
1.8.3.1
cbb3ed
cbb3ed
From 6d2940d3b7744868b72e2b14cc8e1b70c77ce594 Mon Sep 17 00:00:00 2001
cbb3ed
From: Akira TAGOH <akira@tagoh.org>
cbb3ed
Date: Wed, 16 Oct 2013 13:24:59 +0900
cbb3ed
Subject: [PATCH 3/3] clean up
cbb3ed
cbb3ed
---
cbb3ed
 imsettings-daemon/imsettings-server.c | 106 ++++++++++++++++------------------
cbb3ed
 1 file changed, 49 insertions(+), 57 deletions(-)
cbb3ed
cbb3ed
diff --git a/imsettings-daemon/imsettings-server.c b/imsettings-daemon/imsettings-server.c
cbb3ed
index 1c52782..25f45a6 100644
cbb3ed
--- a/imsettings-daemon/imsettings-server.c
cbb3ed
+++ b/imsettings-daemon/imsettings-server.c
cbb3ed
@@ -541,6 +541,8 @@ imsettings_server_cb_get_info_variants(IMSettingsServer  *server,
cbb3ed
 			v = imsettings_info_variant_new(p, lang);
cbb3ed
 			g_free(p);
cbb3ed
 			g_free(conf);
cbb3ed
+			if (!v)
cbb3ed
+				goto next;
cbb3ed
 
cbb3ed
 			info = imsettings_info_new(v);
cbb3ed
 			if (imsettings_info_is_visible(info)) {
cbb3ed
@@ -591,15 +593,17 @@ imsettings_server_cb_get_info_variants(IMSettingsServer  *server,
cbb3ed
 		if (g_file_test(p, G_FILE_TEST_EXISTS) &&
cbb3ed
 		    !g_file_test(p, G_FILE_TEST_IS_SYMLINK)) {
cbb3ed
 			v = imsettings_info_variant_new(p, lang);
cbb3ed
-			info = imsettings_info_new(v);
cbb3ed
-			module = imsettings_info_get_short_desc(info);
cbb3ed
-			n = imsettings_info_get_filename(info);
cbb3ed
-			if (g_strcmp0(module, IMSETTINGS_USER_SPECIFIC_SHORT_DESC) == 0) {
cbb3ed
-				g_variant_builder_add(vb, "{sv}", module, v);
cbb3ed
-			} else {
cbb3ed
-				g_variant_unref(v);
cbb3ed
+			if (v) {
cbb3ed
+				info = imsettings_info_new(v);
cbb3ed
+				module = imsettings_info_get_short_desc(info);
cbb3ed
+				n = imsettings_info_get_filename(info);
cbb3ed
+				if (g_strcmp0(module, IMSETTINGS_USER_SPECIFIC_SHORT_DESC) == 0) {
cbb3ed
+					g_variant_builder_add(vb, "{sv}", module, v);
cbb3ed
+				} else {
cbb3ed
+					g_variant_unref(v);
cbb3ed
+				}
cbb3ed
+				g_object_unref(info);
cbb3ed
 			}
cbb3ed
-			g_object_unref(info);
cbb3ed
 		}
cbb3ed
 		g_free(p);
cbb3ed
 		/* an exception to deal with the case switching back to the user specific.
cbb3ed
@@ -610,15 +614,17 @@ imsettings_server_cb_get_info_variants(IMSettingsServer  *server,
cbb3ed
 		if (g_file_test(p, G_FILE_TEST_EXISTS) &&
cbb3ed
 		    !g_file_test(p, G_FILE_TEST_IS_SYMLINK)) {
cbb3ed
 			v = imsettings_info_variant_new(p, lang);
cbb3ed
-			info = imsettings_info_new(v);
cbb3ed
-			module = imsettings_info_get_short_desc(info);
cbb3ed
-			n = imsettings_info_get_filename(info);
cbb3ed
-			if (g_strcmp0(module, IMSETTINGS_USER_SPECIFIC_SHORT_DESC) == 0) {
cbb3ed
-				g_variant_builder_add(vb, "{sv}", module, v);
cbb3ed
-			} else {
cbb3ed
-				g_variant_unref(v);
cbb3ed
+			if (v) {
cbb3ed
+				info = imsettings_info_new(v);
cbb3ed
+				module = imsettings_info_get_short_desc(info);
cbb3ed
+				n = imsettings_info_get_filename(info);
cbb3ed
+				if (g_strcmp0(module, IMSETTINGS_USER_SPECIFIC_SHORT_DESC) == 0) {
cbb3ed
+					g_variant_builder_add(vb, "{sv}", module, v);
cbb3ed
+				} else {
cbb3ed
+					g_variant_unref(v);
cbb3ed
+				}
cbb3ed
+				g_object_unref(info);
cbb3ed
 			}
cbb3ed
-			g_object_unref(info);
cbb3ed
 		}
cbb3ed
 		g_free(p);
cbb3ed
 
cbb3ed
@@ -1034,43 +1040,36 @@ imsettings_server_bus_method_call(GDBusConnection       *connection,
cbb3ed
 
cbb3ed
 	if (g_strcmp0(method_name, "StopService") == 0) {
cbb3ed
 		g_dbus_method_invocation_return_value(invocation,
cbb3ed
-						      g_variant_new("(b)", TRUE));
cbb3ed
+						      g_variant_new_boolean(TRUE));
cbb3ed
 		g_signal_emit(server, signals[SIG_DISCONNECTED], 0, NULL);
cbb3ed
 	} else if (g_strcmp0(method_name, "GetVersion") == 0) {
cbb3ed
-		value = g_variant_new("(u)",
cbb3ed
-				      IMSETTINGS_SETTINGS_API_VERSION);
cbb3ed
+		value = g_variant_new_uint32(IMSETTINGS_SETTINGS_API_VERSION);
cbb3ed
 	} else if (g_strcmp0(method_name, "GetInfoVariants") == 0) {
cbb3ed
 		const gchar *lang;
cbb3ed
-		GVariant *v;
cbb3ed
 
cbb3ed
 		g_variant_get(parameters, "(&s)",
cbb3ed
 			      &lang);
cbb3ed
 
cbb3ed
-		v = imsettings_server_cb_get_info_variants(server, lang, &err;;
cbb3ed
-		if (!v) {
cbb3ed
+		value = imsettings_server_cb_get_info_variants(server, lang, &err;;
cbb3ed
+		if (!value) {
cbb3ed
 			g_set_error(&err, IMSETTINGS_GERROR,
cbb3ed
 				    IMSETTINGS_GERROR_IM_NOT_FOUND,
cbb3ed
 				    "No IMs available");
cbb3ed
-		} else {
cbb3ed
-			value = g_variant_new_tuple(&v, 1);
cbb3ed
 		}
cbb3ed
 	} else if (g_strcmp0(method_name, "GetInfoVariant") == 0) {
cbb3ed
 		const gchar *lang, *module;
cbb3ed
-		GVariant *v;
cbb3ed
 
cbb3ed
 		g_variant_get(parameters, "(&s&s)",
cbb3ed
 			      &lang, &module);
cbb3ed
 
cbb3ed
-		v = imsettings_server_cb_get_info_variant(server,
cbb3ed
-							  lang,
cbb3ed
-							  module,
cbb3ed
-							  &err;;
cbb3ed
-		if (!v) {
cbb3ed
+		value = imsettings_server_cb_get_info_variant(server,
cbb3ed
+							      lang,
cbb3ed
+							      module,
cbb3ed
+							      &err;;
cbb3ed
+		if (!value) {
cbb3ed
 			g_set_error(&err, IMSETTINGS_GERROR,
cbb3ed
 				    IMSETTINGS_GERROR_IM_NOT_FOUND,
cbb3ed
 				    "No such input method: %s", module);
cbb3ed
-		} else {
cbb3ed
-			value = g_variant_new_tuple(&v, 1);
cbb3ed
 		}
cbb3ed
 	} else if (g_strcmp0(method_name, "GetSystemIM") == 0) {
cbb3ed
 		const gchar *lang;
cbb3ed
@@ -1079,7 +1078,7 @@ imsettings_server_bus_method_call(GDBusConnection       *connection,
cbb3ed
 		g_variant_get(parameters, "(&s)", &lang);
cbb3ed
 		im = imsettings_server_cb_get_system_im(server, lang, &err;;
cbb3ed
 		if (im) {
cbb3ed
-			value = g_variant_new("(s)", im);
cbb3ed
+			value = g_variant_new_string(im);
cbb3ed
 			g_free(im);
cbb3ed
 		}
cbb3ed
 	} else if (g_strcmp0(method_name, "GetUserIM") == 0) {
cbb3ed
@@ -1089,7 +1088,7 @@ imsettings_server_bus_method_call(GDBusConnection       *connection,
cbb3ed
 		g_variant_get(parameters, "(&s)", &lang);
cbb3ed
 		im = imsettings_server_cb_get_user_im(server, lang, &err;;
cbb3ed
 		if (im) {
cbb3ed
-			value = g_variant_new("(s)", im);
cbb3ed
+			value = g_variant_new_string(im);
cbb3ed
 			g_free(im);
cbb3ed
 		}
cbb3ed
 	} else if (g_strcmp0(method_name, "IsSystemDefault") == 0) {
cbb3ed
@@ -1099,8 +1098,7 @@ imsettings_server_bus_method_call(GDBusConnection       *connection,
cbb3ed
 		g_variant_get(parameters, "(&s&s)", &lang, &module);
cbb3ed
 		im = imsettings_server_cb_get_system_im(server, lang, &err;;
cbb3ed
 		if (im) {
cbb3ed
-			value = g_variant_new("(b)",
cbb3ed
-					      g_ascii_strcasecmp(im, module) == 0);
cbb3ed
+			value = g_variant_new_boolean(g_ascii_strcasecmp(im, module) == 0);
cbb3ed
 			g_free(im);
cbb3ed
 		}
cbb3ed
 	} else if (g_strcmp0(method_name, "IsUserDefault") == 0) {
cbb3ed
@@ -1110,8 +1108,7 @@ imsettings_server_bus_method_call(GDBusConnection       *connection,
cbb3ed
 		g_variant_get(parameters, "(&s&s)", &lang, &module);
cbb3ed
 		im = imsettings_server_cb_get_user_im(server, lang, &err;;
cbb3ed
 		if (im) {
cbb3ed
-			value = g_variant_new("(b)",
cbb3ed
-					      g_ascii_strcasecmp(im, module) == 0);
cbb3ed
+			value = g_variant_new_boolean(g_ascii_strcasecmp(im, module) == 0);
cbb3ed
 			g_free(im);
cbb3ed
 		}
cbb3ed
 	} else if (g_strcmp0(method_name, "IsXIM") == 0) {
cbb3ed
@@ -1138,8 +1135,7 @@ imsettings_server_bus_method_call(GDBusConnection       *connection,
cbb3ed
 				    IMSETTINGS_GERROR_OOM,
cbb3ed
 				    _("Out of memory"));
cbb3ed
 		} else {
cbb3ed
-			value = g_variant_new("(b)",
cbb3ed
-					      imsettings_info_is_xim(info));
cbb3ed
+			value = g_variant_new_boolean(imsettings_info_is_xim(info));
cbb3ed
 			g_object_unref(info);
cbb3ed
 		}
cbb3ed
 		g_variant_unref(v);
cbb3ed
@@ -1166,9 +1162,8 @@ imsettings_server_bus_method_call(GDBusConnection       *connection,
cbb3ed
 		if (info)
cbb3ed
 			g_object_unref(info);
cbb3ed
 
cbb3ed
-		value = g_variant_new("(b)", ret);
cbb3ed
+		value = g_variant_new_boolean(ret);
cbb3ed
 	} else if (g_strcmp0(method_name, "GetActiveVariant") == 0) {
cbb3ed
-		GVariant *v = NULL;
cbb3ed
 		gchar *f;
cbb3ed
 
cbb3ed
 		if (!priv->current_im ||
cbb3ed
@@ -1176,19 +1171,17 @@ imsettings_server_bus_method_call(GDBusConnection       *connection,
cbb3ed
 			f = g_build_filename(imsettings_server_get_xinputdir(server),
cbb3ed
 					     IMSETTINGS_NONE_CONF XINPUT_SUFFIX, NULL);
cbb3ed
 			if (g_file_test(f, G_FILE_TEST_EXISTS))
cbb3ed
-				v = imsettings_info_variant_new(f, NULL);
cbb3ed
+				value = imsettings_info_variant_new(f, NULL);
cbb3ed
 			g_free(f);
cbb3ed
 		} else {
cbb3ed
 			IMSettingsInfo *info = imsettings_proc_info(priv->current_im);
cbb3ed
 
cbb3ed
-			v = imsettings_info_variant_new(imsettings_info_get_filename(info),
cbb3ed
-							imsettings_info_get_language(info));
cbb3ed
+			value = imsettings_info_variant_new(imsettings_info_get_filename(info),
cbb3ed
+							    imsettings_info_get_language(info));
cbb3ed
 		}
cbb3ed
-		if (!v) {
cbb3ed
+		if (!value) {
cbb3ed
 			g_set_error(&err, IMSETTINGS_GERROR, IMSETTINGS_GERROR_CONFIGURATION_ERROR,
cbb3ed
 				    "none.conf isn't installed.");
cbb3ed
-		} else {
cbb3ed
-			value = g_variant_new_tuple(&v, 1);
cbb3ed
 		}
cbb3ed
 	} else if (g_strcmp0(method_name, "LoadModule") == 0) {
cbb3ed
 		const gchar *modname;
cbb3ed
@@ -1197,7 +1190,7 @@ imsettings_server_bus_method_call(GDBusConnection       *connection,
cbb3ed
 		g_variant_get(parameters, "(&s)", &modname);
cbb3ed
 
cbb3ed
 		ret = imsettings_server_cb_load_module(server, modname);
cbb3ed
-		value = g_variant_new("(b)", ret);
cbb3ed
+		value = g_variant_new_boolean(ret);
cbb3ed
 	} else if (g_strcmp0(method_name, "UnloadModule") == 0) {
cbb3ed
 		const gchar *modname;
cbb3ed
 		gboolean ret;
cbb3ed
@@ -1205,17 +1198,13 @@ imsettings_server_bus_method_call(GDBusConnection       *connection,
cbb3ed
 		g_variant_get(parameters, "(&s)", &modname);
cbb3ed
 
cbb3ed
 		ret = imsettings_server_cb_unload_module(server, modname);
cbb3ed
-		value = g_variant_new("(b)", ret);
cbb3ed
+		value = g_variant_new_boolean(ret);
cbb3ed
 	} else if (g_strcmp0(method_name, "DumpModuleSettings") == 0) {
cbb3ed
-		GVariant *v;
cbb3ed
-
cbb3ed
-		v = imsettings_server_cb_get_module_settings(server, &err;;
cbb3ed
-		if (!v) {
cbb3ed
+		value = imsettings_server_cb_get_module_settings(server, &err;;
cbb3ed
+		if (!value) {
cbb3ed
 			g_set_error(&err, IMSETTINGS_GERROR,
cbb3ed
 				    IMSETTINGS_GERROR_CONFIGURATION_ERROR,
cbb3ed
 				    "No modules loaded");
cbb3ed
-		} else {
cbb3ed
-			value = g_variant_new_tuple(&v, 1);
cbb3ed
 		}
cbb3ed
 	}
cbb3ed
   finalize:
cbb3ed
@@ -1232,7 +1221,10 @@ imsettings_server_bus_method_call(GDBusConnection       *connection,
cbb3ed
 		g_error_free(err);
cbb3ed
 	} else {
cbb3ed
 		if (value) {
cbb3ed
-			g_dbus_method_invocation_return_value(invocation, value);
cbb3ed
+			GVariant *v;
cbb3ed
+
cbb3ed
+			v = g_variant_new_tuple(&value, 1);
cbb3ed
+			g_dbus_method_invocation_return_value(invocation, v);
cbb3ed
 		}
cbb3ed
 	}
cbb3ed
 }
cbb3ed
-- 
cbb3ed
1.8.3.1
cbb3ed