]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
tree-wide: more cleanup macros 3279/head
authorChristian Brauner <christian.brauner@ubuntu.com>
Mon, 9 Mar 2020 09:59:14 +0000 (10:59 +0100)
committerChristian Brauner <christian.brauner@ubuntu.com>
Mon, 9 Mar 2020 21:22:12 +0000 (22:22 +0100)
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
src/lxc/attach.c
src/lxc/conf.c
src/lxc/start.c

index 9eb794449e0cc7d5a2b093182589627452cc2a0e..26fd753ecce1683280a617867c0bca4184ecb4b3 100644 (file)
@@ -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->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);
 }
index a8d2ffadfda35660d23992790c3351244526a7f0..41127d6bd47c637ec66ea98a3ca681d6f1625d0a 100644 (file)
@@ -3547,7 +3547,7 @@ int lxc_setup(struct lxc_handler *handler)
                return -1;
        }
 
-       if (handler->nsfd[LXC_NS_UTS] == -1) {
+       if (handler->nsfd[LXC_NS_UTS] == -EBADF) {
                ret = setup_utsname(lxc_conf->utsname);
                if (ret < 0) {
                        ERROR("Failed to setup the utsname %s", name);
index 9e8069b2a2e6c01a56e3737fdf36e08fb00c40c6..dad4ff9843d7c4b345a035194bc2346e2f3a9737 100644 (file)
@@ -122,9 +122,9 @@ static int lxc_try_preserve_ns(const int pid, const char *ns)
                                               errno, "Failed to preserve %s namespace",
                                               ns);
 
-               return log_error_errno(-EOPNOTSUPP,
-                                      errno, "Kernel does not support preserving %s namespaces",
-                                      ns);
+               return log_warn_errno(-EOPNOTSUPP,
+                                     errno, "Kernel does not support preserving %s namespaces",
+                                     ns);
        }
 
        return fd;
@@ -646,7 +646,7 @@ void lxc_free_handler(struct lxc_handler *handler)
 
        if (handler->conf && handler->conf->reboot == REBOOT_NONE)
                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)
                close_prot_errno_disarm(handler->monitor_status_fd);
@@ -892,8 +892,7 @@ out_aborting:
        (void)lxc_set_state(name, handler, ABORTING);
 
 out_close_maincmd_fd:
-       lxc_abstract_unix_close(conf->maincmd_fd);
-       conf->maincmd_fd = -1;
+       close_prot_errno_disarm(conf->maincmd_fd);
        return -1;
 }
 
@@ -981,8 +980,7 @@ void lxc_fini(const char *name, struct lxc_handler *handler)
                 * the command socket causing a new process to get ECONNREFUSED
                 * because we haven't yet closed the command socket.
                 */
-               lxc_abstract_unix_close(handler->conf->maincmd_fd);
-               handler->conf->maincmd_fd = -EBADF;
+               close_prot_errno_disarm(handler->conf->maincmd_fd);
                TRACE("Closed command socket");
 
                /* This function will try to connect to the legacy lxc-monitord
@@ -1641,7 +1639,7 @@ static int lxc_spawn(struct lxc_handler *handler)
         */
        if (!wants_to_map_ids) {
                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);
        }