mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Ben Dooks <ben.dooks@codethink.co.uk>
To: linux-riscv@lists.infradead.org, palmer@dabbelt.com, pjw@kernel.org
Cc: linux-kernel@vger.kernel.org, alex@ghiti.fr,
	Ben Dooks <ben.dooks@codethink.co.uk>
Subject: [PATCH] riscv: uaccess: fix sparse warning about cast to restricted type
Date: Wed, 11 Mar 2026 10:51:47 +0000	[thread overview]
Message-ID: <20260311105147.448717-1-ben.dooks@codethink.co.uk> (raw)

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


                 reply	other threads:[~2026-03-11 10:52 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260311105147.448717-1-ben.dooks@codethink.co.uk \
    --to=ben.dooks@codethink.co.uk \
    --cc=alex@ghiti.fr \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-riscv@lists.infradead.org \
    --cc=palmer@dabbelt.com \
    --cc=pjw@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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®