[vlc-commits] demux:mkv: favor sizeof() on static strings to strlen()

Steve Lhomme git at videolan.org
Wed Mar 21 14:23:45 CET 2018


vlc | branch: master | Steve Lhomme <robux4 at ycbcr.xyz> | Wed Mar 21 14:10:49 2018 +0100| [d8aea6d3e187e3163007119487160dfa59f6eb05] | committer: Steve Lhomme

demux:mkv: favor sizeof() on static strings to strlen()

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

 modules/demux/mkv/matroska_segment_parse.cpp | 2 +-
 modules/demux/mkv/util.cpp                   | 8 ++++----
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/modules/demux/mkv/matroska_segment_parse.cpp b/modules/demux/mkv/matroska_segment_parse.cpp
index f3cf2c2c7d..752bf58bb4 100644
--- a/modules/demux/mkv/matroska_segment_parse.cpp
+++ b/modules/demux/mkv/matroska_segment_parse.cpp
@@ -1592,7 +1592,7 @@ bool matroska_segment_c::TrackInit( mkv_track_t * p_tk )
              *       we try to fix it. They fixed it in 16.0.0. */
             const char* app = vars.obj->psz_writing_application;
             if( p_extra && p_extra[0] == 0 && app != NULL &&
-                    strncmp(app, "mkvmerge", strlen("mkvmerge")) == 0 )
+                    strncmp(app, "mkvmerge", sizeof("mkvmerge")-1) == 0 )
             {
                 int major_version;
                 if( sscanf(app, "mkvmerge v%d.", &major_version) && major_version < 16 )
diff --git a/modules/demux/mkv/util.cpp b/modules/demux/mkv/util.cpp
index e01ab6db07..8c22cf7afe 100644
--- a/modules/demux/mkv/util.cpp
+++ b/modules/demux/mkv/util.cpp
@@ -386,10 +386,10 @@ block_t * packetize_wavpack( const mkv_track_t & tk, uint8_t * buffer, size_t  s
 
 void MkvTree_va( demux_t& demuxer, int i_level, const char* fmt, va_list args)
 {
-    static char const * indent = "|   ";
-    static char const * prefix = "+ ";
-    static int  const   indent_len = strlen( indent );
-    static int  const   prefix_len = strlen( prefix );
+    static char indent[] = "|   ";
+    static char prefix[] = "+ ";
+    static int  const   indent_len = sizeof( indent ) - 1;
+    static int  const   prefix_len = sizeof( prefix ) - 1;
 
     char   fixed_buffer[256] = {};
     size_t const  static_len = sizeof( fixed_buffer );



More information about the vlc-commits mailing list