mirror of
https://gitlab.freedesktop.org/upower/upower.git
synced 2026-02-02 01:30:31 +01:00
bugfix: fix compile error in dkp-power. Fixes #20749
This commit is contained in:
parent
23d3397b5b
commit
ed13111668
1 changed files with 11 additions and 6 deletions
|
|
@ -119,7 +119,7 @@ dkp_history_array_limit_resolution (GPtrArray *array, guint max_num)
|
|||
DkpDeviceState state = DKP_DEVICE_STATE_UNKNOWN;
|
||||
guint64 time = 0;
|
||||
gdouble value = 0;
|
||||
guint64 count;
|
||||
guint64 count = 0;
|
||||
guint step = 1;
|
||||
gfloat preset;
|
||||
|
||||
|
|
@ -128,6 +128,8 @@ dkp_history_array_limit_resolution (GPtrArray *array, guint max_num)
|
|||
|
||||
/* check length */
|
||||
length = array->len;
|
||||
if (length == 0)
|
||||
goto out;
|
||||
if (length < max_num) {
|
||||
/* need to copy array */
|
||||
g_ptr_array_foreach (array, (GFunc) dkp_history_array_copy_cb, new);
|
||||
|
|
@ -170,11 +172,14 @@ dkp_history_array_limit_resolution (GPtrArray *array, guint max_num)
|
|||
}
|
||||
}
|
||||
|
||||
nobj = dkp_history_obj_new ();
|
||||
nobj->time = time / count;
|
||||
nobj->value = value / count;
|
||||
nobj->state = state;
|
||||
g_ptr_array_add (new, nobj);
|
||||
/* only add if nonzero */
|
||||
if (count > 0) {
|
||||
nobj = dkp_history_obj_new ();
|
||||
nobj->time = time / count;
|
||||
nobj->value = value / count;
|
||||
nobj->state = state;
|
||||
g_ptr_array_add (new, nobj);
|
||||
}
|
||||
|
||||
/* check length */
|
||||
egg_debug ("length of array (after) %i", new->len);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue