xen/arch/arm/include/asm/smccc.h | 26 +++---- xen/arch/x86/include/asm/alternative-call.h | 84 ++++++++++----------- xen/common/bitops.c | 2 +- xen/include/xen/bitops.h | 4 +- xen/include/xen/nospec.h | 4 +- xen/include/xen/self-tests.h | 4 +- 6 files changed, 62 insertions(+), 62 deletions(-)
All of these are simple cases of using typeof() to avoid multiple parameter
evaluation. Using auto avoids multiple textural expansion also.
No functional change.
Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
---
CC: Anthony PERARD <anthony.perard@vates.tech>
CC: Michal Orzel <michal.orzel@amd.com>
CC: Jan Beulich <jbeulich@suse.com>
CC: Julien Grall <julien@xen.org>
CC: Roger Pau Monné <roger.pau@citrix.com>
CC: Stefano Stabellini <sstabellini@kernel.org>
CC: Volodymyr Babchuk <Volodymyr_Babchuk@epam.com>
CC: Bertrand Marquis <bertrand.marquis@arm.com>
There's an oddity with SMCCC. 4 or fewer args strictly use unsigned long for
ouput types where 5 or more use a dynamic type. I've left it as-was, but it
looks wrong.
https://gitlab.com/xen-project/hardware/xen-staging/-/pipelines/2287583251
---
xen/arch/arm/include/asm/smccc.h | 26 +++----
xen/arch/x86/include/asm/alternative-call.h | 84 ++++++++++-----------
xen/common/bitops.c | 2 +-
xen/include/xen/bitops.h | 4 +-
xen/include/xen/nospec.h | 4 +-
xen/include/xen/self-tests.h | 4 +-
6 files changed, 62 insertions(+), 62 deletions(-)
diff --git a/xen/arch/arm/include/asm/smccc.h b/xen/arch/arm/include/asm/smccc.h
index 441b3ab65dee..29f1128bc283 100644
--- a/xen/arch/arm/include/asm/smccc.h
+++ b/xen/arch/arm/include/asm/smccc.h
@@ -129,7 +129,7 @@ struct arm_smccc_res {
register unsigned long r3 ASM_REG(3)
#define __declare_arg_1(a0, a1, res) \
- typeof(a1) __a1 = (a1); \
+ auto __a1 = (a1); \
struct arm_smccc_res *___res = (res); \
register unsigned long r0 ASM_REG(0) = (uint32_t)(a0); \
register unsigned long r1 ASM_REG(1) = __a1; \
@@ -137,8 +137,8 @@ struct arm_smccc_res {
register unsigned long r3 ASM_REG(3)
#define __declare_arg_2(a0, a1, a2, res) \
- typeof(a1) __a1 = (a1); \
- typeof(a2) __a2 = (a2); \
+ auto __a1 = (a1); \
+ auto __a2 = (a2); \
struct arm_smccc_res *___res = (res); \
register unsigned long r0 ASM_REG(0) = (uint32_t)(a0); \
register unsigned long r1 ASM_REG(1) = __a1; \
@@ -146,9 +146,9 @@ struct arm_smccc_res {
register unsigned long r3 ASM_REG(3)
#define __declare_arg_3(a0, a1, a2, a3, res) \
- typeof(a1) __a1 = (a1); \
- typeof(a2) __a2 = (a2); \
- typeof(a3) __a3 = (a3); \
+ auto __a1 = (a1); \
+ auto __a2 = (a2); \
+ auto __a3 = (a3); \
struct arm_smccc_res *___res = (res); \
register unsigned long r0 ASM_REG(0) = (uint32_t)(a0); \
register unsigned long r1 ASM_REG(1) = __a1; \
@@ -156,24 +156,24 @@ struct arm_smccc_res {
register unsigned long r3 ASM_REG(3) = __a3
#define __declare_arg_4(a0, a1, a2, a3, a4, res) \
- typeof(a4) __a4 = (a4); \
+ auto __a4 = (a4); \
__declare_arg_3(a0, a1, a2, a3, res); \
register unsigned long r4 ASM_REG(4) = __a4
#define __declare_arg_5(a0, a1, a2, a3, a4, a5, res) \
- typeof(a5) __a5 = (a5); \
+ auto __a5 = (a5); \
__declare_arg_4(a0, a1, a2, a3, a4, res); \
- register typeof(a5) r5 ASM_REG(5) = __a5
+ register auto r5 ASM_REG(5) = __a5
#define __declare_arg_6(a0, a1, a2, a3, a4, a5, a6, res) \
- typeof(a6) __a6 = (a6); \
+ auto __a6 = (a6); \
__declare_arg_5(a0, a1, a2, a3, a4, a5, res); \
- register typeof(a6) r6 ASM_REG(6) = __a6
+ register auto r6 ASM_REG(6) = __a6
#define __declare_arg_7(a0, a1, a2, a3, a4, a5, a6, a7, res) \
- typeof(a7) __a7 = (a7); \
+ auto __a7 = (a7); \
__declare_arg_6(a0, a1, a2, a3, a4, a5, a6, res); \
- register typeof(a7) r7 ASM_REG(7) = __a7
+ register auto r7 ASM_REG(7) = __a7
#define ___declare_args(count, ...) __declare_arg_ ## count(__VA_ARGS__)
#define __declare_args(count, ...) ___declare_args(count, __VA_ARGS__)
diff --git a/xen/arch/x86/include/asm/alternative-call.h b/xen/arch/x86/include/asm/alternative-call.h
index b22c10c32283..27024797f584 100644
--- a/xen/arch/x86/include/asm/alternative-call.h
+++ b/xen/arch/x86/include/asm/alternative-call.h
@@ -111,7 +111,7 @@ struct alt_call {
})
#define alternative_vcall1(func, arg) ({ \
- typeof(arg) v1_ = (arg); \
+ auto v1_ = (arg); \
ALT_CALL_ARG(v1_, 1); \
ALT_CALL_NO_ARG2; \
(void)sizeof(func(arg)); \
@@ -119,15 +119,15 @@ struct alt_call {
})
#define alternative_call1(func, arg) ({ \
- typeof(arg) v1_ = (arg); \
+ auto v1_ = (arg); \
ALT_CALL_ARG(v1_, 1); \
ALT_CALL_NO_ARG2; \
alternative_callN(1, typeof(func(arg)), func); \
})
#define alternative_vcall2(func, arg1, arg2) ({ \
- typeof(arg1) v1_ = (arg1); \
- typeof(arg2) v2_ = (arg2); \
+ auto v1_ = (arg1); \
+ auto v2_ = (arg2); \
ALT_CALL_ARG(v1_, 1); \
ALT_CALL_ARG(v2_, 2); \
ALT_CALL_NO_ARG3; \
@@ -136,8 +136,8 @@ struct alt_call {
})
#define alternative_call2(func, arg1, arg2) ({ \
- typeof(arg1) v1_ = (arg1); \
- typeof(arg2) v2_ = (arg2); \
+ auto v1_ = (arg1); \
+ auto v2_ = (arg2); \
ALT_CALL_ARG(v1_, 1); \
ALT_CALL_ARG(v2_, 2); \
ALT_CALL_NO_ARG3; \
@@ -145,9 +145,9 @@ struct alt_call {
})
#define alternative_vcall3(func, arg1, arg2, arg3) ({ \
- typeof(arg1) v1_ = (arg1); \
- typeof(arg2) v2_ = (arg2); \
- typeof(arg3) v3_ = (arg3); \
+ auto v1_ = (arg1); \
+ auto v2_ = (arg2); \
+ auto v3_ = (arg3); \
ALT_CALL_ARG(v1_, 1); \
ALT_CALL_ARG(v2_, 2); \
ALT_CALL_ARG(v3_, 3); \
@@ -157,9 +157,9 @@ struct alt_call {
})
#define alternative_call3(func, arg1, arg2, arg3) ({ \
- typeof(arg1) v1_ = (arg1); \
- typeof(arg2) v2_ = (arg2); \
- typeof(arg3) v3_ = (arg3); \
+ auto v1_ = (arg1); \
+ auto v2_ = (arg2); \
+ auto v3_ = (arg3); \
ALT_CALL_ARG(v1_, 1); \
ALT_CALL_ARG(v2_, 2); \
ALT_CALL_ARG(v3_, 3); \
@@ -169,10 +169,10 @@ struct alt_call {
})
#define alternative_vcall4(func, arg1, arg2, arg3, arg4) ({ \
- typeof(arg1) v1_ = (arg1); \
- typeof(arg2) v2_ = (arg2); \
- typeof(arg3) v3_ = (arg3); \
- typeof(arg4) v4_ = (arg4); \
+ auto v1_ = (arg1); \
+ auto v2_ = (arg2); \
+ auto v3_ = (arg3); \
+ auto v4_ = (arg4); \
ALT_CALL_ARG(v1_, 1); \
ALT_CALL_ARG(v2_, 2); \
ALT_CALL_ARG(v3_, 3); \
@@ -183,10 +183,10 @@ struct alt_call {
})
#define alternative_call4(func, arg1, arg2, arg3, arg4) ({ \
- typeof(arg1) v1_ = (arg1); \
- typeof(arg2) v2_ = (arg2); \
- typeof(arg3) v3_ = (arg3); \
- typeof(arg4) v4_ = (arg4); \
+ auto v1_ = (arg1); \
+ auto v2_ = (arg2); \
+ auto v3_ = (arg3); \
+ auto v4_ = (arg4); \
ALT_CALL_ARG(v1_, 1); \
ALT_CALL_ARG(v2_, 2); \
ALT_CALL_ARG(v3_, 3); \
@@ -198,11 +198,11 @@ struct alt_call {
})
#define alternative_vcall5(func, arg1, arg2, arg3, arg4, arg5) ({ \
- typeof(arg1) v1_ = (arg1); \
- typeof(arg2) v2_ = (arg2); \
- typeof(arg3) v3_ = (arg3); \
- typeof(arg4) v4_ = (arg4); \
- typeof(arg5) v5_ = (arg5); \
+ auto v1_ = (arg1); \
+ auto v2_ = (arg2); \
+ auto v3_ = (arg3); \
+ auto v4_ = (arg4); \
+ auto v5_ = (arg5); \
ALT_CALL_ARG(v1_, 1); \
ALT_CALL_ARG(v2_, 2); \
ALT_CALL_ARG(v3_, 3); \
@@ -214,11 +214,11 @@ struct alt_call {
})
#define alternative_call5(func, arg1, arg2, arg3, arg4, arg5) ({ \
- typeof(arg1) v1_ = (arg1); \
- typeof(arg2) v2_ = (arg2); \
- typeof(arg3) v3_ = (arg3); \
- typeof(arg4) v4_ = (arg4); \
- typeof(arg5) v5_ = (arg5); \
+ auto v1_ = (arg1); \
+ auto v2_ = (arg2); \
+ auto v3_ = (arg3); \
+ auto v4_ = (arg4); \
+ auto v5_ = (arg5); \
ALT_CALL_ARG(v1_, 1); \
ALT_CALL_ARG(v2_, 2); \
ALT_CALL_ARG(v3_, 3); \
@@ -231,12 +231,12 @@ struct alt_call {
})
#define alternative_vcall6(func, arg1, arg2, arg3, arg4, arg5, arg6) ({ \
- typeof(arg1) v1_ = (arg1); \
- typeof(arg2) v2_ = (arg2); \
- typeof(arg3) v3_ = (arg3); \
- typeof(arg4) v4_ = (arg4); \
- typeof(arg5) v5_ = (arg5); \
- typeof(arg6) v6_ = (arg6); \
+ auto v1_ = (arg1); \
+ auto v2_ = (arg2); \
+ auto v3_ = (arg3); \
+ auto v4_ = (arg4); \
+ auto v5_ = (arg5); \
+ auto v6_ = (arg6); \
ALT_CALL_ARG(v1_, 1); \
ALT_CALL_ARG(v2_, 2); \
ALT_CALL_ARG(v3_, 3); \
@@ -248,12 +248,12 @@ struct alt_call {
})
#define alternative_call6(func, arg1, arg2, arg3, arg4, arg5, arg6) ({ \
- typeof(arg1) v1_ = (arg1); \
- typeof(arg2) v2_ = (arg2); \
- typeof(arg3) v3_ = (arg3); \
- typeof(arg4) v4_ = (arg4); \
- typeof(arg5) v5_ = (arg5); \
- typeof(arg6) v6_ = (arg6); \
+ auto v1_ = (arg1); \
+ auto v2_ = (arg2); \
+ auto v3_ = (arg3); \
+ auto v4_ = (arg4); \
+ auto v5_ = (arg5); \
+ auto v6_ = (arg6); \
ALT_CALL_ARG(v1_, 1); \
ALT_CALL_ARG(v2_, 2); \
ALT_CALL_ARG(v3_, 3); \
diff --git a/xen/common/bitops.c b/xen/common/bitops.c
index e46ea1d3ecf8..859a4ca5c131 100644
--- a/xen/common/bitops.c
+++ b/xen/common/bitops.c
@@ -147,7 +147,7 @@ static void __init test_for_each_set_bit(void)
* A copy of @val is taken internally.
*/
#define for_each_set_bit_reverse(iter, val) \
- for ( typeof(val) __v = (val); __v; __v = 0 ) \
+ for ( auto __v = (val); __v; __v = 0 ) \
for ( unsigned int (iter); \
__v && ((iter) = fls_g(__v) - 1, true); \
__clear_bit(iter, &__v) )
diff --git a/xen/include/xen/bitops.h b/xen/include/xen/bitops.h
index a4d31ec02a7c..24882fb4822d 100644
--- a/xen/include/xen/bitops.h
+++ b/xen/include/xen/bitops.h
@@ -299,7 +299,7 @@ static always_inline attr_const unsigned int fls64(uint64_t x)
* A copy of @val is taken internally.
*/
#define for_each_set_bit(iter, val) \
- for ( typeof(val) __v = (val); __v; __v = 0 ) \
+ for ( auto __v = (val); __v; __v = 0 ) \
for ( unsigned int (iter); \
__v && ((iter) = ffs_g(__v) - 1, true); \
__v &= __v - 1 )
@@ -310,7 +310,7 @@ static always_inline attr_const unsigned int fls64(uint64_t x)
*/
#define multiple_bits_set(x) \
({ \
- typeof(x) _v = (x); \
+ auto _v = (x); \
(_v & (_v - 1)) != 0; \
})
diff --git a/xen/include/xen/nospec.h b/xen/include/xen/nospec.h
index c8167a8a245c..0e474145b476 100644
--- a/xen/include/xen/nospec.h
+++ b/xen/include/xen/nospec.h
@@ -51,8 +51,8 @@ static inline unsigned long array_index_mask_nospec(unsigned long index,
*/
#define array_index_nospec(index, size) \
({ \
- typeof(index) _i = (index); \
- typeof(size) _s = (size); \
+ auto _i = (index); \
+ auto _s = (size); \
unsigned long _mask = array_index_mask_nospec(_i, _s); \
\
BUILD_BUG_ON(sizeof(_i) > sizeof(long)); \
diff --git a/xen/include/xen/self-tests.h b/xen/include/xen/self-tests.h
index c57cceb3b962..c4937e781f66 100644
--- a/xen/include/xen/self-tests.h
+++ b/xen/include/xen/self-tests.h
@@ -18,7 +18,7 @@
*/
#define COMPILE_CHECK(fn, val, res) \
do { \
- typeof(fn(val)) real = fn(val); \
+ auto real = fn(val); \
\
if ( !__builtin_constant_p(real) ) \
BUILD_ERROR("'" STR(fn(val)) "' not compile-time constant"); \
@@ -36,7 +36,7 @@
*/
#define RUNTIME_CHECK(fn, val, res) \
do { \
- typeof(fn(val)) real = fn(HIDE(val)); \
+ auto real = fn(HIDE(val)); \
\
if ( real != (res) ) \
panic("%s: %s(%s) expected %u, got %u\n", \
--
2.39.5
On 27.01.2026 11:18, Andrew Cooper wrote: > All of these are simple cases of using typeof() to avoid multiple parameter > evaluation. Using auto avoids multiple textural expansion also. > > No functional change. > > Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com> Acked-by: Jan Beulich <jbeulich@suse.com>
On 27/01/2026 5:01 pm, Jan Beulich wrote: > On 27.01.2026 11:18, Andrew Cooper wrote: >> All of these are simple cases of using typeof() to avoid multiple parameter >> evaluation. Using auto avoids multiple textural expansion also. >> >> No functional change. >> >> Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com> > Acked-by: Jan Beulich <jbeulich@suse.com> Thanks. While I've got people's attentions, there's a secondary pattern we use that's a bit less clear to convert. typeof(a) *_ptr_a = &a; With auto, you're required to write this as: auto _ptr_a = &a; rather than the more-nomal-looking: auto *_ptr_a = &a; So far I've only found two examples, and I'm debating leaving them as are seeing as auto (in this form) is still a new concept to most. Thoughts? ~Andrew
On 27.01.2026 18:10, Andrew Cooper wrote: > On 27/01/2026 5:01 pm, Jan Beulich wrote: >> On 27.01.2026 11:18, Andrew Cooper wrote: >>> All of these are simple cases of using typeof() to avoid multiple parameter >>> evaluation. Using auto avoids multiple textural expansion also. >>> >>> No functional change. >>> >>> Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com> >> Acked-by: Jan Beulich <jbeulich@suse.com> > > Thanks. > > While I've got people's attentions, there's a secondary pattern we use > that's a bit less clear to convert. > > typeof(a) *_ptr_a = &a; > > With auto, you're required to write this as: > > auto _ptr_a = &a; > > rather than the more-nomal-looking: > > auto *_ptr_a = &a; > > > So far I've only found two examples, and I'm debating leaving them as > are seeing as auto (in this form) is still a new concept to most. > > Thoughts? If already we're moving to the use of auto, I think such want converting as well. "auto" meaning "type of rhs", this necessarily implies absence of pointer-ness in the type. Really, is "auto *" actually a construct which could make sense in some specific situation? This and the rhs type are (seemingly) guaranteed to conflict. Jan
© 2016 - 2026 Red Hat, Inc.