[FFmpeg-devel] [PATCH 3/3] Make opt_default(), return an error code rather than exit from the program.

Stefano Sabatini stefano.sabatini-lala
Sat Nov 6 15:02:57 CET 2010


This allows the program to nicely handle the error, for example
providing detailed error explanation to the user or cleaning up the
allocated resources of the program.
---
 cmdutils.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/cmdutils.c b/cmdutils.c
index 76bf736..d04acd5 100644
--- a/cmdutils.c
+++ b/cmdutils.c
@@ -237,7 +237,7 @@ int opt_default(const char *opt, const char *arg){
     }
     if (o && ret < 0) {
         fprintf(stderr, "Invalid value '%s' for option '%s'\n", arg, opt);
-        exit(1);
+        return AVERROR(EINVAL);
     }
     if (!o) {
         AVCodec *p = NULL;
@@ -248,7 +248,7 @@ int opt_default(const char *opt, const char *arg){
         }
         if(!p){
         fprintf(stderr, "Unrecognized option '%s'\n", opt);
-        exit(1);
+        return AVERROR(EINVAL);
         }
     }
 
-- 
1.7.1




More information about the ffmpeg-devel mailing list