diff options
author | Alejandro Colomar <alx.manpages@gmail.com> | 2021-11-19 02:17:06 +0100 |
---|---|---|
committer | Alejandro Colomar <alx.manpages@gmail.com> | 2021-11-19 02:20:17 +0100 |
commit | 484cc4535fc8984ccde03674bc4fc620bdad1949 (patch) | |
tree | 8c5498672f93b131b658ad892a05c36a83fc1d49 | |
parent | f78518ed2271821448b10c8952a1cd1f1b9ff93a (diff) |
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@gmail.com>
-rw-r--r-- | include/linux/container_of.h | 4 |
1 files 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); \ |