tree-wide: more cleanup macros

parent 768e7ba2
...@@ -92,7 +92,8 @@ static struct lxc_proc_context_info *lxc_proc_get_context_info(pid_t pid) ...@@ -92,7 +92,8 @@ static struct lxc_proc_context_info *lxc_proc_get_context_info(pid_t pid)
info->lsm_label = lsm_process_label_get(pid); info->lsm_label = lsm_process_label_get(pid);
info->ns_inherited = 0; info->ns_inherited = 0;
memset(info->ns_fd, -1, sizeof(int) * LXC_NS_MAX); for (int i = 0; i < LXC_NS_MAX; i++)
info->ns_fd[i] = -EBADF;
return move_ptr(info); return move_ptr(info);
} }
......
...@@ -3547,7 +3547,7 @@ int lxc_setup(struct lxc_handler *handler) ...@@ -3547,7 +3547,7 @@ int lxc_setup(struct lxc_handler *handler)
return -1; return -1;
} }
if (handler->nsfd[LXC_NS_UTS] == -1) { if (handler->nsfd[LXC_NS_UTS] == -EBADF) {
ret = setup_utsname(lxc_conf->utsname); ret = setup_utsname(lxc_conf->utsname);
if (ret < 0) { if (ret < 0) {
ERROR("Failed to setup the utsname %s", name); ERROR("Failed to setup the utsname %s", name);
......
...@@ -122,9 +122,9 @@ static int lxc_try_preserve_ns(const int pid, const char *ns) ...@@ -122,9 +122,9 @@ static int lxc_try_preserve_ns(const int pid, const char *ns)
errno, "Failed to preserve %s namespace", errno, "Failed to preserve %s namespace",
ns); ns);
return log_error_errno(-EOPNOTSUPP, return log_warn_errno(-EOPNOTSUPP,
errno, "Kernel does not support preserving %s namespaces", errno, "Kernel does not support preserving %s namespaces",
ns); ns);
} }
return fd; return fd;
...@@ -646,7 +646,7 @@ void lxc_free_handler(struct lxc_handler *handler) ...@@ -646,7 +646,7 @@ void lxc_free_handler(struct lxc_handler *handler)
if (handler->conf && handler->conf->reboot == REBOOT_NONE) if (handler->conf && handler->conf->reboot == REBOOT_NONE)
if (handler->conf->maincmd_fd >= 0) if (handler->conf->maincmd_fd >= 0)
lxc_abstract_unix_close(handler->conf->maincmd_fd); close_prot_errno_disarm(handler->conf->maincmd_fd);
if (handler->monitor_status_fd >= 0) if (handler->monitor_status_fd >= 0)
close_prot_errno_disarm(handler->monitor_status_fd); close_prot_errno_disarm(handler->monitor_status_fd);
...@@ -892,8 +892,7 @@ out_aborting: ...@@ -892,8 +892,7 @@ out_aborting:
(void)lxc_set_state(name, handler, ABORTING); (void)lxc_set_state(name, handler, ABORTING);
out_close_maincmd_fd: out_close_maincmd_fd:
lxc_abstract_unix_close(conf->maincmd_fd); close_prot_errno_disarm(conf->maincmd_fd);
conf->maincmd_fd = -1;
return -1; return -1;
} }
...@@ -981,8 +980,7 @@ void lxc_fini(const char *name, struct lxc_handler *handler) ...@@ -981,8 +980,7 @@ void lxc_fini(const char *name, struct lxc_handler *handler)
* the command socket causing a new process to get ECONNREFUSED * the command socket causing a new process to get ECONNREFUSED
* because we haven't yet closed the command socket. * because we haven't yet closed the command socket.
*/ */
lxc_abstract_unix_close(handler->conf->maincmd_fd); close_prot_errno_disarm(handler->conf->maincmd_fd);
handler->conf->maincmd_fd = -EBADF;
TRACE("Closed command socket"); TRACE("Closed command socket");
/* This function will try to connect to the legacy lxc-monitord /* This function will try to connect to the legacy lxc-monitord
...@@ -1641,7 +1639,7 @@ static int lxc_spawn(struct lxc_handler *handler) ...@@ -1641,7 +1639,7 @@ static int lxc_spawn(struct lxc_handler *handler)
*/ */
if (!wants_to_map_ids) { if (!wants_to_map_ids) {
handler->pinfd = pin_rootfs(conf->rootfs.path); handler->pinfd = pin_rootfs(conf->rootfs.path);
if (handler->pinfd == -1) if (handler->pinfd == -EBADF)
INFO("Failed to pin the rootfs for container \"%s\"", handler->name); INFO("Failed to pin the rootfs for container \"%s\"", handler->name);
} }
......
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