[FFmpeg-devel] [PATCHv2 3/4] avutil/eval: check av_expr_parse_and_eval error code in the test build

Ganesh Ajjanagadde gajjanagadde at gmail.com
Sun Nov 1 21:26:50 CET 2015


This returns the error code from main in the test in the case of ENOMEM.
This should not matter, and will ensure that no warnings are triggered
when av_warn_unused_result is added to avutil/eval.h.

Tested with FATE.

Signed-off-by: Ganesh Ajjanagadde <gajjanagadde at gmail.com>
---
 libavutil/eval.c | 22 +++++++++++++---------
 1 file changed, 13 insertions(+), 9 deletions(-)

diff --git a/libavutil/eval.c b/libavutil/eval.c
index 7642b91..acb3339 100644
--- a/libavutil/eval.c
+++ b/libavutil/eval.c
@@ -750,7 +750,7 @@ static const char *const const_names[] = {
 
 int main(int argc, char **argv)
 {
-    int i;
+    int i, ret;
     double d;
     const char *const *expr;
     static const char *const exprs[] = {
@@ -854,30 +854,34 @@ int main(int argc, char **argv)
 
     for (expr = exprs; *expr; expr++) {
         printf("Evaluating '%s'\n", *expr);
-        av_expr_parse_and_eval(&d, *expr,
+        if ((ret = av_expr_parse_and_eval(&d, *expr,
                                const_names, const_values,
-                               NULL, NULL, NULL, NULL, NULL, 0, NULL);
+                               NULL, NULL, NULL, NULL, NULL, 0, NULL)) == AVERROR(ENOMEM))
+            return ret;
         if (isnan(d))
             printf("'%s' -> nan\n\n", *expr);
         else
             printf("'%s' -> %f\n\n", *expr, d);
     }
 
-    av_expr_parse_and_eval(&d, "1+(5-2)^(3-1)+1/2+sin(PI)-max(-2.2,-3.1)",
+    if ((ret = av_expr_parse_and_eval(&d, "1+(5-2)^(3-1)+1/2+sin(PI)-max(-2.2,-3.1)",
                            const_names, const_values,
-                           NULL, NULL, NULL, NULL, NULL, 0, NULL);
+                           NULL, NULL, NULL, NULL, NULL, 0, NULL)) < 0)
+        return ret;
     printf("%f == 12.7\n", d);
-    av_expr_parse_and_eval(&d, "80G/80Gi",
+    if ((ret = av_expr_parse_and_eval(&d, "80G/80Gi",
                            const_names, const_values,
-                           NULL, NULL, NULL, NULL, NULL, 0, NULL);
+                           NULL, NULL, NULL, NULL, NULL, 0, NULL)) < 0)
+        return ret;
     printf("%f == 0.931322575\n", d);
 
     if (argc > 1 && !strcmp(argv[1], "-t")) {
         for (i = 0; i < 1050; i++) {
             START_TIMER;
-            av_expr_parse_and_eval(&d, "1+(5-2)^(3-1)+1/2+sin(PI)-max(-2.2,-3.1)",
+            if ((ret = av_expr_parse_and_eval(&d, "1+(5-2)^(3-1)+1/2+sin(PI)-max(-2.2,-3.1)",
                                    const_names, const_values,
-                                   NULL, NULL, NULL, NULL, NULL, 0, NULL);
+                                   NULL, NULL, NULL, NULL, NULL, 0, NULL)) < 0)
+                return ret;
             STOP_TIMER("av_expr_parse_and_eval");
         }
     }
-- 
2.6.2



More information about the ffmpeg-devel mailing list