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

[dm-devel] [dmraid 3/4] Fix min/max macros



These need parentheses around them.

In particular, in hpt37x.c, in 'to_cpu'
we have an expression:
   x + min(y,z)
which will become

 x + y > z ? y : z

which is not what is wanted.

From: dmraid-fdleak.patch
Signed-off-by: NeilBrown <neilb suse de>

---
 lib/internal.h |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

--- dmraid-16.orig/lib/internal.h
+++ dmraid-16/lib/internal.h
@@ -50,8 +50,8 @@
 #define	u_int64_t	uint64_t
 #endif
 
-#define min(a, b) (a) < (b) ? (a) : (b)
-#define max(a, b) (a) > (b) ? (a) : (b)
+#define min(a, b) ((a) < (b) ? (a) : (b))
+#define max(a, b) ((a) > (b) ? (a) : (b))
 #define ARRAY_SIZE(a)   (sizeof(a) / sizeof(*a))
 #define ARRAY_END(a)   (a + ARRAY_SIZE(a))
 


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