projects/linux·commit fa9ee9c4

include/linux/err.h: add a function to cast error-pointers to a return value

fa9ee9c4 · Uwe Kleine-König <[email protected]> · 2011-03-22 16:34:05 -07:00

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]>
Commit
fa9ee9c4b9885dfdf8eccac19b8b4fc8a7c53288
Parents
d404ab0a

Changes

1 files changed · +8 −0

FileStatusAddDelContent
include/linux/err.hmodified+8−0View file

include/linux/err.h

View file
diff --git a/include/linux/err.h b/include/linux/err.h
index 448afc1..f2edce2 100644
--- a/include/linux/err.h
+++ b/include/linux/err.h
@@ -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 */