min/max: remove sparse warnings when they're nested
[cascardo/linux.git] / include / linux / kernel.h
index d96a611..bc6ed52 100644 (file)
@@ -259,17 +259,14 @@ static inline void might_fault(void) { }
 extern struct atomic_notifier_head panic_notifier_list;
 extern long (*panic_blink)(int state);
 __printf(1, 2)
-void panic(const char *fmt, ...)
-       __noreturn __cold;
+void panic(const char *fmt, ...) __noreturn __cold;
 void nmi_panic(struct pt_regs *regs, const char *msg);
 extern void oops_enter(void);
 extern void oops_exit(void);
 void print_oops_end_marker(void);
 extern int oops_may_print(void);
-void do_exit(long error_code)
-       __noreturn;
-void complete_and_exit(struct completion *, long)
-       __noreturn;
+void do_exit(long error_code) __noreturn;
+void complete_and_exit(struct completion *, long) __noreturn;
 
 /* Internal, do not use. */
 int __must_check _kstrtoul(const char *s, unsigned int base, unsigned long *res);
@@ -736,17 +733,25 @@ static inline void ftrace_dump(enum ftrace_dump_mode oops_dump_mode) { }
  * strict type-checking.. See the
  * "unnecessary" pointer comparison.
  */
-#define min(x, y) ({                           \
-       typeof(x) _min1 = (x);                  \
-       typeof(y) _min2 = (y);                  \
-       (void) (&_min1 == &_min2);              \
-       _min1 < _min2 ? _min1 : _min2; })
-
-#define max(x, y) ({                           \
-       typeof(x) _max1 = (x);                  \
-       typeof(y) _max2 = (y);                  \
-       (void) (&_max1 == &_max2);              \
-       _max1 > _max2 ? _max1 : _max2; })
+#define __min(t1, t2, min1, min2, x, y) ({             \
+       t1 min1 = (x);                                  \
+       t2 min2 = (y);                                  \
+       (void) (&min1 == &min2);                        \
+       min1 < min2 ? min1 : min2; })
+#define min(x, y)                                      \
+       __min(typeof(x), typeof(y),                     \
+             __UNIQUE_ID(min1_), __UNIQUE_ID(min2_),   \
+             x, y)
+
+#define __max(t1, t2, max1, max2, x, y) ({             \
+       t1 max1 = (x);                                  \
+       t2 max2 = (y);                                  \
+       (void) (&max1 == &max2);                        \
+       max1 > max2 ? max1 : max2; })
+#define max(x, y)                                      \
+       __max(typeof(x), typeof(y),                     \
+             __UNIQUE_ID(max1_), __UNIQUE_ID(max2_),   \
+             x, y)
 
 #define min3(x, y, z) min((typeof(x))min(x, y), z)
 #define max3(x, y, z) max((typeof(x))max(x, y), z)
@@ -778,15 +783,15 @@ static inline void ftrace_dump(enum ftrace_dump_mode oops_dump_mode) { }
  *
  * Or not use min/max/clamp at all, of course.
  */
-#define min_t(type, x, y) ({                   \
-       type __min1 = (x);                      \
-       type __min2 = (y);                      \
-       __min1 < __min2 ? __min1: __min2; })
-
-#define max_t(type, x, y) ({                   \
-       type __max1 = (x);                      \
-       type __max2 = (y);                      \
-       __max1 > __max2 ? __max1: __max2; })
+#define min_t(type, x, y)                              \
+       __min(type, type,                               \
+             __UNIQUE_ID(min1_), __UNIQUE_ID(min2_),   \
+             x, y)
+
+#define max_t(type, x, y)                              \
+       __max(type, type,                               \
+             __UNIQUE_ID(min1_), __UNIQUE_ID(min2_),   \
+             x, y)
 
 /**
  * clamp_t - return a value clamped to a given range using a given type