[babl] babl: fix clang warnings in babl-polynomial



commit 3c3effa2f15ece16aa0af725079f2943bd582f0b
Author: Ell <ell_se yahoo com>
Date:   Tue Oct 3 10:01:58 2017 -0400

    babl: fix clang warnings in babl-polynomial
    
    Cast the input polynomial from BablPolynomial* to
    BablBigPolynomial* in the evaluator functions, so that clang
    doesn't warn us about out-of-bounds access to its coefficient
    array.

 babl/babl-polynomial.c |   15 +++++++++++----
 1 files changed, 11 insertions(+), 4 deletions(-)
---
diff --git a/babl/babl-polynomial.c b/babl/babl-polynomial.c
index 82f9ce4..d27c1bb 100644
--- a/babl/babl-polynomial.c
+++ b/babl/babl-polynomial.c
@@ -98,10 +98,14 @@ typedef struct
   babl_polynomial_eval_1_##i (const BablPolynomial *poly,                      \
                               double                x)                         \
   {                                                                            \
+    /* quiet clang warnings */                                                 \
+    const BablBigPolynomial *const big_poly = (const BablBigPolynomial *) poly;\
+                                                                               \
     const double x2 = x * x;                                                   \
     (void) x2;                                                                 \
-    return BABL_POLYNOMIAL_EVAL_##i   (poly, x2) +                             \
-           BABL_POLYNOMIAL_EVAL_##i_1 (poly, x2) * x;                          \
+                                                                               \
+    return BABL_POLYNOMIAL_EVAL_##i   (big_poly, x2) +                         \
+           BABL_POLYNOMIAL_EVAL_##i_1 (big_poly, x2) * x;                      \
   }
 #include "babl-polynomial.c"
 
@@ -110,8 +114,11 @@ typedef struct
   babl_polynomial_eval_2_##i (const BablPolynomial *poly,                      \
                               double                x)                         \
   {                                                                            \
-    return BABL_POLYNOMIAL_EVAL_##i   (poly, x) +                              \
-           BABL_POLYNOMIAL_EVAL_##i_1 (poly, x) * sqrt (x);                    \
+    /* quiet clang warnings */                                                 \
+    const BablBigPolynomial *const big_poly = (const BablBigPolynomial *) poly;\
+                                                                               \
+    return BABL_POLYNOMIAL_EVAL_##i   (big_poly, x) +                          \
+           BABL_POLYNOMIAL_EVAL_##i_1 (big_poly, x) * sqrt (x);                \
   }
 #include "babl-polynomial.c"
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]