[PATCH] up-device-supply.c: Fix #27902 Bug - Daemon Segmentation Fault

Mariusz Ceier mceier at gmail.com
Fri Jul 2 05:54:12 PDT 2010


In linux backend, g_object_set was called with wrong
argument types for time-to-empty,time-to-full and percentage
properties. This patch uses explicit casts in the same way as freebsd
backend.

Signed-off-by: Mariusz Ceier <mceier at gmail.com>
---
 src/freebsd/up-device-supply.c |    6 +++---
 src/linux/up-device-supply.c   |   30 +++++++++++++++---------------
 2 files changed, 18 insertions(+), 18 deletions(-)

diff --git a/src/freebsd/up-device-supply.c b/src/freebsd/up-device-supply.c
index d3c2872..b499d57 100644
--- a/src/freebsd/up-device-supply.c
+++ b/src/freebsd/up-device-supply.c
@@ -112,8 +112,8 @@ up_device_supply_reset_values (UpDevice *device)
 		      "energy-full-design", (gdouble) 0.0,
 		      "energy-rate", (gdouble) 0.0,
 		      "voltage", (gdouble) 0.0,
-		      "time-to-empty", (guint64) 0,
-		      "time-to-full", (guint64) 0,
+		      "time-to-empty", (gint64) 0,
+		      "time-to-full", (gint64) 0,
 		      "percentage", (gdouble) 0.0,
 		      "technology", UP_DEVICE_TECHNOLOGY_UNKNOWN,
 		      NULL);
@@ -162,7 +162,7 @@ up_device_supply_battery_set_properties (UpDevice *device, UpAcpiNative *native)
 	gdouble volt, dvolt, rate, lastfull, cap, dcap, lcap, capacity;
 	gboolean is_present;
 	gboolean ret = FALSE;
-	guint64 time_to_empty, time_to_full;
+	gint64 time_to_empty, time_to_full;
 	gchar *vendor, *model, *serial;
 	UpDeviceTechnology technology;
 	UpDeviceState state;
diff --git a/src/linux/up-device-supply.c b/src/linux/up-device-supply.c
index ec405f4..b1e03c3 100644
--- a/src/linux/up-device-supply.c
+++ b/src/linux/up-device-supply.c
@@ -104,25 +104,25 @@ up_device_supply_reset_values (UpDeviceSupply *supply)
 		      "vendor", NULL,
 		      "model", NULL,
 		      "serial", NULL,
-		      "update-time", 0,
+		      "update-time", (guint64) 0,
 		      "power-supply", FALSE,
 		      "online", FALSE,
-		      "energy", 0.0,
+		      "energy", (gdouble) 0.0,
 		      "is-present", FALSE,
 		      "is-rechargeable", FALSE,
 		      "has-history", FALSE,
 		      "has-statistics", FALSE,
-		      "state", NULL,
-		      "capacity", 0.0,
-		      "energy-empty", 0.0,
-		      "energy-full", 0.0,
-		      "energy-full-design", 0.0,
-		      "energy-rate", 0.0,
-		      "voltage", 0.0,
-		      "time-to-empty", 0,
-		      "time-to-full", 0,
-		      "percentage", 0,
-		      "technology", NULL,
+		      "state", UP_DEVICE_STATE_UNKNOWN,
+		      "capacity", (gdouble) 0.0,
+		      "energy-empty", (gdouble) 0.0,
+		      "energy-full", (gdouble) 0.0,
+		      "energy-full-design", (gdouble) 0.0,
+		      "energy-rate", (gdouble) 0.0,
+		      "voltage", (gdouble) 0.0,
+		      "time-to-empty", (gint64) 0,
+		      "time-to-full", (gint64) 0,
+		      "percentage", (gdouble) 0.0,
+		      "technology", UP_DEVICE_TECHNOLOGY_UNKNOWN,
 		      NULL);
 }
 
@@ -415,8 +415,8 @@ up_device_supply_refresh_battery (UpDeviceSupply *supply)
 	gdouble capacity = 100.0f;
 	gdouble percentage = 0.0f;
 	gdouble voltage;
-	guint64 time_to_empty;
-	guint64 time_to_full;
+	gint64 time_to_empty;
+	gint64 time_to_full;
 	gchar *manufacturer = NULL;
 	gchar *model_name = NULL;
 	gchar *serial_number = NULL;
-- 
1.7.1.1



More information about the devkit-devel mailing list