[PATCH] all: convert value from g_get_real_time() to seconds

Evangelos Foutras evangelos at foutrelis.com
Thu Oct 2 06:04:31 PDT 2014


Commit 5ddfe0d (all: Use g_get_real_time() when possible) replaced calls
to g_get_current_time() with g_get_real_time(), however, we also need to
convert the return value from microseconds to seconds.
---
 src/dummy/up-backend.c         | 2 +-
 src/freebsd/up-device-supply.c | 2 +-
 src/linux/up-device-csr.c      | 2 +-
 src/linux/up-device-hid.c      | 2 +-
 src/linux/up-device-idevice.c  | 2 +-
 src/linux/up-device-supply.c   | 2 +-
 src/linux/up-device-unifying.c | 2 +-
 src/linux/up-device-wup.c      | 2 +-
 src/openbsd/up-backend.c       | 4 ++--
 src/up-daemon.c                | 4 ++--
 10 files changed, 12 insertions(+), 12 deletions(-)

diff --git a/src/dummy/up-backend.c b/src/dummy/up-backend.c
index ddb7e62..ffd425c 100644
--- a/src/dummy/up-backend.c
+++ b/src/dummy/up-backend.c
@@ -73,7 +73,7 @@ up_backend_changed_time_cb (UpBackend *backend)
 	device = NULL;
 
 	/* reset time */
-	g_object_set (device, "update-time", (guint64) g_get_real_time (), NULL);
+	g_object_set (device, "update-time", (guint64) g_get_real_time () / 1000000, NULL);
 	return TRUE;
 }
 
diff --git a/src/freebsd/up-device-supply.c b/src/freebsd/up-device-supply.c
index 04d7f45..877f164 100644
--- a/src/freebsd/up-device-supply.c
+++ b/src/freebsd/up-device-supply.c
@@ -400,7 +400,7 @@ up_device_supply_refresh (UpDevice *device)
 	}
 
 	if (ret)
-		g_object_set (device, "update-time", (guint64) g_get_real_time (), NULL);
+		g_object_set (device, "update-time", (guint64) g_get_real_time () / 1000000, NULL);
 
 	return ret;
 }
diff --git a/src/linux/up-device-csr.c b/src/linux/up-device-csr.c
index 6b4d768..6a13c8e 100644
--- a/src/linux/up-device-csr.c
+++ b/src/linux/up-device-csr.c
@@ -274,7 +274,7 @@ up_device_csr_refresh (UpDevice *device)
 	}
 
 	/* reset time */
-	g_object_set (device, "update-time", (guint64) g_get_real_time (), NULL);
+	g_object_set (device, "update-time", (guint64) g_get_real_time () / 1000000, NULL);
 
 	/* success */
 	ret = TRUE;
diff --git a/src/linux/up-device-hid.c b/src/linux/up-device-hid.c
index 5933394..d4e3eb1 100644
--- a/src/linux/up-device-hid.c
+++ b/src/linux/up-device-hid.c
@@ -427,7 +427,7 @@ up_device_hid_refresh (UpDevice *device)
 	up_device_hid_fixup_state (device);
 
 	/* reset time */
-	g_object_set (device, "update-time", (guint64) g_get_real_time (), NULL);
+	g_object_set (device, "update-time", (guint64) g_get_real_time () / 1000000, NULL);
 out:
 	return ret;
 }
diff --git a/src/linux/up-device-idevice.c b/src/linux/up-device-idevice.c
index bf61a6f..3482d4c 100644
--- a/src/linux/up-device-idevice.c
+++ b/src/linux/up-device-idevice.c
@@ -200,7 +200,7 @@ up_device_idevice_refresh (UpDevice *device)
 	plist_free (dict);
 
 	/* reset time */
-	g_object_set (device, "update-time", (guint64) g_get_real_time (), NULL);
+	g_object_set (device, "update-time", (guint64) g_get_real_time () / 1000000, NULL);
 
 	retval = TRUE;
 
diff --git a/src/linux/up-device-supply.c b/src/linux/up-device-supply.c
index 075235c..538aa98 100644
--- a/src/linux/up-device-supply.c
+++ b/src/linux/up-device-supply.c
@@ -1109,7 +1109,7 @@ up_device_supply_refresh (UpDevice *device)
 
 	/* reset time if we got new data */
 	if (ret)
-		g_object_set (device, "update-time", (guint64) g_get_real_time (), NULL);
+		g_object_set (device, "update-time", (guint64) g_get_real_time () / 1000000, NULL);
 
 	return ret;
 }
diff --git a/src/linux/up-device-unifying.c b/src/linux/up-device-unifying.c
index 2795831..0383732 100644
--- a/src/linux/up-device-unifying.c
+++ b/src/linux/up-device-unifying.c
@@ -103,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) g_get_real_time (),
+		      "update-time", (guint64) g_get_real_time () / 1000000,
 		      NULL);
 out:
 	return TRUE;
diff --git a/src/linux/up-device-wup.c b/src/linux/up-device-wup.c
index 4e82bba..d84039c 100644
--- a/src/linux/up-device-wup.c
+++ b/src/linux/up-device-wup.c
@@ -406,7 +406,7 @@ up_device_wup_refresh (UpDevice *device)
 	}
 
 	/* reset time */
-	g_object_set (device, "update-time", (guint64) g_get_real_time (), NULL);
+	g_object_set (device, "update-time", (guint64) g_get_real_time () / 1000000, NULL);
 
 out:
 	g_free (data);
diff --git a/src/openbsd/up-backend.c b/src/openbsd/up-backend.c
index 1258770..0017986 100644
--- a/src/openbsd/up-backend.c
+++ b/src/openbsd/up-backend.c
@@ -415,7 +415,7 @@ up_apm_device_refresh(UpDevice* device)
 	}
 
 	if (ret)
-		g_object_set (device, "update-time", (guint64) g_get_real_time (), NULL);
+		g_object_set (device, "update-time", (guint64) g_get_real_time () / 1000000, NULL);
 
 	return ret;
 }
@@ -601,7 +601,7 @@ up_backend_init (UpBackend *backend)
 		}
 
 		/* setup dummy */
-		current_time = g_get_real_time ();
+		current_time = g_get_real_time () / 1000000;
 		g_object_set (backend->priv->battery,
 			      "type", UP_DEVICE_KIND_BATTERY,
 			      "power-supply", TRUE,
diff --git a/src/up-daemon.c b/src/up-daemon.c
index 5d9fe87..a0a932c 100644
--- a/src/up-daemon.c
+++ b/src/up-daemon.c
@@ -317,7 +317,7 @@ out:
 		      "percentage", percentage_total,
 		      "is-present", is_present_total,
 		      "power-supply", TRUE,
-		      "update-time", (guint64) g_get_real_time (),
+		      "update-time", (guint64) g_get_real_time () / 1000000,
 		      NULL);
 
 	return TRUE;
@@ -757,7 +757,7 @@ up_daemon_set_warning_level (UpDaemon *daemon, UpDeviceLevel warning_level)
 
 	g_object_set (G_OBJECT (daemon->priv->display_device),
 		      "warning-level", warning_level,
-		      "update-time", (guint64) g_get_real_time (),
+		      "update-time", (guint64) g_get_real_time () / 1000000,
 		      NULL);
 
 	if (daemon->priv->warning_level == UP_DEVICE_LEVEL_ACTION) {
-- 
2.1.2



More information about the devkit-devel mailing list