tools: Fix possible uninitialized variable in obexctl

On set_default_session(), if g_dbus_proxy_get_property() returns FALSE,
desc will be uninitialized. Given that this function already checks for
NULL proxy internally, it is enough to check whether it fails (and if
so, set a default prompt without destination).

Fixes this clang error:

tools/obexctl.c:439:6: error: variable 'desc' is used uninitialized
whenever 'if' condition is false [-Werror,-Wsometimes-uninitialized]
This commit is contained in:
Anderson Lizardo 2014-01-03 21:55:23 -04:00 committed by Johan Hedberg
parent 57207bf438
commit ff0afe7b7f

View File

@ -431,14 +431,12 @@ static void set_default_session(GDBusProxy *proxy)
default_session = proxy;
if (proxy == NULL) {
if (!g_dbus_proxy_get_property(proxy, "Destination", &iter)) {
desc = g_strdup(PROMPT_ON);
goto done;
}
if (g_dbus_proxy_get_property(proxy, "Destination", &iter))
dbus_message_iter_get_basic(&iter, &desc);
dbus_message_iter_get_basic(&iter, &desc);
desc = g_strdup_printf(COLOR_BLUE "[%s]" COLOR_OFF "# ", desc);
done: