lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <152261546159.30503.11719145019451087798.stgit@warthog.procyon.org.uk>
Date:   Sun, 01 Apr 2018 21:44:21 +0100
From:   David Howells <dhowells@...hat.com>
To:     linux-kernel@...r.kernel.org
Subject: [PATCH 41/45] C++: Cast in bitops

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@...hat.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_ */

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ