mirror of
https://gitlab.freedesktop.org/upower/upower.git
synced 2025-12-20 09:00:03 +01:00
openbsd: Fix compilation and compiler warnings
It didn't even compile, and one warning about an uninitialised variable was actually relevant.
This commit is contained in:
parent
65f2aa5c24
commit
8be73b986a
1 changed files with 8 additions and 5 deletions
|
|
@ -24,6 +24,8 @@
|
||||||
#include "up-backend.h"
|
#include "up-backend.h"
|
||||||
#include "up-daemon.h"
|
#include "up-daemon.h"
|
||||||
#include "up-device.h"
|
#include "up-device.h"
|
||||||
|
#include "up-config.h"
|
||||||
|
#include "up-backend-bsd-private.h"
|
||||||
#include <string.h> /* strcmp() */
|
#include <string.h> /* strcmp() */
|
||||||
|
|
||||||
static void up_backend_class_init (UpBackendClass *klass);
|
static void up_backend_class_init (UpBackendClass *klass);
|
||||||
|
|
@ -270,6 +272,9 @@ up_backend_update_battery_state(UpDevice* device)
|
||||||
"is-present", &is_present,
|
"is-present", &is_present,
|
||||||
(void*) NULL);
|
(void*) NULL);
|
||||||
|
|
||||||
|
// zero out new_time_to empty if we're not discharging or minutes_left is negative
|
||||||
|
new_time_to_empty = (new_state == UP_DEVICE_STATE_DISCHARGING && a.minutes_left > 0 ? a.minutes_left : 0);
|
||||||
|
|
||||||
/* XXX use acpibat0.raw0 if available */
|
/* XXX use acpibat0.raw0 if available */
|
||||||
/*
|
/*
|
||||||
* XXX: Stop having a split brain regarding
|
* XXX: Stop having a split brain regarding
|
||||||
|
|
@ -284,11 +289,12 @@ up_backend_update_battery_state(UpDevice* device)
|
||||||
* If we're on AC, we may either be charging, or the battery is already
|
* If we're on AC, we may either be charging, or the battery is already
|
||||||
* fully charged. Figure out which.
|
* fully charged. Figure out which.
|
||||||
*/
|
*/
|
||||||
if (a.ac_state == APM_AC_ON)
|
if (a.ac_state == APM_AC_ON) {
|
||||||
if ((gdouble) a.battery_life >= 99.0)
|
if ((gdouble) a.battery_life >= 99.0)
|
||||||
new_state = UP_DEVICE_STATE_FULLY_CHARGED;
|
new_state = UP_DEVICE_STATE_FULLY_CHARGED;
|
||||||
else
|
else
|
||||||
new_state = UP_DEVICE_STATE_CHARGING;
|
new_state = UP_DEVICE_STATE_CHARGING;
|
||||||
|
}
|
||||||
|
|
||||||
if ((a.battery_state == APM_BATTERY_ABSENT) ||
|
if ((a.battery_state == APM_BATTERY_ABSENT) ||
|
||||||
(a.battery_state == APM_BATT_UNKNOWN)) {
|
(a.battery_state == APM_BATT_UNKNOWN)) {
|
||||||
|
|
@ -310,9 +316,6 @@ up_backend_update_battery_state(UpDevice* device)
|
||||||
is_present = TRUE;
|
is_present = TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
// zero out new_time_to empty if we're not discharging or minutes_left is negative
|
|
||||||
new_time_to_empty = (new_state == UP_DEVICE_STATE_DISCHARGING && a.minutes_left > 0 ? a.minutes_left : 0);
|
|
||||||
|
|
||||||
if (cur_state != new_state ||
|
if (cur_state != new_state ||
|
||||||
percentage != (gdouble) a.battery_life ||
|
percentage != (gdouble) a.battery_life ||
|
||||||
cur_time_to_empty != new_time_to_empty)
|
cur_time_to_empty != new_time_to_empty)
|
||||||
|
|
@ -617,7 +620,7 @@ up_backend_init (UpBackend *backend)
|
||||||
device_class->get_online = up_apm_device_get_online;
|
device_class->get_online = up_apm_device_get_online;
|
||||||
device_class->refresh = up_apm_device_refresh;
|
device_class->refresh = up_apm_device_refresh;
|
||||||
/* creates thread */
|
/* creates thread */
|
||||||
if((backend->priv->apm_thread = (GThread*) g_thread_try_new("apm-poller",(GThreadFunc)up_backend_apm_event_thread, (void*) backend, &err) == NULL))
|
if((backend->priv->apm_thread = (GThread*) g_thread_try_new("apm-poller",(GThreadFunc)up_backend_apm_event_thread, (void*) backend, &err)) == NULL)
|
||||||
{
|
{
|
||||||
g_warning("Thread create failed: %s", err->message);
|
g_warning("Thread create failed: %s", err->message);
|
||||||
g_error_free (err);
|
g_error_free (err);
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue