diff mbox

[1/3] xen/err: Use static inlines and boolean types

Message ID 1477997170-7795-2-git-send-email-andrew.cooper3@citrix.com (mailing list archive)
State New, archived
Headers show

Commit Message

Andrew Cooper Nov. 1, 2016, 10:46 a.m. UTC
IS_ERR() and IS_ERR_OR_NULL() both return boolean values.

No functional change.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
---
CC: Jan Beulich <JBeulich@suse.com>
---
 xen/include/xen/err.h | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

Comments

Jan Beulich Nov. 2, 2016, 11:33 a.m. UTC | #1
>>> On 01.11.16 at 11:46, <andrew.cooper3@citrix.com> 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_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;
> +}

... 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
diff mbox

Patch

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 <xen/compiler.h>
+#include <xen/stdbool.h>
 #include <xen/errno.h>
 
 /*
@@ -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);
 }