diff options
author | Richard Hughes <richard@hughsie.com> | 2009-05-27 15:47:06 +0100 |
---|---|---|
committer | Richard Hughes <richard@hughsie.com> | 2009-05-27 15:47:06 +0100 |
commit | 70a5fce8a4da9b9b000c86cd9c2ae668d1025850 (patch) | |
tree | 83e8c583cba2418be6a65e4fcddfa6bb094840b3 /src | |
parent | 0ff31760f9be79af57a000e60ec757c4b6e55805 (diff) |
Fix up the return statuses from coldplug and refresh, as different modules are doing different things
Diffstat (limited to 'src')
-rw-r--r-- | src/dkp-csr.c | 15 | ||||
-rw-r--r-- | src/dkp-device.c | 15 | ||||
-rw-r--r-- | src/dkp-hid.c | 6 | ||||
-rw-r--r-- | src/dkp-supply.c | 13 | ||||
-rw-r--r-- | src/dkp-wup.c | 4 |
5 files changed, 38 insertions, 15 deletions
diff --git a/src/dkp-csr.c b/src/dkp-csr.c index e8f7a52..00414e6 100644 --- a/src/dkp-csr.c +++ b/src/dkp-csr.c @@ -126,6 +126,8 @@ out: /** * dkp_csr_coldplug: + * + * Return %TRUE on success, %FALSE if we failed to get data and should be removed **/ static gboolean dkp_csr_coldplug (DkpDevice *device) @@ -216,14 +218,16 @@ out: /** * dkp_csr_refresh: + * + * Return %TRUE on success, %FALSE if we failed to refresh or no data **/ static gboolean dkp_csr_refresh (DkpDevice *device) { - gboolean ret = TRUE; + gboolean ret = FALSE; GTimeVal time; DkpCsr *csr = DKP_CSR (device); - usb_dev_handle *handle; + usb_dev_handle *handle = NULL; char buf[80]; unsigned int addr; gdouble percentage; @@ -239,14 +243,14 @@ dkp_csr_refresh (DkpDevice *device) if (csr->priv->device == NULL) { egg_warning ("no device!"); - return FALSE; + goto out; } /* open USB device */ handle = usb_open (csr->priv->device); if (handle == NULL) { egg_warning ("could not open device"); - return FALSE; + goto out; } /* get the charge */ @@ -273,7 +277,8 @@ dkp_csr_refresh (DkpDevice *device) } out: - usb_close (handle); + if (handle != NULL) + usb_close (handle); return ret; } diff --git a/src/dkp-device.c b/src/dkp-device.c index 9c394d8..ef46c05 100644 --- a/src/dkp-device.c +++ b/src/dkp-device.c @@ -476,6 +476,8 @@ out: /** * dkp_device_coldplug: + * + * Return %TRUE on success, %FALSE if we failed to get data and should be removed **/ gboolean dkp_device_coldplug (DkpDevice *device, DkpDaemon *daemon, DevkitDevice *d) @@ -677,6 +679,8 @@ out: /** * dkp_device_refresh: + * + * Return %TRUE on success, %FALSE if we failed to refresh or no data **/ gboolean dkp_device_refresh (DkpDevice *device, DBusGMethodInvocation *context) @@ -697,24 +701,23 @@ dkp_device_refresh (DkpDevice *device, DBusGMethodInvocation *context) gboolean dkp_device_changed (DkpDevice *device, DevkitDevice *d, gboolean synthesized) { - gboolean changed; + gboolean ret; g_return_val_if_fail (DKP_IS_DEVICE (device), FALSE); g_object_unref (device->priv->d); device->priv->d = g_object_ref (d); - changed = dkp_device_refresh_internal (device); + ret = dkp_device_refresh_internal (device); - /* this 'change' event might prompt us to remove the supply */ - if (!changed) + /* we failed to refresh, don't emit changed */ + if (!ret) goto out; /* no, it's good .. keep it */ dkp_device_emit_changed (device); - out: - return changed; + return ret; } /** diff --git a/src/dkp-hid.c b/src/dkp-hid.c index 4e4991b..374bd3f 100644 --- a/src/dkp-hid.c +++ b/src/dkp-hid.c @@ -281,6 +281,8 @@ dkp_hid_get_all_data (DkpHid *hid) /** * dkp_hid_coldplug: + * + * Return %TRUE on success, %FALSE if we failed to get data and should be removed **/ static gboolean dkp_hid_coldplug (DkpDevice *device) @@ -351,6 +353,8 @@ out: /** * dkp_hid_refresh: + * + * Return %TRUE on success, %FALSE if we failed to refresh or no data **/ static gboolean dkp_hid_refresh (DkpDevice *device) @@ -370,7 +374,7 @@ dkp_hid_refresh (DkpDevice *device) /* read any data -- it's okay if there's nothing as we are non-blocking */ rd = read (hid->priv->fd, ev, sizeof (ev)); if (rd < (int) sizeof (ev[0])) { - ret = TRUE; + ret = FALSE; goto out; } diff --git a/src/dkp-supply.c b/src/dkp-supply.c index bd95798..9ea76b5 100644 --- a/src/dkp-supply.c +++ b/src/dkp-supply.c @@ -60,6 +60,8 @@ static gboolean dkp_supply_refresh (DkpDevice *device); /** * dkp_supply_refresh_line_power: + * + * Return %TRUE on success, %FALSE if we failed to refresh or no data **/ static gboolean dkp_supply_refresh_line_power (DkpSupply *supply) @@ -274,7 +276,7 @@ dkp_supply_convert_device_technology (const gchar *type) /** * dkp_supply_refresh_battery: * - * Return value: TRUE if we changed + * Return %TRUE on success, %FALSE if we failed to refresh or no data **/ static gboolean dkp_supply_refresh_battery (DkpSupply *supply) @@ -522,11 +524,14 @@ dkp_supply_poll_battery (DkpSupply *supply) /** * dkp_supply_coldplug: + * + * Return %TRUE on success, %FALSE if we failed to get data and should be removed **/ static gboolean dkp_supply_coldplug (DkpDevice *device) { DkpSupply *supply = DKP_SUPPLY (device); + gboolean ret; DevkitDevice *d; const gchar *native_path; @@ -549,9 +554,9 @@ dkp_supply_coldplug (DkpDevice *device) } /* coldplug values */ - dkp_supply_refresh (device); + ret = dkp_supply_refresh (device); - return TRUE; + return ret; } /** @@ -590,6 +595,8 @@ out: /** * dkp_supply_refresh: + * + * Return %TRUE on success, %FALSE if we failed to refresh or no data **/ static gboolean dkp_supply_refresh (DkpDevice *device) diff --git a/src/dkp-wup.c b/src/dkp-wup.c index faf34b4..23ada77 100644 --- a/src/dkp-wup.c +++ b/src/dkp-wup.c @@ -291,6 +291,8 @@ out: /** * dkp_wup_coldplug: + * + * Return %TRUE on success, %FALSE if we failed to get data and should be removed **/ static gboolean dkp_wup_coldplug (DkpDevice *device) @@ -388,6 +390,8 @@ out: /** * dkp_wup_refresh: + * + * Return %TRUE on success, %FALSE if we failed to refresh or no data **/ static gboolean dkp_wup_refresh (DkpDevice *device) |