Commit 50711dde authored by Philippe De Swert's avatar Philippe De Swert

[usb setting logic] Do not check for mode_to_set_twice Fixes: CID#1230272

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: default avatarPhilippe De Swert <philippe.deswert@jollamobile.com>
parent 642e8062
......@@ -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 */
......@@ -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 */
......@@ -292,6 +287,7 @@ void set_usb_connected_state(void)
*/
set_usb_mode(MODE_CHARGING);
}
end:
free((void *)mode_to_set);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment