[PATCH] x86/bitops: drop redundant casts from find_next{,_zero}_bit()

Jan Beulich posted 1 patch 1 week, 4 days ago
Failed in applying to current master (apply log)
[PATCH] x86/bitops: drop redundant casts from find_next{,_zero}_bit()
Posted by Jan Beulich 1 week, 4 days ago
It's not clear why they were put in place - a__ is of the very type
already.

No change in generated code.

Signed-off-by: Jan Beulich <jbeulich@suse.com>

--- a/xen/arch/x86/include/asm/bitops.h
+++ b/xen/arch/x86/include/asm/bitops.h
@@ -343,7 +343,7 @@ static always_inline unsigned int __scan
     if ( o__ >= s__ )                                                       \
         r__ = s__;                                                          \
     else if ( __builtin_constant_p(size) && s__ <= BITS_PER_LONG )          \
-        r__ = o__ + __scanbit(*(const unsigned long *)(a__) >> o__, s__);   \
+        r__ = o__ + __scanbit(*a__ >> o__, s__);                            \
     else if ( __builtin_constant_p(off) && !o__ )                           \
         r__ = __find_first_bit(a__, s__);                                   \
     else                                                                    \
@@ -375,7 +375,7 @@ static always_inline unsigned int __scan
     if ( o__ >= s__ )                                                       \
         r__ = s__;                                                          \
     else if ( __builtin_constant_p(size) && s__ <= BITS_PER_LONG )          \
-        r__ = o__ + __scanbit(~*(const unsigned long *)(a__) >> o__, s__);  \
+        r__ = o__ + __scanbit(~*a__ >> o__, s__);                           \
     else if ( __builtin_constant_p(off) && !o__ )                           \
         r__ = __find_first_zero_bit(a__, s__);                              \
     else                                                                    \
Re: [PATCH] x86/bitops: drop redundant casts from find_next{,_zero}_bit()
Posted by Andrew Cooper 1 week, 4 days ago
On 19/02/2026 3:43 pm, Jan Beulich wrote:
> It's not clear why they were put in place - a__ is of the very type
> already.
>
> No change in generated code.
>
> Signed-off-by: Jan Beulich <jbeulich@suse.com>

I recall this monstrosity requiring many edits to get right.  I expect
it's stale from an older form.

Acked-by: Andrew Cooper <andrew.cooper3@citrix.com>

>
> --- a/xen/arch/x86/include/asm/bitops.h
> +++ b/xen/arch/x86/include/asm/bitops.h
> @@ -343,7 +343,7 @@ static always_inline unsigned int __scan
>      if ( o__ >= s__ )                                                       \
>          r__ = s__;                                                          \
>      else if ( __builtin_constant_p(size) && s__ <= BITS_PER_LONG )          \
> -        r__ = o__ + __scanbit(*(const unsigned long *)(a__) >> o__, s__);   \
> +        r__ = o__ + __scanbit(*a__ >> o__, s__);                            \
>      else if ( __builtin_constant_p(off) && !o__ )                           \
>          r__ = __find_first_bit(a__, s__);                                   \
>      else                                                                    \
> @@ -375,7 +375,7 @@ static always_inline unsigned int __scan
>      if ( o__ >= s__ )                                                       \
>          r__ = s__;                                                          \
>      else if ( __builtin_constant_p(size) && s__ <= BITS_PER_LONG )          \
> -        r__ = o__ + __scanbit(~*(const unsigned long *)(a__) >> o__, s__);  \
> +        r__ = o__ + __scanbit(~*a__ >> o__, s__);                           \
>      else if ( __builtin_constant_p(off) && !o__ )                           \
>          r__ = __find_first_zero_bit(a__, s__);                              \
>      else                                                                    \