Re: [PATCH] XArray: Fix a math problem in xa_is_err()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, Jan 15, 2019 at 10:52:41PM +0300, Dan Carpenter wrote:
> @@ -177,7 +177,8 @@ static inline bool xa_is_internal(const void *entry)
>  static inline bool xa_is_err(const void *entry)
>  {
>  	return unlikely(xa_is_internal(entry) &&
> -			(unsigned long)entry >= -((MAX_ERRNO << 2) + 2));
> +			(unsigned long)entry >=
> +				(((unsigned long)(-MAX_ERRNO << 2) + 2)));
>  }

Ugh all the brackets, I'm not surprised I got it wrong.  How about this
instead; does it make your static checker happy?

diff --git a/include/linux/xarray.h b/include/linux/xarray.h
index 7da665f5cb20..5d9d318bcf7a 100644
--- a/include/linux/xarray.h
+++ b/include/linux/xarray.h
@@ -177,7 +177,7 @@ static inline bool xa_is_internal(const void *entry)
 static inline bool xa_is_err(const void *entry)
 {
        return unlikely(xa_is_internal(entry) &&
-                       (unsigned long)entry >= -((MAX_ERRNO << 2) + 2));
+                       entry >= xa_mk_internal(-MAX_ERRNO));
 }
 
 /**

(passes sparse & gcc, but ...)



[Index of Archives]     [Linux Ext4 Filesystem]     [Union Filesystem]     [Filesystem Testing]     [Ceph Users]     [Ecryptfs]     [AutoFS]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux Cachefs]     [Reiser Filesystem]     [Linux RAID]     [Samba]     [Device Mapper]     [CEPH Development]

  Powered by Linux