MAX and MIN are unsuitable for use where a constant expression is
required. Provide MAX_RAW and MIN_RAW which are suitable but might
evaluate the left argument twice.
Remove max() in ipaddr.c and replace the call with one to MAX (not
MAX_RAW. (The old max macro there is operator-priority-unsafe but
there is only one call site and it happens to be OK.)
We ae going to use MAX_RAW later.
No functional change.
Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
#include <stdio.h>
#include <string.h>
#include "ipaddr.h"
+#include "util.h"
#define DEFAULT_ALLOC 2
#define EXTEND_ALLOC_BY 4
a->d[a->l-1]=r;
}
-#define max(a,b) (a>b?a:b)
struct ipset *ipset_union(struct ipset *a, struct ipset *b)
{
struct ipset *c;
ipset_append_range(c,r);
else if (r.a <= c->d[c->l-1].b+1)
/* Extends (or is consumed by) the last range */
- c->d[c->l-1].b=max(c->d[c->l-1].b, r.b);
+ c->d[c->l-1].b=MAX(c->d[c->l-1].b, r.b);
else
ipset_append_range(c,r);
}
#define MAX(a,b) MINMAX((a),(b),>)
#define MIN(a,b) MINMAX((a),(b),<)
+#define MAX_RAW(a,b) ((a)>(b)?(a):(b))
+#define MIN_RAW(a,b) ((a)<(b)?(a):(b))
+
static inline bool_t iswouldblock(int e)
{ return e==EWOULDBLOCK || e==EAGAIN; }