]> git.puffer.fish Git - matthieu/frr.git/commitdiff
lib: force local MIN/MAX macros
authorDavid Lamparter <equinox@opensourcerouting.org>
Wed, 21 Sep 2016 16:20:49 +0000 (18:20 +0200)
committerDonald Sharp <sharpd@cumulusnetworks.com>
Fri, 23 Sep 2016 16:12:17 +0000 (12:12 -0400)
Linux/glibc sys/param.h has definitions of MIN/MAX that result in
multiple evaluations of its parameters.  Force local definitions.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
lib/checksum.c
lib/zebra.h

index 116aaafc975bf0143d85ea2c15d40cb543da701a..3d6cd45791dd48da1024b1b36006137d45b373d9 100644 (file)
@@ -47,7 +47,7 @@ in_cksum(void *parg, int nbytes)
 }
 
 /* Fletcher Checksum -- Refer to RFC1008. */
-#define MODX                 4102   /* 5802 should be fine */
+#define MODX                 4102U   /* 5802 should be fine */
 
 /* To be consistent, offset is 0-based index, rather than the 1-based 
    index required in the specification ISO 8473, Annex C.1 */
index da069d1dfa311200d0b98f2649644e1451865e65..8763abd7667d116d6288b2c2b3847aea6cb7e35e 100644 (file)
@@ -352,18 +352,21 @@ struct in_pktinfo
 #endif /* ndef BYTE_ORDER */
 
 /* MAX / MIN are not commonly defined, but useful */
-#ifndef MAX
+/* note: glibc sys/param.h has #define MIN(a,b) (((a)<(b))?(a):(b)) */
+#ifdef MAX
+#undef MAX
+#endif
 #define MAX(a, b) \
        ({ typeof (a) _a = (a); \
           typeof (b) _b = (b); \
           _a > _b ? _a : _b; })
+#ifdef MIN
+#undef MIN
 #endif
-#ifndef MIN
 #define MIN(a, b) \
        ({ typeof (a) _a = (a); \
           typeof (b) _b = (b); \
           _a < _b ? _a : _b; })
-#endif
 
 #define ZEBRA_NUM_OF(x) (sizeof (x) / sizeof (x[0]))