Skip to content

Commit 5e57418

Browse files
andy-shevakpm00
authored andcommitted
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/[email protected] Signed-off-by: Andy Shevchenko <[email protected]> Acked-by: Herve Codina <[email protected]> Signed-off-by: Andrew Morton <[email protected]>
1 parent 6309727 commit 5e57418

File tree

1 file changed

+3
-23
lines changed

1 file changed

+3
-23
lines changed

include/linux/minmax.h

Lines changed: 3 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
#ifndef _LINUX_MINMAX_H
33
#define _LINUX_MINMAX_H
44

5+
#include <linux/compiler_types.h>
56
#include <linux/const.h>
67
#include <linux/types.h>
78

@@ -134,27 +135,6 @@
134135
*/
135136
#define max_t(type, x, y) __careful_cmp((type)(x), (type)(y), >)
136137

137-
/*
138-
* Remove a const qualifier from integer types
139-
* _Generic(foo, type-name: association, ..., default: association) performs a
140-
* comparison against the foo type (not the qualified type).
141-
* Do not use the const keyword in the type-name as it will not match the
142-
* unqualified type of foo.
143-
*/
144-
#define __unconst_integer_type_cases(type) \
145-
unsigned type: (unsigned type)0, \
146-
signed type: (signed type)0
147-
148-
#define __unconst_integer_typeof(x) typeof( \
149-
_Generic((x), \
150-
char: (char)0, \
151-
__unconst_integer_type_cases(char), \
152-
__unconst_integer_type_cases(short), \
153-
__unconst_integer_type_cases(int), \
154-
__unconst_integer_type_cases(long), \
155-
__unconst_integer_type_cases(long long), \
156-
default: (x)))
157-
158138
/*
159139
* Do not check the array parameter using __must_be_array().
160140
* In the following legit use-case where the "array" passed is a simple pointer,
@@ -169,13 +149,13 @@
169149
* 'int *buff' and 'int buff[N]' types.
170150
*
171151
* The array can be an array of const items.
172-
* typeof() keeps the const qualifier. Use __unconst_integer_typeof() in order
152+
* typeof() keeps the const qualifier. Use __unqual_scalar_typeof() in order
173153
* to discard the const qualifier for the __element variable.
174154
*/
175155
#define __minmax_array(op, array, len) ({ \
176156
typeof(&(array)[0]) __array = (array); \
177157
typeof(len) __len = (len); \
178-
__unconst_integer_typeof(__array[0]) __element = __array[--__len]; \
158+
__unqual_scalar_typeof(__array[0]) __element = __array[--__len];\
179159
while (__len--) \
180160
__element = op(__element, __array[__len]); \
181161
__element; })

0 commit comments

Comments
 (0)