mirror of
https://gitlab.freedesktop.org/upower/upower.git
synced 2026-05-05 01:48:06 +02:00
up-client: Don't overwrite retval with property values
If one of the properties is FALSE, we'll end up return FALSE without setting an error (and making the caller crash if they expect an error being filled in). https://bugs.freedesktop.org/show_bug.cgi?id=70283 Signed-off-by: Martin Pitt <martinpitt@gnome.org>
This commit is contained in:
parent
5c132c683d
commit
db89e5a32b
1 changed files with 16 additions and 15 deletions
|
|
@ -315,6 +315,7 @@ up_client_get_properties_sync (UpClient *client, GCancellable *cancellable, GErr
|
|||
{
|
||||
gboolean ret = TRUE;
|
||||
gboolean allowed = FALSE;
|
||||
gboolean prop_val;
|
||||
GHashTable *props;
|
||||
GValue *value;
|
||||
|
||||
|
|
@ -353,8 +354,8 @@ up_client_get_properties_sync (UpClient *client, GCancellable *cancellable, GErr
|
|||
if (!ret)
|
||||
goto out;
|
||||
|
||||
ret = g_value_get_boolean (value) && allowed;
|
||||
if (ret != client->priv->can_suspend) {
|
||||
prop_val = g_value_get_boolean (value) && allowed;
|
||||
if (prop_val != client->priv->can_suspend) {
|
||||
client->priv->can_suspend = ret;
|
||||
g_object_notify (G_OBJECT(client), "can-suspend");
|
||||
}
|
||||
|
|
@ -369,8 +370,8 @@ up_client_get_properties_sync (UpClient *client, GCancellable *cancellable, GErr
|
|||
if (!ret)
|
||||
goto out;
|
||||
|
||||
ret = g_value_get_boolean (value) && allowed;
|
||||
if (ret != client->priv->can_hibernate) {
|
||||
prop_val = g_value_get_boolean (value) && allowed;
|
||||
if (prop_val != client->priv->can_hibernate) {
|
||||
client->priv->can_hibernate = ret;
|
||||
g_object_notify (G_OBJECT(client), "can-hibernate");
|
||||
}
|
||||
|
|
@ -380,8 +381,8 @@ up_client_get_properties_sync (UpClient *client, GCancellable *cancellable, GErr
|
|||
g_warning ("No 'LidIsClosed' property");
|
||||
goto out;
|
||||
}
|
||||
ret = g_value_get_boolean (value);
|
||||
if (ret != client->priv->lid_is_closed) {
|
||||
prop_val = g_value_get_boolean (value);
|
||||
if (prop_val != client->priv->lid_is_closed) {
|
||||
client->priv->lid_is_closed = ret;
|
||||
g_object_notify (G_OBJECT(client), "lid-is-closed");
|
||||
}
|
||||
|
|
@ -391,8 +392,8 @@ up_client_get_properties_sync (UpClient *client, GCancellable *cancellable, GErr
|
|||
g_warning ("No 'OnBattery' property");
|
||||
goto out;
|
||||
}
|
||||
ret = g_value_get_boolean (value);
|
||||
if (ret != client->priv->on_battery) {
|
||||
prop_val = g_value_get_boolean (value);
|
||||
if (prop_val != client->priv->on_battery) {
|
||||
client->priv->on_battery = ret;
|
||||
g_object_notify (G_OBJECT(client), "on-battery");
|
||||
}
|
||||
|
|
@ -402,8 +403,8 @@ up_client_get_properties_sync (UpClient *client, GCancellable *cancellable, GErr
|
|||
g_warning ("No 'OnLowBattery' property");
|
||||
goto out;
|
||||
}
|
||||
ret = g_value_get_boolean (value);
|
||||
if (ret != client->priv->on_low_battery) {
|
||||
prop_val = g_value_get_boolean (value);
|
||||
if (prop_val != client->priv->on_low_battery) {
|
||||
client->priv->on_low_battery = ret;
|
||||
g_object_notify (G_OBJECT(client), "on-low-battery");
|
||||
}
|
||||
|
|
@ -413,8 +414,8 @@ up_client_get_properties_sync (UpClient *client, GCancellable *cancellable, GErr
|
|||
g_warning ("No 'LidIsPresent' property");
|
||||
goto out;
|
||||
}
|
||||
ret = g_value_get_boolean (value);
|
||||
if (ret != client->priv->lid_is_present) {
|
||||
prop_val = g_value_get_boolean (value);
|
||||
if (prop_val != client->priv->lid_is_present) {
|
||||
client->priv->lid_is_present = ret;
|
||||
g_object_notify (G_OBJECT(client), "lid-is-present");
|
||||
}
|
||||
|
|
@ -424,7 +425,7 @@ up_client_get_properties_sync (UpClient *client, GCancellable *cancellable, GErr
|
|||
g_warning ("No 'IsDocked' property");
|
||||
goto out;
|
||||
}
|
||||
ret = g_value_get_boolean (value);
|
||||
prop_val = g_value_get_boolean (value);
|
||||
if (ret != client->priv->is_docked) {
|
||||
client->priv->is_docked = ret;
|
||||
g_object_notify (G_OBJECT(client), "is-docked");
|
||||
|
|
@ -435,8 +436,8 @@ up_client_get_properties_sync (UpClient *client, GCancellable *cancellable, GErr
|
|||
g_warning ("No 'LidForceSleep' property");
|
||||
goto out;
|
||||
}
|
||||
ret = g_value_get_boolean (value);
|
||||
if (ret != client->priv->lid_force_sleep) {
|
||||
prop_val = g_value_get_boolean (value);
|
||||
if (prop_val != client->priv->lid_force_sleep) {
|
||||
client->priv->lid_force_sleep = ret;
|
||||
g_object_notify (G_OBJECT(client), "lid-force-sleep");
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue