summaryrefslogtreecommitdiffstats
path: root/include/linux/err.h
diff options
context:
space:
mode:
authorDan Carpenter <dan.carpenter@oracle.com>2013-07-03 18:04:54 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2013-07-03 19:07:41 -0400
commite7152b97f38f1f5b915c719e6a3040697a700a16 (patch)
tree78f73f1c4791683f38b5894b0c7f12d9e9b6006d /include/linux/err.h
parent98bd8d05ea5798ff3179ee33f0ca2789722ecc5a (diff)
err.h: IS_ERR() can accept __user pointers
Sparse generates a false positive when you pass a __user or __iomem pointer to the IS_ERR() functions. drivers/rtc/rtc-ds1286.c:344:36: sparse: incorrect type in argument 1 (different address spaces) drivers/rtc/rtc-ds1286.c:344:36: expected void const *ptr drivers/rtc/rtc-ds1286.c:344:36: got unsigned int [noderef] [usertype] <asn:2>*rtcregs We can silence these by adding a __force here and upgrading to Sparse v0.4.5-rc1 or later. This change has no effect when using current Sparse releases. Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com> Acked-by: Christopher Li <sparse@chrisli.org> 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 f2edce25a76b..221fcfb676c4 100644
--- a/include/linux/err.h
+++ b/include/linux/err.h
@@ -24,17 +24,17 @@ static inline void * __must_check ERR_PTR(long error)
24 return (void *) error; 24 return (void *) error;
25} 25}
26 26
27static inline long __must_check PTR_ERR(const void *ptr) 27static inline long __must_check PTR_ERR(__force const void *ptr)
28{ 28{
29 return (long) ptr; 29 return (long) ptr;
30} 30}
31 31
32static inline long __must_check IS_ERR(const void *ptr) 32static inline long __must_check IS_ERR(__force 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 __must_check IS_ERR_OR_NULL(const void *ptr) 37static inline long __must_check IS_ERR_OR_NULL(__force 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,13 +46,13 @@ static inline long __must_check 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 * __must_check ERR_CAST(const void *ptr) 49static inline void * __must_check ERR_CAST(__force const void *ptr)
50{ 50{
51 /* cast away the const */ 51 /* cast away the const */
52 return (void *) ptr; 52 return (void *) ptr;
53} 53}
54 54
55static inline int __must_check PTR_RET(const void *ptr) 55static inline int __must_check PTR_RET(__force const void *ptr)
56{ 56{
57 if (IS_ERR(ptr)) 57 if (IS_ERR(ptr))
58 return PTR_ERR(ptr); 58 return PTR_ERR(ptr);