conf: cleanup macros make_anonymous_mount_file

parent ae2a3d81
...@@ -2358,10 +2358,10 @@ static const char nesting_helpers[] = ...@@ -2358,10 +2358,10 @@ static const char nesting_helpers[] =
FILE *make_anonymous_mount_file(struct lxc_list *mount, FILE *make_anonymous_mount_file(struct lxc_list *mount,
bool include_nesting_helpers) bool include_nesting_helpers)
{ {
__do_close_prot_errno int fd = -EBADF;
int ret; int ret;
char *mount_entry; char *mount_entry;
struct lxc_list *iterator; struct lxc_list *iterator;
int fd = -1;
fd = memfd_create(".lxc_mount_file", MFD_CLOEXEC); fd = memfd_create(".lxc_mount_file", MFD_CLOEXEC);
if (fd < 0) { if (fd < 0) {
...@@ -2387,30 +2387,25 @@ FILE *make_anonymous_mount_file(struct lxc_list *mount, ...@@ -2387,30 +2387,25 @@ FILE *make_anonymous_mount_file(struct lxc_list *mount,
ret = lxc_write_nointr(fd, mount_entry, len); ret = lxc_write_nointr(fd, mount_entry, len);
if (ret != len) if (ret != len)
goto on_error; return NULL;
ret = lxc_write_nointr(fd, "\n", 1); ret = lxc_write_nointr(fd, "\n", 1);
if (ret != 1) if (ret != 1)
goto on_error; return NULL;
} }
if (include_nesting_helpers) { if (include_nesting_helpers) {
ret = lxc_write_nointr(fd, nesting_helpers, ret = lxc_write_nointr(fd, nesting_helpers,
STRARRAYLEN(nesting_helpers)); STRARRAYLEN(nesting_helpers));
if (ret != STRARRAYLEN(nesting_helpers)) if (ret != STRARRAYLEN(nesting_helpers))
goto on_error; return NULL;
} }
ret = lseek(fd, 0, SEEK_SET); ret = lseek(fd, 0, SEEK_SET);
if (ret < 0) if (ret < 0)
goto on_error; return NULL;
return fdopen(fd, "r+");
on_error: return fdopen(move_fd(fd), "r+");
SYSERROR("Failed to write mount entry to temporary mount file");
close(fd);
return NULL;
} }
static int setup_mount_entries(const struct lxc_conf *conf, static int setup_mount_entries(const struct lxc_conf *conf,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment