aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/err.h
diff options
context:
space:
mode:
authorJani Nikula <ext-jani.1.nikula@nokia.com>2010-05-24 17:33:00 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2010-05-25 11:07:02 -0400
commite47103b1af5df52fa69e18b14d3012472f78817d (patch)
tree6652e56e361415a85ab5a7b888492e5ceef0cd94 /include/linux/err.h
parent1f85f87d4f81d1e5a2d502d48316a1bdc5acac0b (diff)
err.h: add __must_check to error pointer handlers
Add __must_check to error pointer handlers to have the compiler warn about mistakes like: if (err) ERR_PTR(err); It found two bugs: Mar 12 Nikula Jani [PATCH] enclosure: fix error path - actually return ERR_PTR() on error Mar 12 Nikula Jani [PATCH] sunrpc: fix error path - actually return ERR_PTR() on error Signed-off-by: Jani Nikula <ext-jani.1.nikula@nokia.com> Cc: Phil Carmody <ext-phil.2.carmody@nokia.com> Cc: Alexey Dobriyan <adobriyan@gmail.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'include/linux/err.h')
-rw-r--r--include/linux/err.h10
1 files changed, 5 insertions, 5 deletions
diff --git a/include/linux/err.h b/include/linux/err.h
index 1b12642636c7..448afc12c78a 100644
--- a/include/linux/err.h
+++ b/include/linux/err.h
@@ -19,22 +19,22 @@
19 19
20#define IS_ERR_VALUE(x) unlikely((x) >= (unsigned long)-MAX_ERRNO) 20#define IS_ERR_VALUE(x) unlikely((x) >= (unsigned long)-MAX_ERRNO)
21 21
22static inline void *ERR_PTR(long error) 22static inline void * __must_check ERR_PTR(long error)
23{ 23{
24 return (void *) error; 24 return (void *) error;
25} 25}
26 26
27static inline long PTR_ERR(const void *ptr) 27static inline long __must_check PTR_ERR(const void *ptr)
28{ 28{
29 return (long) ptr; 29 return (long) ptr;
30} 30}
31 31
32static inline long IS_ERR(const void *ptr) 32static inline long __must_check IS_ERR(const void *ptr)
33{ 33{
34 return IS_ERR_VALUE((unsigned long)ptr); 34 return IS_ERR_VALUE((unsigned long)ptr);
35} 35}
36 36
37static inline long IS_ERR_OR_NULL(const void *ptr) 37static inline long __must_check IS_ERR_OR_NULL(const void *ptr)
38{ 38{
39 return !ptr || IS_ERR_VALUE((unsigned long)ptr); 39 return !ptr || IS_ERR_VALUE((unsigned long)ptr);
40} 40}
@@ -46,7 +46,7 @@ static inline long IS_ERR_OR_NULL(const void *ptr)
46 * Explicitly cast an error-valued pointer to another pointer type in such a 46 * Explicitly cast an error-valued pointer to another pointer type in such a
47 * way as to make it clear that's what's going on. 47 * way as to make it clear that's what's going on.
48 */ 48 */
49static inline void *ERR_CAST(const void *ptr) 49static inline void * __must_check ERR_CAST(const void *ptr)
50{ 50{
51 /* cast away the const */ 51 /* cast away the const */
52 return (void *) ptr; 52 return (void *) ptr;