Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

include/linux/err.h: add a function to cast error-pointers to a return 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>

authored by

Uwe Kleine-König and committed by
Linus Torvalds
fa9ee9c4 d404ab0a

+8
+8
include/linux/err.h
··· 52 52 return (void *) ptr; 53 53 } 54 54 55 + static inline int __must_check PTR_RET(const void *ptr) 56 + { 57 + if (IS_ERR(ptr)) 58 + return PTR_ERR(ptr); 59 + else 60 + return 0; 61 + } 62 + 55 63 #endif 56 64 57 65 #endif /* _LINUX_ERR_H */