Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[usb-moded] Forget stale timer id
The charging_fallback() function has multiple return paths and does
not always clear timer id variable "charging_timeout". This can later
on lead to attempts to remove stale timer id - which causes glib to
emit warnings.

Clear the bookkeeping variable on entry to callback rather than just
one of the possible return points.

Signed-off-by: Simo Piiroinen <simo.piiroinen@jollamobile.com>
  • Loading branch information
spiiroin committed Mar 28, 2018
1 parent d5cc31f commit 00e6688
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/usb_moded.c
Expand Up @@ -793,6 +793,8 @@ static gboolean charging_fallback(gpointer data)
{
(void)data;

charging_timeout = 0;

/* if a mode has been set we don't want it changed to charging
* after 5 seconds. We set it to ask, so anything different
* means a mode has been set */
Expand All @@ -806,7 +808,6 @@ static gboolean charging_fallback(gpointer data)
free(current_mode.mode);
current_mode.mode = strdup(MODE_ASK);
current_mode.data = NULL;
charging_timeout = 0;
log_info("Falling back on charging mode.\n");

return(FALSE);
Expand Down

0 comments on commit 00e6688

Please sign in to comment.