diff mbox series

[FFmpeg-devel,37/47] fftools/ffmpeg_opt: consolidate printing errors in ffmpeg_parse_options()

Message ID 20230715104611.17902-37-anton@khirnov.net
State Accepted
Commit c56fabde27dad6aeb12313be854e21a4aca01e5a
Headers show
Series [FFmpeg-devel,01/47] fftools/ffmpeg_mux_init: handle pixel format endianness | expand

Checks

Context Check Description
yinshiyou/make_loongarch64 success Make finished
yinshiyou/make_fate_loongarch64 success Make fate finished
andriy/make_x86 success Make finished
andriy/make_fate_x86 success Make fate finished

Commit Message

Anton Khirnov July 15, 2023, 10:46 a.m. UTC
---
 fftools/ffmpeg_opt.c | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)
diff mbox series

Patch

diff --git a/fftools/ffmpeg_opt.c b/fftools/ffmpeg_opt.c
index 44a6b49ed7..14b292f202 100644
--- a/fftools/ffmpeg_opt.c
+++ b/fftools/ffmpeg_opt.c
@@ -1289,6 +1289,7 @@  static int open_files(OptionGroupList *l, const char *inout,
 int ffmpeg_parse_options(int argc, char **argv)
 {
     OptionParseContext octx;
+    const char *errmsg = NULL;
     int ret;
 
     memset(&octx, 0, sizeof(octx));
@@ -1297,14 +1298,14 @@  int ffmpeg_parse_options(int argc, char **argv)
     ret = split_commandline(&octx, argc, argv, options, groups,
                             FF_ARRAY_ELEMS(groups));
     if (ret < 0) {
-        av_log(NULL, AV_LOG_FATAL, "Error splitting the argument list: ");
+        errmsg = "splitting the argument list";
         goto fail;
     }
 
     /* apply global options */
     ret = parse_optgroup(NULL, &octx.global_opts);
     if (ret < 0) {
-        av_log(NULL, AV_LOG_FATAL, "Error parsing global options: ");
+        errmsg = "parsing global options";
         goto fail;
     }
 
@@ -1314,21 +1315,21 @@  int ffmpeg_parse_options(int argc, char **argv)
     /* open input files */
     ret = open_files(&octx.groups[GROUP_INFILE], "input", ifile_open);
     if (ret < 0) {
-        av_log(NULL, AV_LOG_FATAL, "Error opening input files: ");
+        errmsg = "opening input files";
         goto fail;
     }
 
     /* create the complex filtergraphs */
     ret = init_complex_filters();
     if (ret < 0) {
-        av_log(NULL, AV_LOG_FATAL, "Error initializing complex filters.\n");
+        errmsg = "initializing complex filters";
         goto fail;
     }
 
     /* open output files */
     ret = open_files(&octx.groups[GROUP_OUTFILE], "output", of_open);
     if (ret < 0) {
-        av_log(NULL, AV_LOG_FATAL, "Error opening output files: ");
+        errmsg = "opening output files";
         goto fail;
     }
 
@@ -1345,7 +1346,8 @@  int ffmpeg_parse_options(int argc, char **argv)
 fail:
     uninit_parse_context(&octx);
     if (ret < 0) {
-        av_log(NULL, AV_LOG_FATAL, "%s\n", av_err2str(ret));
+        av_log(NULL, AV_LOG_FATAL, "Error %s: %s\n",
+               errmsg ? errmsg : "", av_err2str(ret));
     }
     return ret;
 }