Skip to content

Commit 8d4beed

Browse files
committed
compiler-types.h: Include naked type in __pick_integer_type() match
__pick_integer_type() checks whether the type of its first argument is compatible with an explicitly signed or unsigned integer type, returning the compatible type if it exists. Unfortunately, 'char' is neither compatible with 'signed char' nor 'unsigned char', so add a check against the naked type to allow the __unqual_scalar_typeof() macro to strip qualifiers from char types without an explicit signedness. Reported-by: Rasmus Villemoes <[email protected]> Signed-off-by: Will Deacon <[email protected]>
1 parent 5872f1a commit 8d4beed

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

include/linux/compiler_types.h

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -220,9 +220,14 @@ struct ftrace_likely_data {
220220
#define __pick_scalar_type(x, type, otherwise) \
221221
__builtin_choose_expr(__same_type(x, type), (type)0, otherwise)
222222

223+
/*
224+
* 'char' is not type-compatible with either 'signed char' or 'unsigned char',
225+
* so we include the naked type here as well as the signed/unsigned variants.
226+
*/
223227
#define __pick_integer_type(x, type, otherwise) \
224-
__pick_scalar_type(x, unsigned type, \
225-
__pick_scalar_type(x, signed type, otherwise))
228+
__pick_scalar_type(x, type, \
229+
__pick_scalar_type(x, unsigned type, \
230+
__pick_scalar_type(x, signed type, otherwise)))
226231

227232
#define __unqual_scalar_typeof(x) typeof( \
228233
__pick_integer_type(x, char, \

0 commit comments

Comments
 (0)