diff mbox series

[FFmpeg-devel,39/47] fftools/cmdutils: return AVERROR_EXIT for OPT_EXIT options instead of aborting()

Message ID 20230715104611.17902-39-anton@khirnov.net
State Accepted
Commit eda1fac27afdaaf646d9c84e6f2cea407764fbf2
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/cmdutils.c   | 2 +-
 fftools/ffmpeg.c     | 3 +++
 fftools/ffmpeg_opt.c | 2 +-
 fftools/ffplay.c     | 2 +-
 fftools/ffprobe.c    | 2 +-
 5 files changed, 7 insertions(+), 4 deletions(-)
diff mbox series

Patch

diff --git a/fftools/cmdutils.c b/fftools/cmdutils.c
index 9d9d8d44a6..f37b7d44d6 100644
--- a/fftools/cmdutils.c
+++ b/fftools/cmdutils.c
@@ -320,7 +320,7 @@  static int write_option(void *optctx, const OptionDef *po, const char *opt,
         }
     }
     if (po->flags & OPT_EXIT)
-        exit_program(0);
+        return AVERROR_EXIT;
 
     return 0;
 }
diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c
index 0c5e553c72..50d6658472 100644
--- a/fftools/ffmpeg.c
+++ b/fftools/ffmpeg.c
@@ -1371,6 +1371,9 @@  int main(int argc, char **argv)
           err_rate_exceeded   ?  69 : ret;
 
 finish:
+    if (ret == AVERROR_EXIT)
+        ret = 0;
+
     exit_program(ret);
     return ret;
 }
diff --git a/fftools/ffmpeg_opt.c b/fftools/ffmpeg_opt.c
index 14b292f202..700db706a1 100644
--- a/fftools/ffmpeg_opt.c
+++ b/fftools/ffmpeg_opt.c
@@ -1345,7 +1345,7 @@  int ffmpeg_parse_options(int argc, char **argv)
 
 fail:
     uninit_parse_context(&octx);
-    if (ret < 0) {
+    if (ret < 0 && ret != AVERROR_EXIT) {
         av_log(NULL, AV_LOG_FATAL, "Error %s: %s\n",
                errmsg ? errmsg : "", av_err2str(ret));
     }
diff --git a/fftools/ffplay.c b/fftools/ffplay.c
index df20c6a29d..a491fdd9e3 100644
--- a/fftools/ffplay.c
+++ b/fftools/ffplay.c
@@ -3657,7 +3657,7 @@  int main(int argc, char **argv)
 
     ret = parse_options(NULL, argc, argv, options, opt_input_file);
     if (ret < 0)
-        exit(1);
+        exit(ret == AVERROR_EXIT ? 0 : 1);
 
     if (!input_filename) {
         show_usage();
diff --git a/fftools/ffprobe.c b/fftools/ffprobe.c
index da8fc89830..c83d20995e 100644
--- a/fftools/ffprobe.c
+++ b/fftools/ffprobe.c
@@ -4129,7 +4129,7 @@  int main(int argc, char **argv)
     show_banner(argc, argv, options);
     ret = parse_options(NULL, argc, argv, options, opt_input_file);
     if (ret < 0)
-        exit_program(1);
+        exit_program(ret == AVERROR_EXIT ? 0 : 1);
 
     if (do_show_log)
         av_log_set_callback(log_callback);