Skip to content

Commit

Permalink
include/linux/err.h: add a function to cast error-pointers to a retur…
Browse files Browse the repository at this point in the history
…n value

PTR_RET() can be used if you have an error-pointer and are only interested
in the eventual error value, but not the pointer.  Yields the usual 0 for
no error, -ESOMETHING otherwise.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
  • Loading branch information
Uwe Kleine-König authored and Linus Torvalds committed Mar 23, 2011
1 parent d404ab0 commit fa9ee9c
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions include/linux/err.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,14 @@ static inline void * __must_check ERR_CAST(const void *ptr)
return (void *) ptr;
}

static inline int __must_check PTR_RET(const void *ptr)
{
if (IS_ERR(ptr))
return PTR_ERR(ptr);
else
return 0;
}

#endif

#endif /* _LINUX_ERR_H */

0 comments on commit fa9ee9c

Please sign in to comment.