lkml.org 
[lkml]   [2018]   [Apr]   [1]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Subject[PATCH 41/45] C++: Cast in bitops
From
Date
In the generic bitops functions, cast the void* bits pointer to unsigned
long* before using it to avoid things like:

include/asm-generic/bitops/le.h:15:28: error: invalid conversion from 'const void*' to 'const long unsigned int*' [-fpermissive]

Signed-off-by: David Howells <dhowells@redhat.com>
---

include/asm-generic/bitops/le.h | 32 ++++++++++++++++++++------------
1 file changed, 20 insertions(+), 12 deletions(-)

diff --git a/include/asm-generic/bitops/le.h b/include/asm-generic/bitops/le.h
index 188d3eba3ace..8b0fb40da390 100644
--- a/include/asm-generic/bitops/le.h
+++ b/include/asm-generic/bitops/le.h
@@ -12,19 +12,19 @@
static inline unsigned long find_next_zero_bit_le(const void *addr,
unsigned long size, unsigned long offset)
{
- return find_next_zero_bit(addr, size, offset);
+ return find_next_zero_bit(static_cast<const unsigned long *>(addr), size, offset);
}

static inline unsigned long find_next_bit_le(const void *addr,
unsigned long size, unsigned long offset)
{
- return find_next_bit(addr, size, offset);
+ return find_next_bit(static_cast<const unsigned long *>(addr), size, offset);
}

static inline unsigned long find_first_zero_bit_le(const void *addr,
unsigned long size)
{
- return find_first_zero_bit(addr, size);
+ return find_first_zero_bit(static_cast<const unsigned long *>(addr), size);
}

#elif defined(__BIG_ENDIAN)
@@ -52,47 +52,55 @@ extern unsigned long find_next_bit_le(const void *addr,

static inline int test_bit_le(int nr, const void *addr)
{
- return test_bit(nr ^ BITOP_LE_SWIZZLE, addr);
+ return test_bit(nr ^ BITOP_LE_SWIZZLE,
+ static_cast<const unsigned long *>(addr));
}

static inline void set_bit_le(int nr, void *addr)
{
- set_bit(nr ^ BITOP_LE_SWIZZLE, addr);
+ set_bit(nr ^ BITOP_LE_SWIZZLE, static_cast<unsigned long *>(addr));
}

static inline void clear_bit_le(int nr, void *addr)
{
- clear_bit(nr ^ BITOP_LE_SWIZZLE, addr);
+ clear_bit(nr ^ BITOP_LE_SWIZZLE,
+ static_cast<unsigned long *>(addr));
}

static inline void __set_bit_le(int nr, void *addr)
{
- __set_bit(nr ^ BITOP_LE_SWIZZLE, addr);
+ __set_bit(nr ^ BITOP_LE_SWIZZLE,
+ static_cast<unsigned long *>(addr));
}

static inline void __clear_bit_le(int nr, void *addr)
{
- __clear_bit(nr ^ BITOP_LE_SWIZZLE, addr);
+ __clear_bit(nr ^ BITOP_LE_SWIZZLE,
+ static_cast<unsigned long *>(addr));
}

static inline int test_and_set_bit_le(int nr, void *addr)
{
- return test_and_set_bit(nr ^ BITOP_LE_SWIZZLE, addr);
+ return test_and_set_bit(nr ^ BITOP_LE_SWIZZLE,
+ static_cast<unsigned long *>(addr));
}

static inline int test_and_clear_bit_le(int nr, void *addr)
{
- return test_and_clear_bit(nr ^ BITOP_LE_SWIZZLE, addr);
+ return test_and_clear_bit(nr ^ BITOP_LE_SWIZZLE,
+ static_cast<unsigned long *>(addr));
}

static inline int __test_and_set_bit_le(int nr, void *addr)
{
- return __test_and_set_bit(nr ^ BITOP_LE_SWIZZLE, addr);
+ return __test_and_set_bit(nr ^ BITOP_LE_SWIZZLE,
+ static_cast<unsigned long *>(addr));
}

static inline int __test_and_clear_bit_le(int nr, void *addr)
{
- return __test_and_clear_bit(nr ^ BITOP_LE_SWIZZLE, addr);
+ return __test_and_clear_bit(nr ^ BITOP_LE_SWIZZLE,
+ static_cast<unsigned long *>(addr));
}

#endif /* _ASM_GENERIC_BITOPS_LE_H_ */
\
 
 \ /
  Last update: 2018-04-01 22:45    [W:0.166 / U:2.180 seconds]
©2003-2018 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site