Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[usb setting logic] Do not check for mode_to_set_twice Fixes: CID#123…
…0272

In case we compile without devicelock support the old code already checked
for a mode to set. However this meant the secondary part of the loop got never
reached. Now we check in one place. No more dead code. Also we cleaned-up a
minor mem leak at the same time, as the mode_to_set did not get cleaned-up in
case it matched the current mode.

Signed-off-by: Philippe De Swert <philippe.deswert@jollamobile.com>
  • Loading branch information
philippedeswert committed Aug 5, 2014
1 parent 642e806 commit 50711dd
Showing 1 changed file with 7 additions and 11 deletions.
18 changes: 7 additions & 11 deletions src/usb_moded.c
Expand Up @@ -236,17 +236,6 @@ void set_usb_connected_state(void)
}

mode_to_set = get_mode_setting();
if(!mode_to_set)
{
set_usb_mode(MODE_CHARGING);
return;
}

/* This is safe to do here as the starting condition is
MODE_UNDEFINED, and having a devicelock being activated when
a mode is set will not interrupt it */
if(!strcmp(mode_to_set, current_mode.mode))
return;

#ifdef MEEGOLOCK
/* check if we are allowed to export system contents 0 is unlocked */
Expand All @@ -258,6 +247,12 @@ void set_usb_connected_state(void)
if(mode_to_set)
#endif /* MEEGOLOCK */
{
/* This is safe to do here as the starting condition is
MODE_UNDEFINED, and having a devicelock being activated when
a mode is set will not interrupt it */
if(!strcmp(mode_to_set, current_mode.mode))
goto end;

#ifdef NOKIA
/* If we switch to another mode than the one that is still set before the
clean-up timeout expired we need to clean up */
Expand Down Expand Up @@ -292,6 +287,7 @@ void set_usb_connected_state(void)
*/
set_usb_mode(MODE_CHARGING);
}
end:
free((void *)mode_to_set);
}

Expand Down

0 comments on commit 50711dd

Please sign in to comment.