[FFmpeg-devel] [RFC]lavu/timecode: Increase AV_TIMECODE_STR_SIZE.
Carl Eugen Hoyos
cehoyos at ag.or.at
Fri May 5 02:27:56 EEST 2017
Hi!
Attached patch is one possibility to fix the following warning with gcc 7:
libavutil/timecode.c: In function ‘av_timecode_make_string’:
libavutil/timecode.c:103:60: warning: ‘%02d’ directive output may be truncated
writing between 2 and 10 bytes into a region of size between 0 and 7
[-Wformat-truncation=]
snprintf(buf, AV_TIMECODE_STR_SIZE, "%s%02d:%02d:%02d%c%02d",
^~~~
libavutil/timecode.c:103:41: note: directive argument in the range [0,
2147483647]
snprintf(buf, AV_TIMECODE_STR_SIZE, "%s%02d:%02d:%02d%c%02d",
^~~~~~~~~~~~~~~~~~~~~~~~
libavutil/timecode.c:103:5: note: ‘snprintf’ output between 12 and 32 bytes
into a destination of size 16
snprintf(buf, AV_TIMECODE_STR_SIZE, "%s%02d:%02d:%02d%c%02d",
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
neg ? "-" : "",
~~~~~~~~~~~~~~~
hh, mm, ss, drop ? ';' : ':', ff);
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Several similar warnings are printed, an alternative is to disable the
warning.
The warning seemed wrong on first sight but may actually be correct, we
accept invalid fps for timecode.
Carl Eugen
-------------- next part --------------
From 8906d9b41b5576ddc0bc5f79f1192001825b89c7 Mon Sep 17 00:00:00 2001
From: Carl Eugen Hoyos <cehoyos at ag.or.at>
Date: Fri, 5 May 2017 01:23:24 +0200
Subject: [PATCH] lavu/timecode: Increase AV_TIMECODE_STR_SIZE.
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Fixes the following warning:
libavutil/timecode.c:103:60: warning: ���%02d��� directive output may be truncated writing between 2 and 10 bytes into a region of size between 0 and 7
---
libavutil/timecode.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/libavutil/timecode.h b/libavutil/timecode.h
index 56e3975..37c1361 100644
--- a/libavutil/timecode.h
+++ b/libavutil/timecode.h
@@ -30,7 +30,7 @@
#include <stdint.h>
#include "rational.h"
-#define AV_TIMECODE_STR_SIZE 16
+#define AV_TIMECODE_STR_SIZE 23
enum AVTimecodeFlag {
AV_TIMECODE_FLAG_DROPFRAME = 1<<0, ///< timecode is drop frame
--
1.7.10.4
More information about the ffmpeg-devel
mailing list