eina: safe guard against macro expension error in EINA_*_EQ
authorStefan Schmidt <s.schmidt@samsung.com>
Thu, 28 Feb 2019 09:08:23 +0000 (10:08 +0100)
committerWonki Kim <wonki_.kim@samsung.com>
Fri, 8 Mar 2019 11:49:36 +0000 (20:49 +0900)
Make sure we are use doubel also also in things like EINA_DBL_EQ(a-b, x+y).
Thanks to Vicent for reporting and Xavi for giving me context.

Reviewed-by: Vincent Torri <vincent.torri@gmail.com>
Differential Revision: https://phab.enlightenment.org/D8049

src/lib/eina/eina_util.h

index 6afd424..08b1523 100644 (file)
@@ -78,7 +78,7 @@ static inline Eina_Bool eina_flt_exact(float a, float b);
  *
  * @return @c true if two floats match
  */
-#define EINA_FLT_EQ(a, b) (!!(fabsf((float)a - (float)b) <= FLT_EPSILON))
+#define EINA_FLT_EQ(a, b) (!!(fabsf((float)(a) - (float)(b)) <= FLT_EPSILON))
 
 /**
  * @brief Determines if a float is not zero
@@ -97,7 +97,7 @@ static inline Eina_Bool eina_flt_exact(float a, float b);
  *
  * @return @c true if two double match
  */
-#define EINA_DBL_EQ(a, b) (!!(fabs((double)a - (double)b) <= DBL_EPSILON))
+#define EINA_DBL_EQ(a, b) (!!(fabs((double)(a) - (double)(b)) <= DBL_EPSILON))
 
 /**
  * @brief Determines if a double is not zero