s390: Replace weird use of PTR_RET.
authorRusty Russell <rusty@rustcorp.com.au>
Mon, 15 Jul 2013 01:51:32 +0000 (11:21 +0930)
committerRusty Russell <rusty@rustcorp.com.au>
Mon, 15 Jul 2013 01:55:02 +0000 (11:25 +0930)
Saves repeating "(void __force *)__uptr" but it's less clear.  Using
the output of PTR_RET() to determine the error rather than just
testing IS_ERR() is odd.

For example, I *assume* __gptr_to_uptr() never returns NULL?  Because
the __ret would be 0 for the old code.  The new version is clearer, IMHO:
it would try to get_user() on that address.

If you hate this variant, I can just s/PTR_RET/PTR_ERR_OR_ZERO/ instead.

Cc: Christian Borntraeger <borntraeger@de.ibm.com>
Cc: Martin Schwidefsky <schwidefsky@de.ibm.com>
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Acked-by: Heiko Carstens <heiko.carstens@de.ibm.com>
arch/s390/kvm/gaccess.h

index 302e0e52b0097e7f21a30bfb3fd9a1866e8c4274..99d789e8a0189c0ab319d775b1c54beba0dac05b 100644 (file)
@@ -42,9 +42,11 @@ static inline void __user *__gptr_to_uptr(struct kvm_vcpu *vcpu,
 ({                                                             \
        __typeof__(gptr) __uptr = __gptr_to_uptr(vcpu, gptr, 1);\
        int __mask = sizeof(__typeof__(*(gptr))) - 1;           \
-       int __ret = PTR_RET((void __force *)__uptr);            \
+       int __ret;                                              \
                                                                \
-       if (!__ret) {                                           \
+       if (IS_ERR((void __force *)__uptr)) {                   \
+               __ret = PTR_ERR((void __force *)__uptr);        \
+       } else {                                                \
                BUG_ON((unsigned long)__uptr & __mask);         \
                __ret = get_user(x, __uptr);                    \
        }                                                       \
@@ -55,9 +57,11 @@ static inline void __user *__gptr_to_uptr(struct kvm_vcpu *vcpu,
 ({                                                             \
        __typeof__(gptr) __uptr = __gptr_to_uptr(vcpu, gptr, 1);\
        int __mask = sizeof(__typeof__(*(gptr))) - 1;           \
-       int __ret = PTR_RET((void __force *)__uptr);            \
+       int __ret;                                              \
                                                                \
-       if (!__ret) {                                           \
+       if (IS_ERR((void __force *)__uptr)) {                   \
+               __ret = PTR_ERR((void __force *)__uptr);        \
+       } else {                                                \
                BUG_ON((unsigned long)__uptr & __mask);         \
                __ret = put_user(x, __uptr);                    \
        }                                                       \