Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

cb710: avoid NULL pointer subtraction

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)")
Cc: stable <stable@vger.kernel.org>
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Link: https://lore.kernel.org/r/20210927121408.939246-1-arnd@kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Arnd Bergmann and committed by
Greg Kroah-Hartman
42641042 a3e16937

+1 -1
+1 -1
drivers/misc/cb710/sgbuf2.c
··· 47 47 #ifdef CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS 48 48 return false; 49 49 #else 50 - return ((ptr - NULL) & 3) != 0; 50 + return ((uintptr_t)ptr & 3) != 0; 51 51 #endif 52 52 } 53 53