[vlc-commits] item: fix and check table ordering
Rémi Denis-Courmont
git at videolan.org
Tue Apr 26 21:33:25 CEST 2016
vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Tue Apr 26 22:33:10 2016 +0300| [05e8bc777674c9d4c17527c1f08d973bc0a239d2] | committer: Rémi Denis-Courmont
item: fix and check table ordering
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=05e8bc777674c9d4c17527c1f08d973bc0a239d2
---
src/input/item.c | 34 ++++++++++++++++------------------
1 file changed, 16 insertions(+), 18 deletions(-)
diff --git a/src/input/item.c b/src/input/item.c
index 3b9016b..dd8622b 100644
--- a/src/input/item.c
+++ b/src/input/item.c
@@ -1040,7 +1040,6 @@ static int GuessType( const input_item_t *p_item, bool *p_net )
{ "dir", ITEM_TYPE_DIRECTORY, false },
{ "dshow", ITEM_TYPE_CARD, false },
{ "dtv", ITEM_TYPE_CARD, false },
- { "dv", ITEM_TYPE_CARD, false },
{ "dvb", ITEM_TYPE_CARD, false },
{ "dvd", ITEM_TYPE_DISC, false },
{ "eyetv", ITEM_TYPE_CARD, false },
@@ -1088,26 +1087,25 @@ static int GuessType( const input_item_t *p_item, bool *p_net )
{ "wasapi", ITEM_TYPE_CARD, false },
{ "window", ITEM_TYPE_CARD, false },
};
- int i_item_type = ITEM_TYPE_UNKNOWN;
+
+#ifndef NDEBUG
+ for( size_t i = 1; i < ARRAY_SIZE( tab ); i++ )
+ assert( typecmp( tab + i, tab + i - 1 ) > 0 );
+#endif
+
*p_net = false;
- if( !strstr( p_item->psz_uri, "://" ) )
- {
- i_item_type = ITEM_TYPE_FILE;
- }
- else
- {
- const struct item_type_entry *e =
- bsearch( p_item->psz_uri, tab, sizeof( tab ) / sizeof( tab[0] ),
- sizeof( tab[0] ), typecmp );
- if( e )
- {
- *p_net = e->b_net;
- i_item_type = e->i_type;
- }
- }
+ if( strstr( p_item->psz_uri, "://" ) == NULL )
+ return ITEM_TYPE_UNKNOWN; /* invalid URI */
+
+ const struct item_type_entry *e =
+ bsearch( p_item->psz_uri, tab, ARRAY_SIZE( tab ),
+ sizeof( tab[0] ), typecmp );
+ if( e == NULL )
+ return ITEM_TYPE_UNKNOWN;
- return i_item_type;
+ *p_net = e->b_net;
+ return e->i_type;
}
input_item_node_t *input_item_node_Create( input_item_t *p_input )
More information about the vlc-commits
mailing list