mirror of
http://git.haproxy.org/git/haproxy.git/
synced 2025-02-20 04:37:04 +00:00
CLEANUP: compat: make the MIN/MAX macros more reliable
After every release we say that MIN/MAX should be changed to be an expression that only evaluates each operand once, and before every version we forget to change it and we recheck that the code doesn't misuse them. Let's fix them now.
This commit is contained in:
parent
b9915a745e
commit
0999e3d959
@ -94,11 +94,19 @@ typedef struct { } empty_t;
|
||||
#endif
|
||||
|
||||
#ifndef MIN
|
||||
#define MIN(a, b) (((a) < (b)) ? (a) : (b))
|
||||
#define MIN(a, b) ({ \
|
||||
typeof(a) _a = (a); \
|
||||
typeof(a) _b = (b); \
|
||||
((_a < _b) ? _a : _b); \
|
||||
})
|
||||
#endif
|
||||
|
||||
#ifndef MAX
|
||||
#define MAX(a, b) (((a) > (b)) ? (a) : (b))
|
||||
#define MAX(a, b) ({ \
|
||||
typeof(a) _a = (a); \
|
||||
typeof(a) _b = (b); \
|
||||
((_a > _b) ? _a : _b); \
|
||||
})
|
||||
#endif
|
||||
|
||||
/* this is for libc5 for example */
|
||||
|
Loading…
Reference in New Issue
Block a user