summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBastien Nocera <hadess@hadess.net>2014-09-24 15:15:23 +0200
committerBastien Nocera <hadess@hadess.net>2014-09-24 15:16:11 +0200
commit5ddfe0dba19c069b16a1b38cac2fa9dc8372862d (patch)
tree1d806f20386cf172e86fef0140868e480b0333f5
parent8271045a68b5d34a47d0c6214681e2b088234d2e (diff)
downloadupower-5ddfe0dba19c069b16a1b38cac2fa9dc8372862d.tar.gz
all: Use g_get_real_time() when possible
Instead of a call to g_get_current_time().
-rw-r--r--src/dummy/up-backend.c4
-rw-r--r--src/freebsd/up-device-supply.c7
-rw-r--r--src/linux/up-device-csr.c4
-rw-r--r--src/linux/up-device-hid.c4
-rw-r--r--src/linux/up-device-idevice.c4
-rw-r--r--src/linux/up-device-supply.c7
-rw-r--r--src/linux/up-device-unifying.c4
-rw-r--r--src/linux/up-device-wup.c4
-rw-r--r--src/openbsd/up-backend.c15
9 files changed, 16 insertions, 37 deletions
diff --git a/src/dummy/up-backend.c b/src/dummy/up-backend.c
index d9972a9..ddb7e62 100644
--- a/src/dummy/up-backend.c
+++ b/src/dummy/up-backend.c
@@ -68,14 +68,12 @@ static gboolean
up_backend_changed_time_cb (UpBackend *backend)
{
UpDevice *device;
- GTimeVal timeval;
//FIXME!
device = NULL;
/* reset time */
- g_get_current_time (&timeval);
- g_object_set (device, "update-time", (guint64) timeval.tv_sec, NULL);
+ g_object_set (device, "update-time", (guint64) g_get_real_time (), NULL);
return TRUE;
}
diff --git a/src/freebsd/up-device-supply.c b/src/freebsd/up-device-supply.c
index f2cc1c4..04d7f45 100644
--- a/src/freebsd/up-device-supply.c
+++ b/src/freebsd/up-device-supply.c
@@ -382,7 +382,6 @@ static gboolean
up_device_supply_refresh (UpDevice *device)
{
GObject *object;
- GTimeVal timeval;
UpDeviceKind type;
gboolean ret;
@@ -400,10 +399,8 @@ up_device_supply_refresh (UpDevice *device)
break;
}
- if (ret) {
- g_get_current_time (&timeval);
- g_object_set (device, "update-time", (guint64) timeval.tv_sec, NULL);
- }
+ if (ret)
+ g_object_set (device, "update-time", (guint64) g_get_real_time (), NULL);
return ret;
}
diff --git a/src/linux/up-device-csr.c b/src/linux/up-device-csr.c
index 9425689..6b4d768 100644
--- a/src/linux/up-device-csr.c
+++ b/src/linux/up-device-csr.c
@@ -219,7 +219,6 @@ static gboolean
up_device_csr_refresh (UpDevice *device)
{
gboolean ret = FALSE;
- GTimeVal timeval;
UpDeviceCsr *csr = UP_DEVICE_CSR (device);
libusb_device_handle *handle = NULL;
guint8 buf[80];
@@ -275,8 +274,7 @@ up_device_csr_refresh (UpDevice *device)
}
/* reset time */
- g_get_current_time (&timeval);
- g_object_set (device, "update-time", (guint64) timeval.tv_sec, NULL);
+ g_object_set (device, "update-time", (guint64) g_get_real_time (), NULL);
/* success */
ret = TRUE;
diff --git a/src/linux/up-device-hid.c b/src/linux/up-device-hid.c
index fe2c992..5933394 100644
--- a/src/linux/up-device-hid.c
+++ b/src/linux/up-device-hid.c
@@ -393,7 +393,6 @@ up_device_hid_refresh (UpDevice *device)
{
gboolean set = FALSE;
gboolean ret = FALSE;
- GTimeVal timeval;
guint i;
struct hiddev_event ev[64];
int rd;
@@ -428,8 +427,7 @@ up_device_hid_refresh (UpDevice *device)
up_device_hid_fixup_state (device);
/* reset time */
- g_get_current_time (&timeval);
- g_object_set (device, "update-time", (guint64) timeval.tv_sec, NULL);
+ g_object_set (device, "update-time", (guint64) g_get_real_time (), NULL);
out:
return ret;
}
diff --git a/src/linux/up-device-idevice.c b/src/linux/up-device-idevice.c
index 27d7319..bf61a6f 100644
--- a/src/linux/up-device-idevice.c
+++ b/src/linux/up-device-idevice.c
@@ -153,7 +153,6 @@ out:
static gboolean
up_device_idevice_refresh (UpDevice *device)
{
- GTimeVal timeval;
UpDeviceIdevice *idevice = UP_DEVICE_IDEVICE (device);
lockdownd_client_t client = NULL;
plist_t dict, node;
@@ -201,8 +200,7 @@ up_device_idevice_refresh (UpDevice *device)
plist_free (dict);
/* reset time */
- g_get_current_time (&timeval);
- g_object_set (device, "update-time", (guint64) timeval.tv_sec, NULL);
+ g_object_set (device, "update-time", (guint64) g_get_real_time (), NULL);
retval = TRUE;
diff --git a/src/linux/up-device-supply.c b/src/linux/up-device-supply.c
index e94eefd..075235c 100644
--- a/src/linux/up-device-supply.c
+++ b/src/linux/up-device-supply.c
@@ -1088,7 +1088,6 @@ static gboolean
up_device_supply_refresh (UpDevice *device)
{
gboolean ret;
- GTimeVal timeval;
UpDeviceSupply *supply = UP_DEVICE_SUPPLY (device);
UpDeviceKind type;
UpDeviceState state;
@@ -1109,10 +1108,8 @@ up_device_supply_refresh (UpDevice *device)
}
/* reset time if we got new data */
- if (ret) {
- g_get_current_time (&timeval);
- g_object_set (device, "update-time", (guint64) timeval.tv_sec, NULL);
- }
+ if (ret)
+ g_object_set (device, "update-time", (guint64) g_get_real_time (), NULL);
return ret;
}
diff --git a/src/linux/up-device-unifying.c b/src/linux/up-device-unifying.c
index 7d0dbf9..2795831 100644
--- a/src/linux/up-device-unifying.c
+++ b/src/linux/up-device-unifying.c
@@ -48,7 +48,6 @@ up_device_unifying_refresh (UpDevice *device)
{
gboolean ret;
GError *error = NULL;
- GTimeVal timeval;
HidppRefreshFlags refresh_flags;
UpDeviceState state = UP_DEVICE_STATE_UNKNOWN;
UpDeviceUnifying *unifying = UP_DEVICE_UNIFYING (device);
@@ -95,7 +94,6 @@ up_device_unifying_refresh (UpDevice *device)
state = UP_DEVICE_STATE_UNKNOWN;
}
- g_get_current_time (&timeval);
lux = hidpp_device_get_luminosity (priv->hidpp_device);
if (lux >= 0) {
g_object_set (device, "luminosity", lux, NULL);
@@ -105,7 +103,7 @@ up_device_unifying_refresh (UpDevice *device)
"is-present", hidpp_device_is_reachable (priv->hidpp_device),
"percentage", (gdouble) hidpp_device_get_batt_percentage (priv->hidpp_device),
"state", state,
- "update-time", (guint64) timeval.tv_sec,
+ "update-time", (guint64) g_get_real_time (),
NULL);
out:
return TRUE;
diff --git a/src/linux/up-device-wup.c b/src/linux/up-device-wup.c
index 914741e..4e82bba 100644
--- a/src/linux/up-device-wup.c
+++ b/src/linux/up-device-wup.c
@@ -388,7 +388,6 @@ static gboolean
up_device_wup_refresh (UpDevice *device)
{
gboolean ret = FALSE;
- GTimeVal timeval;
gchar *data = NULL;
UpDeviceWup *wup = UP_DEVICE_WUP (device);
@@ -407,8 +406,7 @@ up_device_wup_refresh (UpDevice *device)
}
/* reset time */
- g_get_current_time (&timeval);
- g_object_set (device, "update-time", (guint64) timeval.tv_sec, NULL);
+ g_object_set (device, "update-time", (guint64) g_get_real_time (), NULL);
out:
g_free (data);
diff --git a/src/openbsd/up-backend.c b/src/openbsd/up-backend.c
index d40a269..1258770 100644
--- a/src/openbsd/up-backend.c
+++ b/src/openbsd/up-backend.c
@@ -399,7 +399,6 @@ static gboolean
up_apm_device_refresh(UpDevice* device)
{
UpDeviceKind type;
- GTimeVal timeval;
gboolean ret;
g_object_get (device, "type", &type, NULL);
@@ -415,10 +414,8 @@ up_apm_device_refresh(UpDevice* device)
break;
}
- if (ret) {
- g_get_current_time (&timeval);
- g_object_set (device, "update-time", (guint64) timeval.tv_sec, NULL);
- }
+ if (ret)
+ g_object_set (device, "update-time", (guint64) g_get_real_time (), NULL);
return ret;
}
@@ -578,8 +575,8 @@ static void
up_backend_init (UpBackend *backend)
{
GError *err = NULL;
- GTimeVal timeval;
UpDeviceClass *device_class;
+ gint64 current_time;
backend->priv = UP_BACKEND_GET_PRIVATE (backend);
backend->priv->is_laptop = up_native_is_laptop();
@@ -604,7 +601,7 @@ up_backend_init (UpBackend *backend)
}
/* setup dummy */
- g_get_current_time (&timeval);
+ current_time = g_get_real_time ();
g_object_set (backend->priv->battery,
"type", UP_DEVICE_KIND_BATTERY,
"power-supply", TRUE,
@@ -614,13 +611,13 @@ up_backend_init (UpBackend *backend)
"state", UP_DEVICE_STATE_UNKNOWN,
"percentage", 0.0f,
"time-to-empty", (gint64) 0,
- "update-time", (guint64) timeval.tv_sec,
+ "update-time", (guint64) current_time,
(void*) NULL);
g_object_set (backend->priv->ac,
"type", UP_DEVICE_KIND_LINE_POWER,
"online", TRUE,
"power-supply", TRUE,
- "update-time", (guint64) timeval.tv_sec,
+ "update-time", (guint64) current_time,
(void*) NULL);
}
}