linux-mips
[Top] [All Lists]

Re: Fixes for uaccess.h with gcc >= 4.0.1

To: ralf@linux-mips.org
Subject: Re: Fixes for uaccess.h with gcc >= 4.0.1
From: Atsushi Nemoto <anemo@mba.ocn.ne.jp>
Date: Tue, 14 Feb 2006 15:57:50 +0900 (JST)
Cc: tbm@cyrius.com, linux-mips@linux-mips.org, anderson@netsweng.com, ddaney@avtrex.com, richard@codesourcery.com
In-reply-to: <20060211.224420.25910222.anemo@mba.ocn.ne.jp>
Original-recipient: rfc822;linux-mips@linux-mips.org
References: <87wtg6c43s.fsf@talisman.home> <20060210013440.GA5436@linux-mips.org> <20060211.224420.25910222.anemo@mba.ocn.ne.jp>
Sender: linux-mips-bounce@linux-mips.org
>>>>> On Sat, 11 Feb 2006 22:44:20 +0900 (JST), Atsushi Nemoto 
>>>>> <anemo@mba.ocn.ne.jp> said:
anemo> Please add this cast to fix compiler/sparse warnings?

Sorry, please ignore this patch.  It would be wrong.


It seems current get_user() incorrectly sign-extend an unsigned int
value on 64bit kernel.  I think this is because '(__typeof__(val))'
cast in final assignment.  I suppose the cast should be
'(__typeof__(*(addr))'.

Signed-off-by: Atsushi Nemoto <anemo@mba.ocn.ne.jp>

diff --git a/include/asm-mips/uaccess.h b/include/asm-mips/uaccess.h
index 7a553e9..b96f3e0 100644
--- a/include/asm-mips/uaccess.h
+++ b/include/asm-mips/uaccess.h
@@ -233,7 +233,7 @@ do {                                                        
                \
 #define __get_user_check(x,ptr,size)                                   \
 ({                                                                     \
        long __gu_err = -EFAULT;                                        \
-       const void __user * __gu_ptr = (ptr);                           \
+       const __typeof__(*(ptr)) __user * __gu_ptr = (ptr);             \
                                                                        \
        if (likely(access_ok(VERIFY_READ,  __gu_ptr, size)))            \
                __get_user_common((x), size, __gu_ptr);                 \
@@ -258,7 +258,7 @@ do {                                                        
                \
        : "=r" (__gu_err), "=r" (__gu_tmp)                              \
        : "0" (0), "o" (__m(addr)), "i" (-EFAULT));                     \
                                                                        \
-       (val) = (__typeof__(val)) __gu_tmp;                             \
+       (val) = (__typeof__(*(addr))) __gu_tmp;                         \
 }
 
 /*
@@ -284,7 +284,7 @@ do {                                                        
                \
        "       .previous                                       \n"     \
        : "=r" (__gu_err), "=&r" (__gu_tmp)                             \
        : "0" (0), "r" (addr), "i" (-EFAULT));                          \
-       (val) = __gu_tmp;                                               \
+       (val) = (__typeof__(*(addr))) __gu_tmp;                         \
 }
 
 /*

<Prev in Thread] Current Thread [Next in Thread>