datapath: Add IS_ERR_OR_NULL for backward compatibility.
[cascardo/ovs.git] / datapath / linux / compat / include / linux / err.h
1 #ifndef __LINUX_ERR_WRAPPER_H
2 #define __LINUX_ERR_WRAPPER_H 1
3
4 #include_next <linux/err.h>
5
6 #ifndef HAVE_ERR_CAST
7 /**
8  * ERR_CAST - Explicitly cast an error-valued pointer to another pointer type
9  * @ptr: The pointer to cast.
10  *
11  * Explicitly cast an error-valued pointer to another pointer type in such a
12  * way as to make it clear that's what's going on.
13  */
14 static inline void *ERR_CAST(const void *ptr)
15 {
16         /* cast away the const */
17         return (void *) ptr;
18 }
19 #endif /* HAVE_ERR_CAST */
20
21 #ifndef HAVE_IS_ERR_OR_NULL
22 static inline bool __must_check IS_ERR_OR_NULL(__force const void *ptr)
23 {
24         return !ptr || IS_ERR_VALUE((unsigned long)ptr);
25 }
26 #endif
27
28 #endif