.. | .. |
---|
20 | 20 | * Userspace note: |
---|
21 | 21 | * The same principle works for userspace, because 'error' pointers |
---|
22 | 22 | * fall down to the unused hole far from user space, as described |
---|
23 | | - * in Documentation/x86/x86_64/mm.txt for x86_64 arch: |
---|
| 23 | + * in Documentation/x86/x86_64/mm.rst for x86_64 arch: |
---|
24 | 24 | * |
---|
25 | 25 | * 0000000000000000 - 00007fffffffffff (=47 bits) user space, different per mm hole caused by [48:63] sign extension |
---|
26 | 26 | * ffffffffffe00000 - ffffffffffffffff (=2 MB) unused hole |
---|
.. | .. |
---|
52 | 52 | return unlikely(!ptr) || IS_ERR_VALUE((unsigned long)ptr); |
---|
53 | 53 | } |
---|
54 | 54 | |
---|
| 55 | +static inline int __must_check PTR_ERR_OR_ZERO(__force const void *ptr) |
---|
| 56 | +{ |
---|
| 57 | + if (IS_ERR(ptr)) |
---|
| 58 | + return PTR_ERR(ptr); |
---|
| 59 | + else |
---|
| 60 | + return 0; |
---|
| 61 | +} |
---|
| 62 | + |
---|
| 63 | +/** |
---|
| 64 | + * ERR_CAST - Explicitly cast an error-valued pointer to another pointer type |
---|
| 65 | + * @ptr: The pointer to cast. |
---|
| 66 | + * |
---|
| 67 | + * Explicitly cast an error-valued pointer to another pointer type in such a |
---|
| 68 | + * way as to make it clear that's what's going on. |
---|
| 69 | + */ |
---|
| 70 | +static inline void * __must_check ERR_CAST(__force const void *ptr) |
---|
| 71 | +{ |
---|
| 72 | + /* cast away the const */ |
---|
| 73 | + return (void *) ptr; |
---|
| 74 | +} |
---|
55 | 75 | #endif /* _LINUX_ERR_H */ |
---|