diff options
| author | Masahiro Yamada <[email protected]> | 2014-11-07 03:03:31 +0900 |
|---|---|---|
| committer | Tom Rini <[email protected]> | 2014-11-23 06:48:30 -0500 |
| commit | b41411954d4ccf6ddaa581178462017557b82b5d (patch) | |
| tree | f9439432d8dfa1073b0ba7b84f8289c4a9835c5f /include | |
| parent | 111396ccb9a8d3e1f0e9d9921d3dbd6c7a70423f (diff) | |
linux/kernel.h: sync min, max, min3, max3 macros with Linux
U-Boot has never cared about the type when we get max/min of two
values, but Linux Kernel does. This commit gets min, max, min3, max3
macros synced with the kernel introducing type checks.
Many of references of those macros must be fixed to suppress warnings.
We have two options:
- Use min, max, min3, max3 only when the arguments have the same type
(or add casts to the arguments)
- Use min_t/max_t instead with the appropriate type for the first
argument
Signed-off-by: Masahiro Yamada <[email protected]>
Acked-by: Pavel Machek <[email protected]>
Acked-by: Lukasz Majewski <[email protected]>
Tested-by: Lukasz Majewski <[email protected]>
[trini: Fixup arch/blackfin/lib/string.c]
Signed-off-by: Tom Rini <[email protected]>
Diffstat (limited to 'include')
| -rw-r--r-- | include/linux/kernel.h | 17 |
1 files changed, 4 insertions, 13 deletions
diff --git a/include/linux/kernel.h b/include/linux/kernel.h index 0e838de0945..89fcae0983c 100644 --- a/include/linux/kernel.h +++ b/include/linux/kernel.h @@ -150,26 +150,17 @@ #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 min3(x, y, z) ({ \ - typeof(x) _min1 = (x); \ - typeof(y) _min2 = (y); \ - typeof(z) _min3 = (z); \ - _min1 < _min2 ? (_min1 < _min3 ? _min1 : _min3) : \ - (_min2 < _min3 ? _min2 : _min3); }) - -#define max3(x, y, z) ({ \ - typeof(x) _max1 = (x); \ - typeof(y) _max2 = (y); \ - typeof(z) _max3 = (z); \ - _max1 > _max2 ? (_max1 > _max3 ? _max1 : _max3) : \ - (_max2 > _max3 ? _max2 : _max3); }) +#define min3(x, y, z) min((typeof(x))min(x, y), z) +#define max3(x, y, z) max((typeof(x))max(x, y), z) /** * min_not_zero - return the minimum that is _not_ zero, unless both are zero |
