[PATCH] Fix min/max macro

Matthias Koenig <[email protected]>
Newsgroups gmane.linux.ataraid
Organization SUSE Linux Products GmbH, Nuernberg
Message-ID <[email protected]>
Hi,

here is a patch for the internal.h header which fixes the
min/max macro. In current form its expansion might lead to wrong
behaviour in certain contexts.

Matthias

_______________________________________________
Ataraid-list mailing list
[email protected]
https://www.redhat.com/mailman/listinfo/ataraid-list
dmraid-1.0.0.rc13-fix_macro.patch (text/x-patch, 470 B)
Index: 1.0.0.rc13/lib/internal.h
===================================================================
--- 1.0.0.rc13.orig/lib/internal.h
+++ 1.0.0.rc13/lib/internal.h
@@ -49,8 +49,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))
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.