summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard Hughes <richard@hughsie.com>2009-09-11 14:37:51 +0100
committerRichard Hughes <richard@hughsie.com>2009-09-11 14:39:48 +0100
commit97a782484471b00529471588da6fe54ba8e4c207 (patch)
treeebe7a1bbd32ce1c90e3c067c5b7fd3b5b94d105a
parent2f211aa7a78ab77f3c30bc06eb4740c749b5d333 (diff)
Fix up a few problems spotted by clang
-rw-r--r--src/dkp-daemon.c31
-rw-r--r--src/linux/dkp-device-csr.c3
-rw-r--r--src/linux/dkp-device-hid.c3
-rw-r--r--src/linux/dkp-device-supply.c3
-rw-r--r--src/linux/dkp-device-wup.c9
-rw-r--r--tools/dkp-tool.c26
6 files changed, 41 insertions, 34 deletions
diff --git a/src/dkp-daemon.c b/src/dkp-daemon.c
index b4452e2..08c1128 100644
--- a/src/dkp-daemon.c
+++ b/src/dkp-daemon.c
@@ -483,9 +483,8 @@ out:
static gboolean
dkp_daemon_register_power_daemon (DkpDaemon *daemon)
{
- DBusConnection *connection;
- DBusError dbus_error;
GError *error = NULL;
+ gboolean ret = FALSE;
daemon->priv->connection = dbus_g_bus_get (DBUS_BUS_SYSTEM, &error);
if (daemon->priv->connection == NULL) {
@@ -493,28 +492,24 @@ dkp_daemon_register_power_daemon (DkpDaemon *daemon)
g_critical ("error getting system bus: %s", error->message);
g_error_free (error);
}
- goto error;
+ goto out;
}
- connection = dbus_g_connection_get_connection (daemon->priv->connection);
+ /* connect to DBUS */
+ daemon->priv->proxy = dbus_g_proxy_new_for_name (daemon->priv->connection,
+ DBUS_SERVICE_DBUS,
+ DBUS_PATH_DBUS,
+ DBUS_INTERFACE_DBUS);
+
+ /* register GObject */
dbus_g_connection_register_g_object (daemon->priv->connection,
"/org/freedesktop/DeviceKit/Power",
G_OBJECT (daemon));
- daemon->priv->proxy = dbus_g_proxy_new_for_name (daemon->priv->connection,
- DBUS_SERVICE_DBUS,
- DBUS_PATH_DBUS,
- DBUS_INTERFACE_DBUS);
- dbus_error_init (&dbus_error);
- if (dbus_error_is_set (&dbus_error)) {
- egg_warning ("Cannot add match rule: %s: %s", dbus_error.name, dbus_error.message);
- dbus_error_free (&dbus_error);
- goto error;
- }
-
- return TRUE;
-error:
- return FALSE;
+ /* success */
+ ret = TRUE;
+out:
+ return ret;
}
/**
diff --git a/src/linux/dkp-device-csr.c b/src/linux/dkp-device-csr.c
index 75ac383..72c7e78 100644
--- a/src/linux/dkp-device-csr.c
+++ b/src/linux/dkp-device-csr.c
@@ -73,11 +73,10 @@ static gboolean dkp_device_csr_refresh (DkpDevice *device);
static gboolean
dkp_device_csr_poll_cb (DkpDeviceCsr *csr)
{
- gboolean ret;
DkpDevice *device = DKP_DEVICE (csr);
egg_debug ("Polling: %s", dkp_device_get_object_path (device));
- ret = dkp_device_csr_refresh (device);
+ dkp_device_csr_refresh (device);
/* always continue polling */
return TRUE;
diff --git a/src/linux/dkp-device-hid.c b/src/linux/dkp-device-hid.c
index 77b0a44..c1e1425 100644
--- a/src/linux/dkp-device-hid.c
+++ b/src/linux/dkp-device-hid.c
@@ -132,11 +132,10 @@ out:
static gboolean
dkp_device_hid_poll (DkpDeviceHid *hid)
{
- gboolean ret;
DkpDevice *device = DKP_DEVICE (hid);
egg_debug ("Polling: %s", dkp_device_get_object_path (device));
- ret = dkp_device_hid_refresh (device);
+ dkp_device_hid_refresh (device);
/* always continue polling */
return TRUE;
diff --git a/src/linux/dkp-device-supply.c b/src/linux/dkp-device-supply.c
index fd759ec..94bde51 100644
--- a/src/linux/dkp-device-supply.c
+++ b/src/linux/dkp-device-supply.c
@@ -608,12 +608,11 @@ out:
static gboolean
dkp_device_supply_poll_battery (DkpDeviceSupply *supply)
{
- gboolean ret;
DkpDevice *device = DKP_DEVICE (supply);
egg_debug ("No updates on supply %s for %i seconds; forcing update", dkp_device_get_object_path (device), DKP_DEVICE_SUPPLY_REFRESH_TIMEOUT);
supply->priv->poll_timer_id = 0;
- ret = dkp_device_supply_refresh (device);
+ dkp_device_supply_refresh (device);
/* never repeat */
return FALSE;
diff --git a/src/linux/dkp-device-wup.c b/src/linux/dkp-device-wup.c
index 99f9393..df34fa0 100644
--- a/src/linux/dkp-device-wup.c
+++ b/src/linux/dkp-device-wup.c
@@ -85,11 +85,10 @@ static gboolean dkp_device_wup_refresh (DkpDevice *device);
static gboolean
dkp_device_wup_poll_cb (DkpDeviceWup *wup)
{
- gboolean ret;
DkpDevice *device = DKP_DEVICE (wup);
egg_debug ("Polling: %s", dkp_device_get_object_path (device));
- ret = dkp_device_wup_refresh (device);
+ dkp_device_wup_refresh (device);
/* always continue polling */
return TRUE;
@@ -335,10 +334,14 @@ dkp_device_wup_coldplug (DkpDevice *device)
/* attempt to clear */
ret = dkp_device_wup_write_command (wup, "#R,W,0;");
+ if (!ret)
+ egg_debug ("failed to clear, nonfatal");
/* setup logging interval */
data = g_strdup_printf ("#L,W,3,E,1,%i;", DKP_DEVICE_WUP_REFRESH_TIMEOUT);
ret = dkp_device_wup_write_command (wup, data);
+ if (!ret)
+ egg_debug ("failed to setup logging interval, nonfatal");
g_free (data);
/* dummy read */
@@ -373,7 +376,7 @@ dkp_device_wup_coldplug (DkpDevice *device)
/* coldplug */
egg_debug ("coldplug");
- ret = dkp_device_wup_refresh (device);
+ dkp_device_wup_refresh (device);
/* hardcode true, as we'll retry later if busy */
ret = TRUE;
diff --git a/tools/dkp-tool.c b/tools/dkp-tool.c
index e9d58b2..031e9d5 100644
--- a/tools/dkp-tool.c
+++ b/tools/dkp-tool.c
@@ -193,7 +193,7 @@ out:
int
main (int argc, char **argv)
{
- gint retval = 1;
+ gint retval = EXIT_FAILURE;
guint i;
GOptionContext *context;
gboolean verbose = FALSE;
@@ -245,9 +245,14 @@ main (int argc, char **argv)
goto out;
}
+ /* wakeups */
if (opt_wakeups) {
dkp_tool_show_wakeups ();
- } else if (opt_enumerate || opt_dump) {
+ retval = EXIT_SUCCESS;
+ goto out;
+ }
+
+ if (opt_enumerate || opt_dump) {
GPtrArray *devices;
devices = dkp_client_enumerate_devices (client, &error);
if (devices == NULL) {
@@ -270,10 +275,18 @@ main (int argc, char **argv)
g_print ("Daemon:\n");
dkp_client_print (client);
}
- } else if (opt_monitor || opt_monitor_detail) {
+ retval = EXIT_SUCCESS;
+ goto out;
+ }
+
+ if (opt_monitor || opt_monitor_detail) {
if (!dkp_tool_do_monitor (client))
goto out;
- } else if (opt_show_info != NULL) {
+ retval = EXIT_SUCCESS;
+ goto out;
+ }
+
+ if (opt_show_info != NULL) {
device = dkp_device_new ();
ret = dkp_device_set_object_path (device, opt_show_info, &error);
if (!ret) {
@@ -281,12 +294,11 @@ main (int argc, char **argv)
g_error_free (error);
} else {
dkp_device_print (device);
- retval = 0;
}
g_object_unref (device);
+ retval = EXIT_SUCCESS;
+ goto out;
}
-
- retval = 0;
out:
g_object_unref (client);
return retval;