Finally decided to put the often copied RETURN_AND_SET_ERRNO() macro
into a header. This version instantiates the given argument only once. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@24900 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -0,0 +1,18 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2008, Ingo Weinhold, [email protected].
|
||||||
|
* Distributed under the terms of the MIT License.
|
||||||
|
*/
|
||||||
|
#ifndef _SYSCALL_UTILS_H
|
||||||
|
#define _SYSCALL_UTILS_H
|
||||||
|
|
||||||
|
#define RETURN_AND_SET_ERRNO(err) \
|
||||||
|
do { \
|
||||||
|
__typeof(err) raseResult = (err); \
|
||||||
|
if (raseResult < 0) { \
|
||||||
|
errno = raseResult; \
|
||||||
|
return -1; \
|
||||||
|
} \
|
||||||
|
return raseResult; \
|
||||||
|
} while (false)
|
||||||
|
|
||||||
|
#endif // _SYSCALL_UTILS_H
|
||||||
Reference in New Issue
Block a user