From: Lennart Poettering Date: Tue, 2 Nov 2021 16:52:24 +0000 (+0100) Subject: fd-util: make TAKE_FD free of double evaluation X-Git-Tag: v250-rc1~364^2~6 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=90d59676b316b1d1f5935eb3fb947c4b213553fa;p=thirdparty%2Fsystemd.git fd-util: make TAKE_FD free of double evaluation Better be safe than sorry. --- diff --git a/src/basic/fd-util.h b/src/basic/fd-util.h index dd5207bd88a..f5cfcb4edeb 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 */