[vlc-devel] commit: udev: fix obvious faults in previous commit, refactor ( Rémi Denis-Courmont )
git version control
git at videolan.org
Mon Feb 15 21:57:37 CET 2010
vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Mon Feb 15 22:56:36 2010 +0200| [7c1437b3d69d68ba496c2cd23c8126bfde361237] | committer: Rémi Denis-Courmont
udev: fix obvious faults in previous commit, refactor
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=7c1437b3d69d68ba496c2cd23c8126bfde361237
---
modules/services_discovery/udev.c | 49 +++++++++++++++++++++----------------
1 files changed, 28 insertions(+), 21 deletions(-)
diff --git a/modules/services_discovery/udev.c b/modules/services_discovery/udev.c
index 93861ef..32020cd 100644
--- a/modules/services_discovery/udev.c
+++ b/modules/services_discovery/udev.c
@@ -560,32 +560,39 @@ static char *disc_get_name (struct udev_device *dev)
static char *disc_get_cat (struct udev_device *dev)
{
- const char *val;
- const char *name;
- int i_val;
- const char *cat = _("Unknown Type");
+ struct udev_list_entry *list, *entry;
- struct udev_list_entry *prop_list
- = udev_device_get_properties_list_entry( dev );
+ list = udev_device_get_properties_list_entry (dev);
+ if (unlikely(list == NULL))
+ return NULL;
- udev_list_entry_foreach( prop_list, prop_list )
+ const char *cat = NULL;
+ udev_list_entry_foreach (entry, list)
{
- name = udev_list_entry_get_name ( prop_list );
- i_val = atoi( udev_list_entry_get_value ( prop_list ) );
- if( !i_val ) continue;
- if( strncmp( name, "ID_CDROM_MEDIA_CD", strlen( "ID_CDROM_MEDIA_CD" ) ) )
- cat = _("CD");
- else if( !strncmp( name, "ID_CDROM_MEDIA_DVD", strlen( "ID_CDROM_MEDIA_DVD" ) ) )
- cat = _("DVD");
- else if( !strncmp( name, "ID_CDROM_MEDIA_BD", strlen( "ID_CDROM_MEDIA_BD" ) ) )
- cat = _("Blu-Ray");
- else if( !strncmp( name, "ID_CDROM_MEDIA_HDDVD", strlen( "ID_CDROM_MEDIA_HDDVD" ) ) )
- cat = _("HD DVD");
- }
+ const char *name = udev_list_entry_get_name (entry);
- free( prop_list );
+ if (strncmp (name, "ID_CDROM_MEDIA_", 15))
+ continue;
+ if (!atoi (udev_list_entry_get_value (entry)))
+ continue;
+ name += 15;
+
+ if (!strncmp (name, "CD", 2))
+ cat = N_("CD");
+ else if (!strncmp (name, "DVD", 3))
+ cat = N_("DVD");
+ else if (!strncmp (name, "BD", 2))
+ cat = N_("Blu-Ray");
+ else if (!strncmp (name, "HDDVD", 5))
+ cat = N_("HD DVD");
+
+ if (cat != NULL)
+ break;
+ }
- return strdup (cat);
+ if (cat == NULL)
+ cat = N_("Unknown type");
+ return strdup (vlc_gettext (cat));
}
int OpenDisc (vlc_object_t *obj)
More information about the vlc-devel
mailing list