[FFmpeg-devel] [PATCH 12/12] Fix constness for func[12] parameters in ff_parse_expr().

Stefano Sabatini stefano.sabatini-lala
Mon Apr 12 00:38:26 CEST 2010


Declare as constant the func[12] list of functions which is passed to
ff_parse_expr() and ff_parse_and_eval_expr().

This is consistent with the semantics of the provided list, which is
not supposed to be changed by the called function, and fixes the
GCC compilation warnings:
libavcodec/ratecontrol.c: In function ?ff_rate_control_init?:
libavcodec/ratecontrol.c:109: warning: passing argument 5 of ?ff_parse_expr? discards qualifiers from pointer target type
libavcodec/eval.h:69: note: expected ?double (**)(void *, double)? but argument is of type ?double (* const*)(void *, double)?
---
 libavcodec/eval.c |   12 ++++++------
 libavcodec/eval.h |    8 ++++----
 2 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/libavcodec/eval.c b/libavcodec/eval.c
index ef644c6..248e244 100644
--- a/libavcodec/eval.c
+++ b/libavcodec/eval.c
@@ -35,9 +35,9 @@ typedef struct Parser {
     char *s;
     const double *var_values;
     const char * const *var_names;      // NULL terminated
-    double (**func1)(void *, double a); // NULL terminated
+    double (* const *func1)(void *, double a); // NULL terminated
     const char * const *func1_names;    // NULL terminated
-    double (**func2)(void *, double a, double b); // NULL terminated
+    double (* const *func2)(void *, double a, double b); // NULL terminated
     const char * const *func2_names;    // NULL terminated
     void *opaque;
 #define VARS 10
@@ -432,8 +432,8 @@ static int verify_expr(AVExpr *e)
 
 int ff_parse_expr(AVExpr **expr, const char *s,
                   const char * const *var_names,
-                  const char * const *func1_names, double (**func1)(void *, double),
-                  const char * const *func2_names, double (**func2)(void *, double, double),
+                  const char * const *func1_names, double (* const *func1)(void *, double),
+                  const char * const *func2_names, double (* const *func2)(void *, double, double),
                   void *log_ctx)
 {
     Parser p;
@@ -478,8 +478,8 @@ double ff_eval_expr(AVExpr *e, const double *var_values, void *opaque)
 
 int ff_parse_and_eval_expr(double *res, const char *s,
                            const char * const *var_names, const double *var_values,
-                           const char * const *func1_names, double (**func1)(void *, double),
-                           const char * const *func2_names, double (**func2)(void *, double, double),
+                           const char * const *func1_names, double (* const *func1)(void *, double),
+                           const char * const *func2_names, double (* const *func2)(void *, double, double),
                            void *opaque, void *log_ctx)
 {
     AVExpr *e;
diff --git a/libavcodec/eval.h b/libavcodec/eval.h
index dc9b835..eadb946 100644
--- a/libavcodec/eval.h
+++ b/libavcodec/eval.h
@@ -47,8 +47,8 @@ typedef struct AVExpr AVExpr;
  */
 int ff_parse_and_eval_expr(double *res, const char *s,
                            const char * const *var_names,   const double *var_values,
-                           const char * const *func1_names, double (**func1)(void *, double),
-                           const char * const *func2_names, double (**func2)(void *, double, double),
+                           const char * const *func1_names, double (* const *func1)(void *, double),
+                           const char * const *func2_names, double (* const *func2)(void *, double, double),
                            void *opaque, void *log_ctx);
 
 /**
@@ -68,8 +68,8 @@ int ff_parse_and_eval_expr(double *res, const char *s,
  */
 int ff_parse_expr(AVExpr **expr, const char *s,
                   const char * const *var_names,
-                  const char * const *func1_names, double (**func1)(void *, double),
-                  const char * const *func2_names, double (**func2)(void *, double, double),
+                  const char * const *func1_names, double (* const *func1)(void *, double),
+                  const char * const *func2_names, double (* const *func2)(void *, double, double),
                   void *log_ctx);
 
 /**
-- 
1.7.0




More information about the ffmpeg-devel mailing list