diff options
author | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2022-10-06 14:41:50 +0200 |
---|---|---|
committer | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2022-10-10 09:12:21 +0200 |
commit | 50c5b991df302e7d143e8a859dd9d95c419d60fc (patch) | |
tree | 5c2d35e43dcbf1f831d52dba33d30c6c2eef1317 /src/basic/errno-util.h | |
parent | 6b7834fe5de3de690e6efb9467c61691c4b2f30f (diff) | |
download | systemd-50c5b991df302e7d143e8a859dd9d95c419d60fc.tar.gz |
basic/errno-util: add helper to protect and set errno in one step
This pattern is used in a few places. Those are changed in this patch.
Subsequent patches will add more.
Diffstat (limited to 'src/basic/errno-util.h')
-rw-r--r-- | src/basic/errno-util.h | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/src/basic/errno-util.h b/src/basic/errno-util.h index 648de50eb4..a71864ca60 100644 --- a/src/basic/errno-util.h +++ b/src/basic/errno-util.h @@ -22,6 +22,10 @@ static inline void _reset_errno_(int *saved_errno) { _saved_errno_ = -1; \ } while (false) +#define LOCAL_ERRNO(value) \ + PROTECT_ERRNO; \ + errno = abs(value) + static inline int negative_errno(void) { /* This helper should be used to shut up gcc if you know 'errno' is * negative. Instead of "return -errno;", use "return negative_errno();" |