Skip to content

Commit

Permalink
* doxygen tag fix
Browse files Browse the repository at this point in the history
* More careful use of online/present for udev monitor
* Be more careful reading config file to avoid crashes
Signed-off-by: Philippe De Swert <phdeswer@lumi.maa>
  • Loading branch information
Philippe De Swert committed Apr 7, 2011
1 parent 72d1af6 commit 44d0373
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 3 deletions.
10 changes: 10 additions & 0 deletions src/usb_moded-config.c
Expand Up @@ -48,6 +48,8 @@ const char *find_mounts(void)
return(ret);
}
keys = g_key_file_get_keys (settingsfile, FS_MOUNT_ENTRY, NULL, NULL);
if(keys == NULL)
return ret;
while (*keys != NULL)
{
if(!strcmp(*keys, FS_MOUNT_KEY))
Expand Down Expand Up @@ -81,6 +83,8 @@ int find_sync(void)
return(ret);
}
keys = g_key_file_get_keys (settingsfile, FS_SYNC_ENTRY, NULL, NULL);
if(keys == NULL)
return ret;
while (*keys != NULL)
{
if(!strcmp(*keys, FS_SYNC_KEY))
Expand Down Expand Up @@ -110,6 +114,8 @@ const char * find_alt_mount(void)
return(ret);
}
keys = g_key_file_get_keys (settingsfile, ALT_MOUNT_ENTRY, NULL, NULL);
if(keys == NULL)
return ret;
while (*keys != NULL)
{
if(!strcmp(*keys, ALT_MOUNT_KEY))
Expand Down Expand Up @@ -144,6 +150,8 @@ const char * find_udev_path(void)
return(ret);
}
keys = g_key_file_get_keys (settingsfile, UDEV_PATH_ENTRY, NULL, NULL);
if(keys == NULL)
return ret;
while (*keys != NULL)
{
if(!strcmp(*keys, UDEV_PATH_KEY))
Expand Down Expand Up @@ -179,6 +187,8 @@ const char * find_cdrom_path(void)
return(ret);
}
keys = g_key_file_get_keys (settingsfile, CDROM_PATH_ENTRY, NULL, NULL);
if(keys == NULL)
return ret;
while (*keys != NULL)
{
if(!strcmp(*keys, CDROM_PATH_KEY))
Expand Down
2 changes: 1 addition & 1 deletion src/usb_moded-dbus.c
Expand Up @@ -231,7 +231,7 @@ void usb_moded_dbus_cleanup(void)
* Send regular usb_moded state signal
*
* @return 1 on success, 0 on failure
* @args the signal name
* @param state_ind the signal name
*
*/
int usb_moded_send_signal(const char *state_ind)
Expand Down
13 changes: 11 additions & 2 deletions src/usb_moded-udev.c
Expand Up @@ -67,15 +67,24 @@ gboolean hwal_init(void)

gpointer monitor_udev(gpointer data)
{
const char *tmp;

while(1)
{
dev = udev_monitor_receive_device (mon);
if (dev)
{
if(!strcmp(udev_device_get_action(dev), "change"))
{
if(!strcmp(udev_device_get_property_value(dev, "POWER_SUPPLY_PRESENT"), "1") ||
!strcmp(udev_device_get_property_value(dev, "POWER_SUPPLY_ONLINE"), "1"))
tmp = udev_device_get_property_value(dev, "POWER_SUPPLY_PRESENT");
if(!tmp)
tmp = udev_device_get_property_value(dev, "POWER_SUPPLY_ONLINE");
if(!tmp)
{
log_err("No usable power supply indicator\n");
exit(1);
}
if(!strcmp(tmp, "1"))
{
log_debug("UDEV:power supply present\n");
/* POWER_SUPPLY_TYPE is USB if usb cable is connected, or USB_DCP for charger */
Expand Down

0 comments on commit 44d0373

Please sign in to comment.