提交 e7152b97 编写于 作者: D Dan Carpenter 提交者: Linus Torvalds

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: NDan Carpenter <dan.carpenter@oracle.com>
Acked-by: NChristopher Li <sparse@chrisli.org>
Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
上级 98bd8d05
...@@ -24,17 +24,17 @@ static inline void * __must_check ERR_PTR(long error) ...@@ -24,17 +24,17 @@ static inline void * __must_check ERR_PTR(long error)
return (void *) error; return (void *) error;
} }
static inline long __must_check PTR_ERR(const void *ptr) static inline long __must_check PTR_ERR(__force const void *ptr)
{ {
return (long) ptr; return (long) ptr;
} }
static inline long __must_check IS_ERR(const void *ptr) static inline long __must_check IS_ERR(__force const void *ptr)
{ {
return IS_ERR_VALUE((unsigned long)ptr); return IS_ERR_VALUE((unsigned long)ptr);
} }
static inline long __must_check IS_ERR_OR_NULL(const void *ptr) static inline long __must_check IS_ERR_OR_NULL(__force const void *ptr)
{ {
return !ptr || IS_ERR_VALUE((unsigned long)ptr); return !ptr || IS_ERR_VALUE((unsigned long)ptr);
} }
...@@ -46,13 +46,13 @@ static inline long __must_check IS_ERR_OR_NULL(const void *ptr) ...@@ -46,13 +46,13 @@ static inline long __must_check IS_ERR_OR_NULL(const void *ptr)
* Explicitly cast an error-valued pointer to another pointer type in such a * Explicitly cast an error-valued pointer to another pointer type in such a
* way as to make it clear that's what's going on. * way as to make it clear that's what's going on.
*/ */
static inline void * __must_check ERR_CAST(const void *ptr) static inline void * __must_check ERR_CAST(__force const void *ptr)
{ {
/* cast away the const */ /* cast away the const */
return (void *) ptr; return (void *) ptr;
} }
static inline int __must_check PTR_RET(const void *ptr) static inline int __must_check PTR_RET(__force const void *ptr)
{ {
if (IS_ERR(ptr)) if (IS_ERR(ptr))
return PTR_ERR(ptr); return PTR_ERR(ptr);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册