Fix: max_t/min_t macros are missing cast on input
authorMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Tue, 13 Nov 2018 17:12:21 +0000 (12:12 -0500)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Fri, 16 Nov 2018 22:18:51 +0000 (17:18 -0500)
The semantic expected from max_t and min_t is to perform the max/min
comparison in the type provided as first parameter.

Cast the input parameters to the proper type before comparing them,
rather than after. There is no more need to cast the result of the
expression now that both inputs are cast to the right type.

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
src/common/macros.h

index c42cddd5050ca163a612e9f1744f9b7aaf03da5b..f242da481b6f8c7c47ddf30064894b3ef35564e8 100644 (file)
@@ -72,7 +72,7 @@ void *zmalloc(size_t len)
 #endif
 
 #ifndef max_t
 #endif
 
 #ifndef max_t
-#define max_t(type, a, b)      ((type) max(a, b))
+#define max_t(type, a, b)      max((type) a, (type) b)
 #endif
 
 #ifndef min
 #endif
 
 #ifndef min
@@ -80,7 +80,7 @@ void *zmalloc(size_t len)
 #endif
 
 #ifndef min_t
 #endif
 
 #ifndef min_t
-#define min_t(type, a, b)      ((type) min(a, b))
+#define min_t(type, a, b)      min((type) a, (type) b)
 #endif
 
 #ifndef LTTNG_PACKED
 #endif
 
 #ifndef LTTNG_PACKED
This page took 0.027793 seconds and 4 git commands to generate.