Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

minmax: deduplicate __unconst_integer_typeof()

It appears that compiler_types.h already have an implementation of the
__unconst_integer_typeof() called __unqual_scalar_typeof(). Use it
instead of the copy.

Link: https://lkml.kernel.org/r/20230911154913.4176033-1-andriy.shevchenko@linux.intel.com
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Acked-by: Herve Codina <herve.codina@bootlin.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

authored by

Andy Shevchenko and committed by
Andrew Morton
5e57418a 6309727e

+3 -23
+3 -23
include/linux/minmax.h
··· 2 2 #ifndef _LINUX_MINMAX_H 3 3 #define _LINUX_MINMAX_H 4 4 5 + #include <linux/compiler_types.h> 5 6 #include <linux/const.h> 6 7 #include <linux/types.h> 7 8 ··· 136 135 #define max_t(type, x, y) __careful_cmp((type)(x), (type)(y), >) 137 136 138 137 /* 139 - * Remove a const qualifier from integer types 140 - * _Generic(foo, type-name: association, ..., default: association) performs a 141 - * comparison against the foo type (not the qualified type). 142 - * Do not use the const keyword in the type-name as it will not match the 143 - * unqualified type of foo. 144 - */ 145 - #define __unconst_integer_type_cases(type) \ 146 - unsigned type: (unsigned type)0, \ 147 - signed type: (signed type)0 148 - 149 - #define __unconst_integer_typeof(x) typeof( \ 150 - _Generic((x), \ 151 - char: (char)0, \ 152 - __unconst_integer_type_cases(char), \ 153 - __unconst_integer_type_cases(short), \ 154 - __unconst_integer_type_cases(int), \ 155 - __unconst_integer_type_cases(long), \ 156 - __unconst_integer_type_cases(long long), \ 157 - default: (x))) 158 - 159 - /* 160 138 * Do not check the array parameter using __must_be_array(). 161 139 * In the following legit use-case where the "array" passed is a simple pointer, 162 140 * __must_be_array() will return a failure. ··· 149 169 * 'int *buff' and 'int buff[N]' types. 150 170 * 151 171 * The array can be an array of const items. 152 - * typeof() keeps the const qualifier. Use __unconst_integer_typeof() in order 172 + * typeof() keeps the const qualifier. Use __unqual_scalar_typeof() in order 153 173 * to discard the const qualifier for the __element variable. 154 174 */ 155 175 #define __minmax_array(op, array, len) ({ \ 156 176 typeof(&(array)[0]) __array = (array); \ 157 177 typeof(len) __len = (len); \ 158 - __unconst_integer_typeof(__array[0]) __element = __array[--__len]; \ 178 + __unqual_scalar_typeof(__array[0]) __element = __array[--__len];\ 159 179 while (__len--) \ 160 180 __element = op(__element, __array[__len]); \ 161 181 __element; })