mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] riscv: uaccess: fix sparse warning about cast to restricted type
@ 2026-03-11 10:51 Ben Dooks
  0 siblings, 0 replies; only message in thread
From: Ben Dooks @ 2026-03-11 10:51 UTC (permalink / raw)
  To: linux-riscv, palmer, pjw; +Cc: linux-kernel, alex, Ben Dooks

It seems recent changes have made sparse warning about casting to
restricted types whe using __get_user() in drivers such as the
drivers/pci/proc.c.

Fix this with a __force to fix such warnings as:

drivers/pci/proc.c:148:17: warning: cast to restricted __le16
drivers/pci/proc.c:148:17: warning: cast to restricted __le16
drivers/pci/proc.c:148:17: warning: cast to restricted __le16
drivers/pci/proc.c:148:17: warning: cast to restricted __le16
drivers/pci/proc.c:157:17: warning: cast to restricted __le32
drivers/pci/proc.c:157:17: warning: cast to restricted __le32
drivers/pci/proc.c:157:17: warning: cast to restricted __le32
drivers/pci/proc.c:157:17: warning: cast to restricted __le32
drivers/pci/proc.c:166:17: warning: cast to restricted __le16
drivers/pci/proc.c:166:17: warning: cast to restricted __le16
drivers/pci/proc.c:166:17: warning: cast to restricted __le16
drivers/pci/proc.c:166:17: warning: cast to restricted __le16

Signed-off-by: Ben Dooks <ben.dooks@codethink.co.uk>
---
 arch/riscv/include/asm/uaccess.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/riscv/include/asm/uaccess.h b/arch/riscv/include/asm/uaccess.h
index 11c9886c3b70..5d4ec15584cf 100644
--- a/arch/riscv/include/asm/uaccess.h
+++ b/arch/riscv/include/asm/uaccess.h
@@ -112,7 +112,7 @@ do {								\
 		_ASM_EXTABLE_UACCESS_ERR(1b, %l2, %0)		\
 		: "=&r" (__tmp)					\
 		: "m" (*(ptr)) : : label);			\
-	(x) = (__typeof__(x))(unsigned long)__tmp;		\
+	(x) = (__force __typeof__(x))(unsigned long)__tmp;	\
 } while (0)
 #else /* !CONFIG_CC_HAS_ASM_GOTO_OUTPUT */
 #define __get_user_asm(insn, x, ptr, label)			\
-- 
2.37.2.352.g3c44437643


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2026-03-11 10:52 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-03-11 10:51 [PATCH] riscv: uaccess: fix sparse warning about cast to restricted type Ben Dooks

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®