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: <20211119113644.1600-13-alx.manpages@gmail.com>
Date:   Fri, 19 Nov 2021 12:36:40 +0100
From:   Alejandro Colomar <alx.manpages@...il.com>
To:     LKML <linux-kernel@...r.kernel.org>
Cc:     Alejandro Colomar <alx.manpages@...il.com>
Subject: [PATCH 12/17] linux/container_of.h: Remove unnecessary cast to (void *)

Casts are dangerous.
Every pointer converts implicitly to (void *).
Remove the unnecessary cast.

Since this macro is used with some pointers-to-const,
removing the cast triggers warnings about that
(implicit conversion from poitner-to-const to pointer-to-void).

To solve it, since we don't use the pointer to modify its contents,
we can simply use a (const void *).

Signed-off-by: Alejandro Colomar <alx.manpages@...il.com>
---
 include/linux/container_of.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/include/linux/container_of.h b/include/linux/container_of.h
index 2100adb9d109..62df2ba21c20 100644
--- a/include/linux/container_of.h
+++ b/include/linux/container_of.h
@@ -17,7 +17,7 @@
  */
 #define container_of(ptr, type, member)  (				\
 {									\
-	void *__mptr = (void *)(ptr);					\
+	const void *__mptr = (ptr);					\
 									\
 	static_assert(__same_type(*(ptr), memberof(type, member)) ||	\
 		      __same_type(*(ptr), void),			\
@@ -36,7 +36,7 @@
  */
 #define container_of_safe(ptr, type, member)  (				\
 {									\
-	void *__mptr = (void *)(ptr);					\
+	const void *__mptr = (ptr);					\
 									\
 	IS_ERR_OR_NULL(__mptr) ? ERR_CAST(__mptr) :			\
 				 container_of(ptr, type, member);	\
-- 
2.33.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ