From 90d59676b316b1d1f5935eb3fb947c4b213553fa Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Tue, 2 Nov 2021 17:52:24 +0100 Subject: [PATCH] fd-util: make TAKE_FD free of double evaluation Better be safe than sorry. --- src/basic/fd-util.h | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/basic/fd-util.h b/src/basic/fd-util.h index dd5207bd88..f5cfcb4ede 100644 --- a/src/basic/fd-util.h +++ b/src/basic/fd-util.h @@ -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 */ -- 2.25.1