[FFmpeg-devel] [PATCH 9/9] Make avfilter_graph_parse() always return meaningful error codes.

Stefano Sabatini stefano.sabatini-lala
Fri Nov 5 18:20:33 CET 2010


---
 libavfilter/graphparser.c |   22 ++++++++++++----------
 1 files changed, 12 insertions(+), 10 deletions(-)

diff --git a/libavfilter/graphparser.c b/libavfilter/graphparser.c
index 251f697..60c40ac 100644
--- a/libavfilter/graphparser.c
+++ b/libavfilter/graphparser.c
@@ -319,7 +319,7 @@ int avfilter_graph_parse(AVFilterGraph *graph, const char *filters,
                          AVFilterInOut *open_inputs,
                          AVFilterInOut *open_outputs, AVClass *log_ctx)
 {
-    int index = 0;
+    int index = 0, ret;
     char chr = 0;
 
     AVFilterInOut *curr_inputs = NULL;
@@ -328,24 +328,24 @@ int avfilter_graph_parse(AVFilterGraph *graph, const char *filters,
         AVFilterContext *filter;
         filters += strspn(filters, WHITESPACES);
 
-        if (parse_inputs(&filters, &curr_inputs, &open_outputs, log_ctx) < 0)
+        if ((ret = parse_inputs(&filters, &curr_inputs, &open_outputs, log_ctx)) < 0)
             goto fail;
 
-        if (parse_filter(&filter, &filters, graph, index, log_ctx) < 0)
+        if ((ret = parse_filter(&filter, &filters, graph, index, log_ctx)) < 0)
             goto fail;
 
         if (filter->input_count == 1 && !curr_inputs && !index) {
             /* First input can be omitted if it is "[in]" */
             const char *tmp = "[in]";
-            if(parse_inputs(&tmp, &curr_inputs, &open_outputs, log_ctx) < 0)
+            if ((ret = parse_inputs(&tmp, &curr_inputs, &open_outputs, log_ctx)) < 0)
                 goto fail;
         }
 
-        if (link_filter_inouts(filter, &curr_inputs, &open_inputs, log_ctx) < 0)
+        if ((ret = link_filter_inouts(filter, &curr_inputs, &open_inputs, log_ctx)) < 0)
             goto fail;
 
-        if (parse_outputs(&filters, &curr_inputs, &open_inputs, &open_outputs,
-                         log_ctx) < 0)
+        if ((ret = parse_outputs(&filters, &curr_inputs, &open_inputs, &open_outputs,
+                                 log_ctx)) < 0)
             goto fail;
 
         filters += strspn(filters, WHITESPACES);
@@ -355,6 +355,7 @@ int avfilter_graph_parse(AVFilterGraph *graph, const char *filters,
             av_log(log_ctx, AV_LOG_ERROR,
                    "Could not find a output to link when parsing \"%s\"\n",
                    filters - 1);
+            ret = AVERROR(EINVAL);
             goto fail;
         }
         index++;
@@ -364,14 +365,15 @@ int avfilter_graph_parse(AVFilterGraph *graph, const char *filters,
         av_log(log_ctx, AV_LOG_ERROR,
                "Unable to parse graph description substring: \"%s\"\n",
                filters - 1);
+        ret = AVERROR(EINVAL);
         goto fail;
     }
 
     if (open_inputs && !strcmp(open_inputs->name, "out") && curr_inputs) {
         /* Last output can be omitted if it is "[out]" */
         const char *tmp = "[out]";
-        if (parse_outputs(&tmp, &curr_inputs, &open_inputs,
-                         &open_outputs, log_ctx) < 0)
+        if ((ret = parse_outputs(&tmp, &curr_inputs, &open_inputs, &open_outputs,
+                                 log_ctx)) < 0)
             goto fail;
     }
 
@@ -382,5 +384,5 @@ int avfilter_graph_parse(AVFilterGraph *graph, const char *filters,
     free_inout(open_inputs);
     free_inout(open_outputs);
     free_inout(curr_inputs);
-    return -1;
+    return ret;
 }
-- 
1.7.1




More information about the ffmpeg-devel mailing list