[vlc-devel] [PATCH 06/13] lib/media_list_path: narrow scope of iteration variables

Filip Roséen filip at atch.se
Wed Oct 12 20:08:05 CEST 2016


---
 lib/media_list_path.h | 23 ++++++++++-------------
 1 file changed, 10 insertions(+), 13 deletions(-)

diff --git a/lib/media_list_path.h b/lib/media_list_path.h
index 49eba08..add4f4c 100644
--- a/lib/media_list_path.h
+++ b/lib/media_list_path.h
@@ -38,8 +38,7 @@ static inline void libvlc_media_list_path_dump( const libvlc_media_list_path_t p
         return;
     }
 
-    int i;
-    for(i = 0; path[i] != -1; i++)
+    for(int i = 0; path[i] != -1; i++)
         printf("%s%d", i > 0 ? "/" : "", path[i]);
     printf("\n");
 }
@@ -118,9 +117,9 @@ static inline libvlc_media_list_path_t libvlc_media_list_path_copy( const libvlc
 static libvlc_media_list_path_t
 get_path_rec( const libvlc_media_list_path_t path, libvlc_media_list_t * p_current_mlist, libvlc_media_t * p_searched_md )
 {
-    int i, count;
-    count = libvlc_media_list_count( p_current_mlist );
-    for( i = 0; i < count; i++ )
+    int count = libvlc_media_list_count( p_current_mlist );
+
+    for( int i = 0; i < count; i++ )
     {
         libvlc_media_t * p_md = libvlc_media_list_item_at_index( p_current_mlist, i );
 
@@ -163,11 +162,10 @@ static libvlc_media_t *
 libvlc_media_list_item_at_path( libvlc_media_list_t * p_mlist, const libvlc_media_list_path_t path )
 {
     libvlc_media_list_t * p_current_mlist = p_mlist;
-    libvlc_media_t * p_md = NULL;
-    int i;
-    for( i = 0; path[i] != -1; i++ )
+
+    for( int i = 0; path[i] != -1; i++ )
     {
-        p_md = libvlc_media_list_item_at_index( p_current_mlist, path[i] );
+        libvlc_media_t* p_md = libvlc_media_list_item_at_index( p_current_mlist, path[i] );
 
         if( p_current_mlist != p_mlist )
             libvlc_media_list_release( p_current_mlist );
@@ -196,9 +194,8 @@ static libvlc_media_list_t *
 libvlc_media_list_parentlist_at_path( libvlc_media_list_t * p_mlist, const libvlc_media_list_path_t path )
 {
     libvlc_media_list_t * p_current_mlist = p_mlist;
-    libvlc_media_t * p_md = NULL;
-    int i;
-    for( i = 0; path[i] != -1; i++ )
+
+    for( int i = 0; path[i] != -1; i++ )
     {
         if( p_current_mlist != p_mlist )
             libvlc_media_list_release( p_current_mlist );
@@ -209,7 +206,7 @@ libvlc_media_list_parentlist_at_path( libvlc_media_list_t * p_mlist, const libvl
             return p_current_mlist;
         }
 
-        p_md = libvlc_media_list_item_at_index( p_current_mlist, path[i] );
+        libvlc_media_t* p_md = libvlc_media_list_item_at_index( p_current_mlist, path[i] );
 
         p_current_mlist = libvlc_media_subitems( p_md );
         libvlc_media_release( p_md );
-- 
2.10.0



More information about the vlc-devel mailing list