From 6b143a68d3a44be42f2370b9d91409eceb14cebd Mon Sep 17 00:00:00 2001 From: David Lamparter Date: Wed, 21 Sep 2016 18:20:49 +0200 Subject: [PATCH] lib: force local MIN/MAX macros 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 --- lib/checksum.c | 2 +- lib/zebra.h | 9 ++++++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/lib/checksum.c b/lib/checksum.c index 116aaafc97..3d6cd45791 100644 --- a/lib/checksum.c +++ b/lib/checksum.c @@ -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 */ diff --git a/lib/zebra.h b/lib/zebra.h index da069d1dfa..8763abd766 100644 --- a/lib/zebra.h +++ b/lib/zebra.h @@ -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])) -- 2.39.5