Re: [Xen-devel] [PATCH 1/3] xen/err: Use static inlines and boolean types

2016-11-02 Thread Jan Beulich
>>> On 01.11.16 at 11:46,  wrote:
> IS_ERR() and IS_ERR_OR_NULL() both return boolean values.
> 
> No functional change.

I'm definitely fine with this part. However, ...

> @@ -14,7 +15,10 @@
>   */
>  #define MAX_ERRNO4095
>  
> -#define IS_ERR_VALUE(x) unlikely((x) >= (unsigned long)-MAX_ERRNO)
> +static inline bool IS_ERR_VALUE(unsigned long x)
> +{
> + return x >= (unsigned long)-MAX_ERRNO;
> +}

... for this one I'd like us to consider following Linux commit
aa00edc128 instead, which I don't think can be achieved by an
inline function alone.

Jan


___
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel


[Xen-devel] [PATCH 1/3] xen/err: Use static inlines and boolean types

2016-11-01 Thread Andrew Cooper
IS_ERR() and IS_ERR_OR_NULL() both return boolean values.

No functional change.

Signed-off-by: Andrew Cooper 
---
CC: Jan Beulich 
---
 xen/include/xen/err.h | 10 +++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/xen/include/xen/err.h b/xen/include/xen/err.h
index 2f29b57..ef77992 100644
--- a/xen/include/xen/err.h
+++ b/xen/include/xen/err.h
@@ -2,6 +2,7 @@
 #define __XEN_ERR_H__
 
 #include 
+#include 
 #include 
 
 /*
@@ -14,7 +15,10 @@
  */
 #define MAX_ERRNO  4095
 
-#define IS_ERR_VALUE(x) unlikely((x) >= (unsigned long)-MAX_ERRNO)
+static inline bool IS_ERR_VALUE(unsigned long x)
+{
+   return x >= (unsigned long)-MAX_ERRNO;
+}
 
 static inline void *__must_check ERR_PTR(long error)
 {
@@ -26,12 +30,12 @@ static inline long __must_check PTR_ERR(const void *ptr)
return (long)ptr;
 }
 
-static inline long __must_check IS_ERR(const void *ptr)
+static inline bool __must_check IS_ERR(const void *ptr)
 {
return IS_ERR_VALUE((unsigned long)ptr);
 }
 
-static inline long __must_check IS_ERR_OR_NULL(const void *ptr)
+static inline bool __must_check IS_ERR_OR_NULL(const void *ptr)
 {
return !ptr || IS_ERR_VALUE((unsigned long)ptr);
 }
-- 
2.1.4


___
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel