diff mbox

[FFmpeg-devel] lavf/matroskadec: Simplify string length calculation slightly

Message ID CAB0OVGqezZbHvsvi+G7qRKxK-v8mACyfV9gJRrBAgtjZ-2WXRA@mail.gmail.com
State Accepted
Headers show

Commit Message

Carl Eugen Hoyos Sept. 19, 2018, 5:18 p.m. UTC
Hi!

Attached patch removes useless sizeof's, we require sizeof(char)==1 afaict.

Please comment, Carl Eugen

Comments

Carl Eugen Hoyos Sept. 26, 2018, 9:30 p.m. UTC | #1
2018-09-19 19:18 GMT+02:00, Carl Eugen Hoyos <ceffmpeg@gmail.com>:

> Attached patch removes useless sizeof's, we require sizeof(char)==1 afaict.

I will push this if there are no objections.

Carl Eugen
Carl Eugen Hoyos Oct. 19, 2018, 6:37 p.m. UTC | #2
2018-09-26 23:30 GMT+02:00, Carl Eugen Hoyos <ceffmpeg@gmail.com>:
> 2018-09-19 19:18 GMT+02:00, Carl Eugen Hoyos <ceffmpeg@gmail.com>:
>
>> Attached patch removes useless sizeof's, we require sizeof(char)==1
>> afaict.
>
> I will push this if there are no objections.

Patch applied.

Carl Eugen
diff mbox

Patch

From 8384c2097976ce8546d1b73ce822851a6f608813 Mon Sep 17 00:00:00 2001
From: Carl Eugen Hoyos <ceffmpeg@gmail.com>
Date: Mon, 3 Sep 2018 14:18:02 +0200
Subject: [PATCH] lavf/matroskadec: Simplify string length calculation.

FFmpeg relies on sizeof(char) == 1.
---
 libavformat/matroskadec.c |    6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c
index e679398..2daa1db 100644
--- a/libavformat/matroskadec.c
+++ b/libavformat/matroskadec.c
@@ -3931,11 +3931,11 @@  static int webm_dash_manifest_cues(AVFormatContext *s, int64_t init_range)
 
     // store cue point timestamps as a comma separated list for checking subsegment alignment in
     // the muxer. assumes that each timestamp cannot be more than 20 characters long.
-    buf = av_malloc_array(s->streams[0]->nb_index_entries, 20 * sizeof(char));
+    buf = av_malloc_array(s->streams[0]->nb_index_entries, 20);
     if (!buf) return -1;
     strcpy(buf, "");
     for (i = 0; i < s->streams[0]->nb_index_entries; i++) {
-        int ret = snprintf(buf + end, 20 * sizeof(char),
+        int ret = snprintf(buf + end, 20,
                            "%" PRId64, s->streams[0]->index_entries[i].timestamp);
         if (ret <= 0 || (ret == 20 && i ==  s->streams[0]->nb_index_entries - 1)) {
             av_log(s, AV_LOG_ERROR, "timestamp too long.\n");
@@ -3944,7 +3944,7 @@  static int webm_dash_manifest_cues(AVFormatContext *s, int64_t init_range)
         }
         end += ret;
         if (i != s->streams[0]->nb_index_entries - 1) {
-            strncat(buf, ",", sizeof(char));
+            strncat(buf, ",", 1);
             end++;
         }
     }
-- 
1.7.10.4