Skip to content

Commit

Permalink
memory_utils: add close_prot_errno_mov()
Browse files Browse the repository at this point in the history
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
  • Loading branch information
Christian Brauner committed Feb 26, 2021
1 parent f3b1c04 commit 826de44
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/lxc/memory_utils.h
Expand Up @@ -29,6 +29,15 @@
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);
Expand Down

0 comments on commit 826de44

Please sign in to comment.