]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
memory_utils: add close_prot_errno_mov()
authorChristian Brauner <christian.brauner@ubuntu.com>
Tue, 2 Feb 2021 12:44:13 +0000 (13:44 +0100)
committerChristian Brauner <christian.brauner@ubuntu.com>
Tue, 2 Feb 2021 12:44:13 +0000 (13:44 +0100)
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
src/lxc/memory_utils.h

index d3b68a1e90aed060b81725b60d9077898ae57fb6..a7a9afcf3ed631592993239ab1370acbdb331915 100644 (file)
                fd = -EBADF;        \
        }
 
+#define close_prot_errno_move(fd, new_fd) \
+       if (fd >= 0) {                       \
+               int _e_ = errno;             \
+               close(fd);                   \
+               errno = _e_;                 \
+               fd = new_fd;                 \
+               new_fd = -EBADF;             \
+       }
+
 static inline void close_prot_errno_disarm_function(int *fd)
 {
        close_prot_errno_disarm(*fd);