fd-util: make TAKE_FD free of double evaluation

Better be safe than sorry.
This commit is contained in:
Lennart Poettering
2021-11-03 15:22:18 +01:00
parent ab7b261663
commit 90d59676b3
+4 -3
View File
@@ -91,9 +91,10 @@ static inline int make_null_stdio(void) {
/* Like TAKE_PTR() but for file descriptors, resetting them to -1 */
#define TAKE_FD(fd) \
({ \
int _fd_ = (fd); \
(fd) = -1; \
_fd_; \
int *_fd_ = &(fd); \
int _ret_ = *_fd_; \
*_fd_ = -1; \
_ret_; \
})
/* Like free_and_replace(), but for file descriptors */