summaryrefslogtreecommitdiff
path: root/src/linux/up-device-supply.c
diff options
context:
space:
mode:
authorJoão Paulo Rechi Vita <jprvita@endlessm.com>2018-11-02 16:05:21 -0700
committerJoão Paulo Rechi Vita <jprvita@endlessm.com>2018-12-18 17:16:49 -0800
commit888c9121f090a1128562edb9c06dcd6b564578c7 (patch)
treeacbb035920dfafb13c6defda7187c864a1c902a1 /src/linux/up-device-supply.c
parentf3f4c6e0b4d05b541a87f09bd93f70a487258884 (diff)
downloadupower-888c9121f090a1128562edb9c06dcd6b564578c7.tar.gz
linux: Don't set out_state before state is final
Currently up_device_supply_refresh_battery sets out_state before the state value is definitive, so the wrong state value is returned to the caller. Luckily the only caller does not make use of this value at the moment, so there are no user-visible consequences. Nonetheless this is a bug, so this commit fixes it.
Diffstat (limited to 'src/linux/up-device-supply.c')
-rw-r--r--src/linux/up-device-supply.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/src/linux/up-device-supply.c b/src/linux/up-device-supply.c
index 000a00f..1644665 100644
--- a/src/linux/up-device-supply.c
+++ b/src/linux/up-device-supply.c
@@ -669,7 +669,6 @@ up_device_supply_refresh_battery (UpDeviceSupply *supply,
}
state = up_device_supply_get_state (native_path);
- *out_state = state;
/* this is the new value in uW */
energy_rate = fabs (sysfs_get_double (native_path, "power_now") / 1000000.0);
@@ -833,6 +832,8 @@ up_device_supply_refresh_battery (UpDeviceSupply *supply,
supply->priv->energy_old_first = 0;
}
+ *out_state = state;
+
g_object_set (device,
"energy", energy,
"energy-full", energy_full,