mirror of
git://git.kernel.org/pub/scm/linux/kernel/git/xiang/erofs.git
synced 2026-10-30 13:52:50 +01:00
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 <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
This commit is contained in:
1 parent
d404ab0a11
commit
fa9ee9c4b9
1 file changed
+8
@@ -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 */
|
||||
Reference in new issue
Block a user