* [PATCH] cb710: avoid NULL pointer subtraction
@ 2021-09-27 12:13 Arnd Bergmann
2021-09-27 15:31 ` Michał Mirosław
0 siblings, 1 reply; 2+ messages in thread
From: Arnd Bergmann @ 2021-09-27 12:13 UTC (permalink / raw)
To: Michał Mirosław, Arnd Bergmann, Greg Kroah-Hartman,
Pierre Ossman
Cc: Nathan Chancellor, Nick Desaulniers, linux-kernel, llvm
From: Arnd Bergmann <arnd@arndb.de>
clang-14 complains about an unusual way of converting a pointer to
an integer:
drivers/misc/cb710/sgbuf2.c:50:15: error: performing pointer subtraction with a null pointer has undefined behavior [-Werror,-Wnull-pointer-subtraction]
return ((ptr - NULL) & 3) != 0;
Replace this with a normal cast to uintptr_t.
Fixes: 5f5bac8272be ("mmc: Driver for CB710/720 memory card reader (MMC part)")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
drivers/misc/cb710/sgbuf2.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/misc/cb710/sgbuf2.c b/drivers/misc/cb710/sgbuf2.c
index e5a4ed3701eb..a798fad5f03c 100644
--- a/drivers/misc/cb710/sgbuf2.c
+++ b/drivers/misc/cb710/sgbuf2.c
@@ -47,7 +47,7 @@ static inline bool needs_unaligned_copy(const void *ptr)
#ifdef CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS
return false;
#else
- return ((ptr - NULL) & 3) != 0;
+ return ((uintptr_t)ptr & 3) != 0;
#endif
}
--
2.29.2
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] cb710: avoid NULL pointer subtraction
2021-09-27 12:13 [PATCH] cb710: avoid NULL pointer subtraction Arnd Bergmann
@ 2021-09-27 15:31 ` Michał Mirosław
0 siblings, 0 replies; 2+ messages in thread
From: Michał Mirosław @ 2021-09-27 15:31 UTC (permalink / raw)
To: Arnd Bergmann
Cc: Arnd Bergmann, Greg Kroah-Hartman, Pierre Ossman,
Nathan Chancellor, Nick Desaulniers, linux-kernel, llvm
On Mon, Sep 27, 2021 at 02:13:57PM +0200, Arnd Bergmann wrote:
> From: Arnd Bergmann <arnd@arndb.de>
>
> clang-14 complains about an unusual way of converting a pointer to
> an integer:
>
> drivers/misc/cb710/sgbuf2.c:50:15: error: performing pointer subtraction with a null pointer has undefined behavior [-Werror,-Wnull-pointer-subtraction]
> return ((ptr - NULL) & 3) != 0;
>
> Replace this with a normal cast to uintptr_t.
>
> Fixes: 5f5bac8272be ("mmc: Driver for CB710/720 memory card reader (MMC part)")
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> ---
> drivers/misc/cb710/sgbuf2.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/misc/cb710/sgbuf2.c b/drivers/misc/cb710/sgbuf2.c
> index e5a4ed3701eb..a798fad5f03c 100644
> --- a/drivers/misc/cb710/sgbuf2.c
> +++ b/drivers/misc/cb710/sgbuf2.c
> @@ -47,7 +47,7 @@ static inline bool needs_unaligned_copy(const void *ptr)
> #ifdef CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS
> return false;
> #else
> - return ((ptr - NULL) & 3) != 0;
> + return ((uintptr_t)ptr & 3) != 0;
> #endif
> }
>
Acked-by: Michał Mirosław <mirq-linux@rere.qmqmq.pl>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2021-09-27 15:32 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-27 12:13 [PATCH] cb710: avoid NULL pointer subtraction Arnd Bergmann
2021-09-27 15:31 ` Michał Mirosław
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).