[FFmpeg-devel] [PATCH] avutil/error: uniformize errbuf size by macro
Li Kai
wolfleekay at gmail.com
Mon Jul 10 11:07:18 EEST 2023
Signed-off-by: likai <wolfleekay at gmail.com>
---
libavdevice/bktr.c | 2 +-
libavdevice/jack.c | 2 +-
libavformat/crypto.c | 2 +-
libavformat/network.c | 6 +++---
libavutil/file.c | 2 +-
tools/aviocat.c | 2 +-
tools/ismindex.c | 4 ++--
tools/sidxindex.c | 2 +-
8 files changed, 11 insertions(+), 11 deletions(-)
diff --git a/libavdevice/bktr.c b/libavdevice/bktr.c
index 196637852f..a24b80a4bb 100644
--- a/libavdevice/bktr.c
+++ b/libavdevice/bktr.c
@@ -106,7 +106,7 @@ static av_cold int bktr_init(const char
*video_device, int width, int height,
int c;
struct sigaction act, old;
int ret;
- char errbuf[128];
+ char errbuf[AV_ERROR_MAX_STRING_SIZE];
if (idev < 0 || idev > 4)
{
diff --git a/libavdevice/jack.c b/libavdevice/jack.c
index db056d824f..8150a91f13 100644
--- a/libavdevice/jack.c
+++ b/libavdevice/jack.c
@@ -289,7 +289,7 @@ static int audio_read_packet(AVFormatContext
*context, AVPacket *pkt)
av_log(context, AV_LOG_ERROR,
"Input error: timed out when waiting for JACK
process callback output\n");
} else {
- char errbuf[128];
+ char errbuf[AV_ERROR_MAX_STRING_SIZE];
int ret = AVERROR(errno);
av_strerror(ret, errbuf, sizeof(errbuf));
av_log(context, AV_LOG_ERROR, "Error while waiting for
audio packet: %s\n",
diff --git a/libavformat/crypto.c b/libavformat/crypto.c
index 1d4514e0f2..41391c7a16 100644
--- a/libavformat/crypto.c
+++ b/libavformat/crypto.c
@@ -314,7 +314,7 @@ static int64_t crypto_seek(URLContext *h, int64_t
pos, int whence)
// if we did not get all the bytes
if (len != 0) {
- char errbuf[100] = "unknown error";
+ char errbuf[AV_ERROR_MAX_STRING_SIZE] = "unknown error";
av_strerror(res, errbuf, sizeof(errbuf));
av_log(h, AV_LOG_ERROR,
"Crypto: discard read did not get all the bytes (%d
remain) - read returned (%d)-%s\n",
diff --git a/libavformat/network.c b/libavformat/network.c
index f752efc411..d02ec65b8a 100644
--- a/libavformat/network.c
+++ b/libavformat/network.c
@@ -282,7 +282,7 @@ int ff_listen_connect(int fd, const struct sockaddr
*addr,
if (getsockopt (fd, SOL_SOCKET, SO_ERROR, &ret, &optlen))
ret = AVUNERROR(ff_neterrno());
if (ret != 0) {
- char errbuf[100];
+ char errbuf[AV_ERROR_MAX_STRING_SIZE];
ret = AVERROR(ret);
av_strerror(ret, errbuf, sizeof(errbuf));
if (will_try_next)
@@ -416,7 +416,7 @@ int ff_connect_parallel(struct addrinfo *addrs, int
timeout_ms_per_address,
int64_t next_attempt_us = av_gettime_relative(), next_deadline_us;
int last_err = AVERROR(EIO);
socklen_t optlen;
- char errbuf[100], hostbuf[100], portbuf[20];
+ char errbuf[AV_ERROR_MAX_STRING_SIZE], hostbuf[100], portbuf[20];
if (parallel > FF_ARRAY_ELEMS(attempts))
parallel = FF_ARRAY_ELEMS(attempts);
@@ -586,7 +586,7 @@ int ff_http_match_no_proxy(const char *no_proxy,
const char *hostname)
void ff_log_net_error(void *ctx, int level, const char* prefix)
{
- char errbuf[100];
+ char errbuf[AV_ERROR_MAX_STRING_SIZE];
av_strerror(ff_neterrno(), errbuf, sizeof(errbuf));
av_log(ctx, level, "%s: %s\n", prefix, errbuf);
}
diff --git a/libavutil/file.c b/libavutil/file.c
index 6a2f3aa91c..0477b821f0 100644
--- a/libavutil/file.c
+++ b/libavutil/file.c
@@ -59,7 +59,7 @@ int av_file_map(const char *filename, uint8_t
**bufptr, size_t *size,
struct stat st;
av_unused void *ptr;
off_t off_size;
- char errbuf[128];
+ char errbuf[AV_ERROR_MAX_STRING_SIZE];
*bufptr = NULL;
*size = 0;
diff --git a/tools/aviocat.c b/tools/aviocat.c
index 816ab700ef..969a883011 100644
--- a/tools/aviocat.c
+++ b/tools/aviocat.c
@@ -37,7 +37,7 @@ int main(int argc, char **argv)
const char *input_url = NULL, *output_url = NULL;
int64_t stream_pos = 0;
int64_t start_time;
- char errbuf[50];
+ char errbuf[AV_ERROR_MAX_STRING_SIZE];
AVIOContext *input, *output;
AVDictionary *in_opts = NULL;
AVDictionary *out_opts = NULL;
diff --git a/tools/ismindex.c b/tools/ismindex.c
index 39b5378190..7778c92797 100644
--- a/tools/ismindex.c
+++ b/tools/ismindex.c
@@ -148,7 +148,7 @@ static int write_fragment(const char *filename,
AVIOContext *in)
int ret;
if ((ret = avio_open2(&out, filename, AVIO_FLAG_WRITE, NULL,
NULL)) < 0) {
- char errbuf[100];
+ char errbuf[AV_ERROR_MAX_STRING_SIZE];
av_strerror(ret, errbuf, sizeof(errbuf));
fprintf(stderr, "Unable to open %s: %s\n", filename, errbuf);
return ret;
@@ -499,7 +499,7 @@ static int handle_file(struct Tracks *tracks, const
char *file, int split,
{
AVFormatContext *ctx = NULL;
int err = 0, i, orig_tracks = tracks->nb_tracks;
- char errbuf[50], *ptr;
+ char errbuf[AV_ERROR_MAX_STRING_SIZE], *ptr;
struct Track *track;
err = avformat_open_input(&ctx, file, NULL, NULL);
diff --git a/tools/sidxindex.c b/tools/sidxindex.c
index 88aea6bcb9..bd02f74a96 100644
--- a/tools/sidxindex.c
+++ b/tools/sidxindex.c
@@ -118,7 +118,7 @@ static int handle_file(struct Tracks *tracks, const
char *file)
{
AVFormatContext *ctx = NULL;
int err = 0, i, orig_tracks = tracks->nb_tracks;
- char errbuf[50], *ptr;
+ char errbuf[AV_ERROR_MAX_STRING_SIZE], *ptr;
struct Track *track;
err = avformat_open_input(&ctx, file, NULL, NULL);
--
2.30.1 (Apple Git-130)
More information about the ffmpeg-devel
mailing list