[vlc-devel] [PATCH] record: remove a few relocations

Rafaël Carré funman at videolan.org
Tue Sep 4 15:12:19 CEST 2012


They were spotted by ruby-elf's cowstats (gem install ruby-elf)
---
One problem with this change is that overflowing the table only 
produces a warning in gcc, which can't be turned into an error.
See http://gcc.gnu.org/bugzilla/show_bug.cgi?id=37866

clang 3.0 doesn't even produce a warning.

Some entries of those tables are commented out but would produce 
such an overflow if uncommented so it would be easy to overlook such 
a change.

 modules/stream_out/record.c |   13 +++++--------
 1 file changed, 5 insertions(+), 8 deletions(-)

diff --git a/modules/stream_out/record.c b/modules/stream_out/record.c
index de6d32e..99fac51 100644
--- a/modules/stream_out/record.c
+++ b/modules/stream_out/record.c
@@ -256,8 +256,8 @@ static int Send( sout_stream_t *p_stream, sout_stream_id_t *id,
  *****************************************************************************/
 typedef struct
 {
-    const char  *psz_muxer;
-    const char  *psz_extension;
+    const char  psz_muxer[4];
+    const char  psz_extension[4];
     int         i_es_max;
     vlc_fourcc_t codec[128];
 } muxer_properties_t;
@@ -305,8 +305,6 @@ static const muxer_properties_t p_muxers[] = {
 
     M( "mkv", "mkv", 32,        VLC_CODEC_H264, VLC_CODEC_VP8, VLC_CODEC_MP4V,
                                 VLC_CODEC_A52,  VLC_CODEC_MP4A, VLC_CODEC_VORBIS, VLC_CODEC_FLAC ),
-
-    M( NULL, NULL, 0, 0 )
 };
 #undef M
 
@@ -386,7 +384,7 @@ static void OutputStart( sout_stream_t *p_stream )
      * TODO we could insert transcode in a few cases like
      * s16l <-> s16b
      */
-    for( int i = 0; p_muxers[i].psz_muxer != NULL; i++ )
+    for( unsigned i = 0; i < sizeof(p_muxers) / sizeof(*p_muxers); i++ )
     {
         bool b_ok;
         if( p_sys->i_id > p_muxers[i].i_es_max )
@@ -421,7 +419,7 @@ static void OutputStart( sout_stream_t *p_stream )
      * keeps most of our stream */
     if( !psz_muxer || !psz_extension )
     {
-        static const char *ppsz_muxers[][2] = {
+        static const char ppsz_muxers[][2][4] = {
             { "avi", "avi" }, { "mp4", "mp4" }, { "ogg", "ogg" },
             { "asf", "asf" }, {  "ts",  "ts" }, {  "ps", "mpg" },
             { "mkv", "mkv" },
@@ -434,13 +432,12 @@ static void OutputStart( sout_stream_t *p_stream )
             { "avformat{mux=nsv}", "nsv" },
             { "avformat{mux=flv}", "flv" },
 #endif
-            { NULL, NULL }
         };
         int i_best = 0;
         int i_best_es = 0;
 
         msg_Warn( p_stream, "failed to find an adequate muxer, probing muxers" );
-        for( int i = 0; ppsz_muxers[i][0] != NULL; i++ )
+        for( unsigned i = 0; i < sizeof(ppsz_muxers) / sizeof(*ppsz_muxers); i++ )
         {
             char *psz_file;
             int i_es;
-- 
1.7.10.4



More information about the vlc-devel mailing list