Skip to contentSkip to conversation

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

PATCH In review Jan Beulich 2 participants 2 messages Feb 19

lore
Share & tools
lore
#0 lore raw

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

It's not clear why they were put in place - a__ is of the very type already.

No change in generated code.

xen/arch/x86/include/asm/bitops.h +2 -2
@@ -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                                                                    \
Acked-by on v1 1/1
#1 lore raw
Quoted 6 lines · Jan Beulich

It's not clear why they were put in place - a__ is of the very type already.

No change in generated code.

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

Quoted 21 lines
xen/arch/x86/include/asm/bitops.h +2 -2
@@ -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                                                                    \