[vlc-commits] stream: STREAM_IS_DIRECTORY can actually fail, fix accordingly

Rémi Denis-Courmont git at videolan.org
Wed Sep 2 21:54:14 CEST 2015


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Wed Sep  2 20:21:46 2015 +0300| [efe323f85f98689ba75f1514fc7d845eb20a9521] | committer: Rémi Denis-Courmont

stream: STREAM_IS_DIRECTORY can actually fail, fix accordingly

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=efe323f85f98689ba75f1514fc7d845eb20a9521
---

 include/vlc_stream.h               |    2 +-
 modules/demux/playlist/directory.c |   10 +++-------
 modules/demux/playlist/playlist.h  |    9 +++++----
 3 files changed, 9 insertions(+), 12 deletions(-)

diff --git a/include/vlc_stream.h b/include/vlc_stream.h
index 597b29c..1eb748b 100644
--- a/include/vlc_stream.h
+++ b/include/vlc_stream.h
@@ -83,7 +83,7 @@ enum stream_query_e
     STREAM_CAN_CONTROL_PACE,    /**< arg1= bool *   res=cannot fail*/
     /* */
     STREAM_GET_SIZE=6,          /**< arg1= uint64_t *     res=can fail */
-    STREAM_IS_DIRECTORY,        /**< arg1= bool *, arg2= bool *, arg3=bool *, res=cannot fail*/
+    STREAM_IS_DIRECTORY,        /**< arg1= bool *, arg2= bool *, arg3=bool *, res=can fail*/
 
     /* */
     STREAM_GET_PTS_DELAY = 0x101,/**< arg1= int64_t* res=cannot fail */
diff --git a/modules/demux/playlist/directory.c b/modules/demux/playlist/directory.c
index 5c835bb..6e394dc 100644
--- a/modules/demux/playlist/directory.c
+++ b/modules/demux/playlist/directory.c
@@ -48,14 +48,10 @@ static int Demux( demux_t *p_demux );
 int Import_Dir ( vlc_object_t *p_this)
 {
     demux_t  *p_demux = (demux_t *)p_this;
+    bool b_is_dir, b_dir_sorted, b_dir_can_loop;
 
-    bool b_is_dir = false;
-    bool b_dir_sorted = false;
-    bool b_dir_can_loop = false;
-    int i_err = stream_Control( p_demux->s, STREAM_IS_DIRECTORY, &b_is_dir,
-                                &b_dir_sorted, &b_dir_can_loop );
-
-    if ( !( i_err == VLC_SUCCESS && b_is_dir ) )
+    if( stream_Control( p_demux->s, STREAM_IS_DIRECTORY, &b_is_dir,
+                        &b_dir_sorted, &b_dir_can_loop ) || !b_is_dir )
         return VLC_EGENERIC;
 
     STANDARD_DEMUX_INIT_MSG( "reading directory content" );
diff --git a/modules/demux/playlist/playlist.h b/modules/demux/playlist/playlist.h
index eb3a583..9bd9b1d 100644
--- a/modules/demux/playlist/playlist.h
+++ b/modules/demux/playlist/playlist.h
@@ -82,10 +82,11 @@ extern input_item_t * GetCurrentItem(demux_t *p_demux);
 
 bool CheckContentType( stream_t * p_stream, const char * psz_ctype );
 
-#define CHECK_FILE() do { \
-    bool b_is_dir = false; \
-    stream_Control( ((demux_t *)p_this)->s, STREAM_IS_DIRECTORY, &b_is_dir, NULL, NULL ); \
-    if( b_is_dir ) \
+#define CHECK_FILE() \
+do { \
+    bool b_is_dir; \
+    if( stream_Control( ((demux_t *)p_this)->s, STREAM_IS_DIRECTORY, \
+                        &b_is_dir, NULL, NULL ) == VLC_SUCCESS && b_is_dir ) \
         return VLC_EGENERIC; \
 } while(0)
 



More information about the vlc-commits mailing list