core: range: Make simpler for -Wpedantic
Replace MIN and MAX with simple conditionals. These evaluate multiple
times, but all uses in libmctp have been audited to be side-effect free.
Using brace grouped expressions is non-portable so -Wpedantic doesn't
support it. A #pragma can't be used to disable the warning since it
occurs at the MAX() macro "callsite", not in the header file.
../serial.c:39:9: warning: ISO C forbids braced-groups
within expressions [-Wpedantic]
39 | ({
Change-Id: I099a3aa8cbd6730129b9da0fd723342ccb1f7e64
Signed-off-by: Matt Johnston <matt@codeconstruct.com.au>
diff --git a/range.h b/range.h
index 20349f2..03e9d1b 100644
--- a/range.h
+++ b/range.h
@@ -1,26 +1,12 @@
#ifndef _RANGE_H
#define _RANGE_H
-#ifndef typeof
-#define typeof __typeof__
-#endif
-
#ifndef MIN
-#define MIN(a, b) \
- ({ \
- typeof(a) _a = a; \
- typeof(b) _b = b; \
- _a < _b ? _a : _b; \
- })
+#define MIN(a, b) ((a) < (b) ? (a) : (b))
#endif
#ifndef MAX
-#define MAX(a, b) \
- ({ \
- typeof(a) _a = a; \
- typeof(b) _b = b; \
- _a > _b ? _a : _b; \
- })
+#define MAX(a, b) ((a) > (b) ? (a) : (b))
#endif
#endif