[vlc-devel] commit: Do not use an enumeration for a bits field ( Rémi Denis-Courmont )

git version control git at videolan.org
Thu Feb 4 17:08:43 CET 2010


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Thu Feb  4 18:07:15 2010 +0200| [2d81d799164338f9120b6684510936299a023025] | committer: Rémi Denis-Courmont 

Do not use an enumeration for a bits field

This violates the C standard. Passing a value outside not part of the
enumeration is undefined. This obviously excludes bits fields.

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

 include/vlc/libvlc_media.h |    6 +++---
 src/control/media.c        |   15 ++++++---------
 2 files changed, 9 insertions(+), 12 deletions(-)

diff --git a/include/vlc/libvlc_media.h b/include/vlc/libvlc_media.h
index d7dd903..4239867 100644
--- a/include/vlc/libvlc_media.h
+++ b/include/vlc/libvlc_media.h
@@ -97,11 +97,11 @@ typedef enum libvlc_state_t
     libvlc_Error
 } libvlc_state_t;
 
-typedef enum libvlc_media_option_t
+enum
 {
     libvlc_media_option_trusted = 0x2,
     libvlc_media_option_unique = 0x100
-} libvlc_media_option_t;
+};
 
 typedef enum libvlc_es_type_t
 {
@@ -223,7 +223,7 @@ VLC_PUBLIC_API void libvlc_media_add_option(
 VLC_PUBLIC_API void libvlc_media_add_option_flag(
                                    libvlc_media_t * p_md,
                                    const char * ppsz_options,
-                                   libvlc_media_option_t i_flags );
+                                   unsigned i_flags );
 
 
 /**
diff --git a/src/control/media.c b/src/control/media.c
index e082e1a..2da4e60 100644
--- a/src/control/media.c
+++ b/src/control/media.c
@@ -348,24 +348,21 @@ libvlc_media_t * libvlc_media_new_as_node( libvlc_instance_t *p_instance,
  *
  * The options are detailled in vlc --long-help, for instance "--sout-all"
  **************************************************************************/
-void libvlc_media_add_option(
-                                   libvlc_media_t * p_md,
-                                   const char * psz_option )
+void libvlc_media_add_option( libvlc_media_t * p_md,
+                              const char * psz_option )
 {
-    input_item_AddOption( p_md->p_input_item, psz_option,
+    libvlc_media_add_option_flag( p_md, psz_option,
                           VLC_INPUT_OPTION_UNIQUE|VLC_INPUT_OPTION_TRUSTED );
 }
 
 /**************************************************************************
  * Same as libvlc_media_add_option but with configurable flags.
  **************************************************************************/
-void libvlc_media_add_option_flag(
-                                   libvlc_media_t * p_md,
+void libvlc_media_add_option_flag( libvlc_media_t * p_md,
                                    const char * ppsz_option,
-                                   libvlc_media_option_t i_flags )
+                                   unsigned i_flags )
 {
-    input_item_AddOption( p_md->p_input_item, ppsz_option,
-                          i_flags );
+    input_item_AddOption( p_md->p_input_item, ppsz_option, i_flags );
 }
 
 /**************************************************************************




More information about the vlc-devel mailing list