Skip to content

Commit

Permalink
More code clean-up and fixes
Browse files Browse the repository at this point in the history
Signed-off-by: Philippe De Swert <phdeswer@lumi.maa>
  • Loading branch information
Philippe De Swert committed Apr 20, 2011
1 parent d69981b commit 96b2617
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 29 deletions.
22 changes: 7 additions & 15 deletions src/usb_moded-appsync.c
Expand Up @@ -64,7 +64,6 @@ static struct list_elem *read_file(const gchar *filename)
GKeyFile *settingsfile;
gboolean test = FALSE;
gchar **keys;
const char *name_char, *launch_char;
struct list_elem *list_item = NULL;
gchar *full_filename = NULL;

Expand All @@ -84,26 +83,19 @@ static struct list_elem *read_file(const gchar *filename)
{
if(!strcmp(*keys, APP_INFO_NAME_KEY))
{
name_char = g_key_file_get_string(settingsfile, APP_INFO_ENTRY, *keys, NULL);
if(name_char)
{
list_item->name = g_strdup(name_char);
log_debug("Appname = %s\n", name_char);
}
list_item->name = g_key_file_get_string(settingsfile, APP_INFO_ENTRY, *keys, NULL);
log_debug("Appname = %s\n", list_item->name);
}
else if(!strcmp(*keys, APP_INFO_LAUNCH_KEY))
{
launch_char = g_key_file_get_string(settingsfile, APP_INFO_ENTRY, *keys, NULL);
if(launch_char)
{
list_item->launch = g_strdup(launch_char);
log_debug("launch path = %s\n", launch_char);
}
list_item->launch = g_key_file_get_string(settingsfile, APP_INFO_ENTRY, *keys, NULL);
log_debug("launch path = %s\n", list_item->launch);
}
keys++;
}
g_strfreev(keys);
g_key_file_free(settingsfile);
if(launch_char == NULL || name_char == NULL)
if(list_item->launch == NULL || list_item->name == NULL)
{
/* free list_item as it will not be used */
free(list_item);
Expand Down Expand Up @@ -142,7 +134,7 @@ int activate_sync(GList *list)
struct list_elem *data = list_iter->data;
log_debug("launching app %s\n", data->launch);
usb_moded_dbus_app_launch(data->launch);
list_iter = g_list_next(list_iter);
list_iter = g_list_next(list_iter);
}
while(list_iter != NULL);

Expand Down
2 changes: 1 addition & 1 deletion src/usb_moded-modesetting.c
Expand Up @@ -261,7 +261,7 @@ int usb_moded_mode_cleanup(const char *module)
}
}

sprintf(command2, "echo "" > /sys/devices/platform/musb_hdrc/gadget/gadget-lun%d/file", i);
sprintf(command2, "echo \"\" > /sys/devices/platform/musb_hdrc/gadget/gadget-lun%d/file", i);
log_debug("usb lun = %s inactive\n", command2);
system(command2);
}
Expand Down
19 changes: 6 additions & 13 deletions src/usb_moded-udev.c
Expand Up @@ -57,26 +57,19 @@ gboolean hwal_init(void)
/* communicate failure, mainloop will exit and call appropriate clean-up */
return FALSE;
}
udev_monitor_filter_add_match_subsystem_devtype(mon, "power_supply", NULL);
// SP: this can fail - in theory at least
ret = udev_monitor_filter_add_match_subsystem_devtype(mon, "power_supply", NULL);
if(ret =! 0)
return FALSE;

udev_monitor_enable_receiving (mon);
// SP: this can fail - in theory at least
ret = udev_monitor_enable_receiving (mon);
if(ret =! 0)
return FALSE;

/* check if we are already connected */
udev_parse(dev);

iochannel = g_io_channel_unix_new(udev_monitor_get_fd(mon));
// SP: this can fail - in theory at least

/* default is UTF-8, set it to binary */
g_io_channel_set_encoding(iochannel, NULL, NULL);
/* set it to unbuffered, since we will be bypassing the GIOChannel for reads */
g_io_channel_set_buffered(iochannel, FALSE);
// SP: do these matter, we're not using g_io for reading?

watch_id = g_io_add_watch(iochannel, G_IO_IN, monitor_udev, NULL);
// SP: this can fail - in theory at least

/* everything went well */
return TRUE;
Expand Down

0 comments on commit 96b2617

Please sign in to comment.