[PATCH] x86: Fixes warning: cast removes address space '__user' of expression in uaccess_64.h
From: Dipendra Khadka
Date: Thu Nov 16 2023 - 12:39:29 EST
Sparse has identified a warning as follows:
./arch/x86/include/asm/uaccess_64.h:88:24: warning: cast removes address space '__user' of expression.
Since the valid_user_address(x) macro implicitly casts the argument
to long and compares the converted value of x to zero, casting ptr
to unsigned long has no functional impact and does not trigger a
Sparse warning either.
Signed-off-by: Dipendra Khadka <kdipendra88@xxxxxxxxx>
---
arch/x86/include/asm/uaccess_64.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/arch/x86/include/asm/uaccess_64.h b/arch/x86/include/asm/uaccess_64.h
index f2c02e4469cc..da24d807e101 100644
--- a/arch/x86/include/asm/uaccess_64.h
+++ b/arch/x86/include/asm/uaccess_64.h
@@ -85,7 +85,7 @@ static inline unsigned long __untagged_addr_remote(struct mm_struct *mm,
static inline bool __access_ok(const void __user *ptr, unsigned long size)
{
if (__builtin_constant_p(size <= PAGE_SIZE) && size <= PAGE_SIZE) {
- return valid_user_address(ptr);
+ return valid_user_address((unsigned long)ptr);
} else {
unsigned long sum = size + (unsigned long)ptr;
return valid_user_address(sum) && sum >= (unsigned long)ptr;
--
2.34.1