]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
compiler-types.h: Include naked type in __pick_integer_type() match
authorWill Deacon <will@kernel.org>
Fri, 5 Jun 2020 10:05:51 +0000 (11:05 +0100)
committerWill Deacon <will@kernel.org>
Fri, 5 Jun 2020 10:05:51 +0000 (11:05 +0100)
__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 <linux@rasmusvillemoes.dk>
Signed-off-by: Will Deacon <will@kernel.org>
include/linux/compiler_types.h

index 233066c92f6f397f572fbff5a245c9654a09031e..6ed0612bc1432ff9679290bd8a34b1477beee9e2 100644 (file)
@@ -220,9 +220,14 @@ struct ftrace_likely_data {
 #define __pick_scalar_type(x, type, otherwise)                                 \
        __builtin_choose_expr(__same_type(x, type), (type)0, otherwise)
 
+/*
+ * 'char' is not type-compatible with either 'signed char' or 'unsigned char',
+ * so we include the naked type here as well as the signed/unsigned variants.
+ */
 #define __pick_integer_type(x, type, otherwise)                                        \
-       __pick_scalar_type(x, unsigned type,                                    \
-               __pick_scalar_type(x, signed type, otherwise))
+       __pick_scalar_type(x, type,                                             \
+               __pick_scalar_type(x, unsigned type,                            \
+                       __pick_scalar_type(x, signed type, otherwise)))
 
 #define __unqual_scalar_typeof(x) typeof(                                      \
        __pick_integer_type(x, char,                                            \