]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
log: change WARN macro using strerror to SYSWARN
author2xsec <dh48.jeong@samsung.com>
Tue, 26 Jun 2018 05:06:09 +0000 (14:06 +0900)
committer2xsec <dh48.jeong@samsung.com>
Tue, 26 Jun 2018 08:26:38 +0000 (17:26 +0900)
Signed-off-by: 2xsec <dh48.jeong@samsung.com>
12 files changed:
src/lxc/attach.c
src/lxc/caps.c
src/lxc/cgroups/cgfsng.c
src/lxc/commands.c
src/lxc/conf.c
src/lxc/monitor.c
src/lxc/network.c
src/lxc/seccomp.c
src/lxc/start.c
src/lxc/storage/btrfs.c
src/lxc/storage/overlay.c
src/lxc/terminal.c

index 429a5d86cdbe1ac0569682e618d1d46eb63ff8b9..7f1fb9f6b7fb1270196ee4b580656591097ce86e 100644 (file)
@@ -380,7 +380,7 @@ static int lxc_attach_set_environment(struct lxc_proc_context_info *init_ctx,
                                if (extra_keep_store[i]) {
                                        ret = setenv(extra_keep[i], extra_keep_store[i], 1);
                                        if (ret < 0)
-                                               WARN("%s - Failed to set environment variable", strerror(errno));
+                                               SYSWARN("Failed to set environment variable");
                                }
                                free(extra_keep_store[i]);
                        }
@@ -395,13 +395,13 @@ static int lxc_attach_set_environment(struct lxc_proc_context_info *init_ctx,
                if (!path_kept) {
                        ret = setenv("PATH", "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin", 1);
                        if (ret < 0)
-                               WARN("%s - Failed to set environment variable", strerror(errno));
+                               SYSWARN("Failed to set environment variable");
                }
        }
 
        ret = putenv("container=lxc");
        if (ret < 0) {
-               WARN("%s - Failed to set environment variable", strerror(errno));
+               SYSWARN("Failed to set environment variable");
                return -1;
        }
 
@@ -435,7 +435,7 @@ static int lxc_attach_set_environment(struct lxc_proc_context_info *init_ctx,
 
                        ret = putenv(p);
                        if (ret < 0)
-                               WARN("%s - Failed to set environment variable", strerror(errno));
+                               SYSWARN("Failed to set environment variable");
                }
        }
 
index 6665af217609d02e9ec336ed62c127a598df318c..9e6a08a9fb699a7160843a3488e4a72300760a0c 100644 (file)
@@ -196,8 +196,7 @@ int lxc_ambient_caps_up(void)
        for (cap = 0; cap <= last_cap; cap++) {
                ret = prctl(PR_CAP_AMBIENT, PR_CAP_AMBIENT_RAISE, cap, 0, 0);
                if (ret < 0) {
-                       WARN("%s - Failed to raise ambient capability %d",
-                            strerror(errno), cap);
+                       SYSWARN("Failed to raise ambient capability %d", cap);
                        goto out;
                }
        }
index fedb9a06367d627555587dc74d67342a883afe0e..b514a7bb6f7b087b7465a2eec799ffffb309eb82 100644 (file)
@@ -1082,14 +1082,14 @@ static int recursive_destroy(char *dirname)
        ret = rmdir(dirname);
        if (ret < 0) {
                if (!r)
-                       WARN("%s - Failed to delete \"%s\"", strerror(errno), dirname);
+                       SYSWARN("Failed to delete \"%s\"", dirname);
                r = -1;
        }
 
        ret = closedir(dir);
        if (ret < 0) {
                if (!r)
-                       WARN("%s - Failed to delete \"%s\"", strerror(errno), dirname);
+                       SYSWARN("Failed to delete \"%s\"", dirname);
                r = -1;
        }
 
@@ -1398,15 +1398,13 @@ static int chowmod(char *path, uid_t chown_uid, gid_t chown_gid,
 
        ret = chown(path, chown_uid, chown_gid);
        if (ret < 0) {
-               WARN("%s - Failed to chown(%s, %d, %d)", strerror(errno), path,
-                    (int)chown_uid, (int)chown_gid);
+               SYSWARN("Failed to chown(%s, %d, %d)", path, (int)chown_uid, (int)chown_gid);
                return -1;
        }
 
        ret = chmod(path, chmod_mode);
        if (ret < 0) {
-               WARN("%s - Failed to chmod(%s, %d)", strerror(errno), path,
-                    (int)chmod_mode);
+               SYSWARN("Failed to chmod(%s, %d)", path, (int)chmod_mode);
                return -1;
        }
 
index 8c1a03d5848c77ad6273b44f784c2df0dc27067a..ca77affd4d49cccb6fbf931f02d23ebe8be0db13 100644 (file)
@@ -126,8 +126,9 @@ static int lxc_cmd_rsp_recv(int sock, struct lxc_cmd_rr *cmd)
 
        ret = lxc_abstract_unix_recv_fds(sock, &rspfd, 1, rsp, sizeof(*rsp));
        if (ret < 0) {
-               WARN("%s - Failed to receive response for command \"%s\"",
-                    strerror(errno), lxc_cmd_str(cmd->req.cmd));
+               SYSWARN("Failed to receive response for command \"%s\"",
+                       lxc_cmd_str(cmd->req.cmd));
+
                if (errno == ECONNRESET)
                        return -ECONNRESET;
 
@@ -218,8 +219,7 @@ static int lxc_cmd_rsp_send(int fd, struct lxc_cmd_rsp *rsp)
 
        ret = send(fd, rsp->data, rsp->datalen, 0);
        if (ret < 0 || ret != (ssize_t)rsp->datalen) {
-               WARN("%s - Failed to send command response data %zd",
-                    strerror(errno), ret);
+               SYSWARN("Failed to send command response data %zd", ret);
                return -1;
        }
 
index 4e7dc379b64287a25c1f6bcf7bc5beb971fe297b..cc97ea9d1c082aba91b6ca48493db69332fecef6 100644 (file)
@@ -986,15 +986,13 @@ int lxc_allocate_ttys(struct lxc_conf *conf)
                /* Prevent leaking the file descriptors to the container */
                ret = fcntl(tty->master, F_SETFD, FD_CLOEXEC);
                if (ret < 0)
-                       WARN("Failed to set FD_CLOEXEC flag on master fd %d of "
-                            "tty device \"%s\": %s",
-                            tty->master, tty->name, strerror(errno));
+                       SYSWARN("Failed to set FD_CLOEXEC flag on master fd %d of "
+                               "tty device \"%s\"", tty->master, tty->name);
 
                ret = fcntl(tty->slave, F_SETFD, FD_CLOEXEC);
                if (ret < 0)
-                       WARN("Failed to set FD_CLOEXEC flag on slave fd %d of "
-                            "tty device \"%s\": %s",
-                            tty->slave, tty->name, strerror(errno));
+                       SYSWARN("Failed to set FD_CLOEXEC flag on slave fd %d of "
+                               "tty device \"%s\"", tty->slave, tty->name);
 
                tty->busy = 0;
        }
@@ -1549,7 +1547,7 @@ static int lxc_setup_devpts(struct lxc_conf *conf)
 
        ret = umount2("/dev/pts", MNT_DETACH);
        if (ret < 0)
-               WARN("%s - Failed to unmount old devpts instance", strerror(errno));
+               SYSWARN("Failed to unmount old devpts instance");
        else
                DEBUG("Unmounted old devpts instance");
 
index ed223a5b29da4e95241d1e0ab7e3e3beb574ad85..5c866ae84b08f538d233c8f33836f301fd400656 100644 (file)
@@ -113,7 +113,7 @@ static void lxc_monitor_fifo_send(struct lxc_msg *msg, const char *lxcpath)
                if (errno == ENXIO || errno == ENOENT)
                        return;
 
-               WARN("%s - Failed to open fifo to send message", strerror(errno));
+               SYSWARN("Failed to open fifo to send message");
                return;
        }
 
index c147d10baa27e713263e156bc5153d05c2a6fb32..3f15590b2b70fa77c9163b3931853d82d1ebcd7a 100644 (file)
@@ -2599,10 +2599,10 @@ bool lxc_delete_network_priv(struct lxc_handler *handler)
                             netdev->name[0] != '\0' ? netdev->name : "(null)",
                             netdev->ifindex);
                } else if (ret < 0) {
-                       WARN("Failed to remove interface \"%s\" with "
-                            "index %d: %s",
-                            netdev->name[0] != '\0' ? netdev->name : "(null)",
-                            netdev->ifindex, strerror(-ret));
+                       errno = -ret;
+                       SYSWARN("Failed to remove interface \"%s\" with index %d",
+                               netdev->name[0] != '\0' ? netdev->name : "(null)",
+                               netdev->ifindex);
                        goto clear_ifindices;
                }
                INFO("Removed interface \"%s\" with index %d",
@@ -2624,8 +2624,9 @@ bool lxc_delete_network_priv(struct lxc_handler *handler)
 
                ret = lxc_netdev_delete_by_name(hostveth);
                if (ret < 0) {
-                       WARN("Failed to remove interface \"%s\" from \"%s\": %s",
-                            hostveth, netdev->link, strerror(-ret));
+                       errno = -ret;
+                       SYSWARN("Failed to remove interface \"%s\" from \"%s\"",
+                               hostveth, netdev->link);
                        goto clear_ifindices;
                }
                INFO("Removed interface \"%s\" from \"%s\"", hostveth, netdev->link);
index 1fbaa429b66541bb4e56c70680fc91be75cff8bf..80a7ef17680af36993e439b1fd43bad8e5b81006 100644 (file)
@@ -427,8 +427,10 @@ scmp_filter_ctx get_new_ctx(enum lxc_hostarch_t n_arch,
 
 #ifdef SCMP_FLTATR_ATL_TSKIP
        ret = seccomp_attr_set(ctx, SCMP_FLTATR_ATL_TSKIP, 1);
-       if (ret < 0)
-               WARN("%s - Failed to turn on seccomp nop-skip, continuing", strerror(-ret));
+       if (ret < 0) {
+               errno = -ret;
+               SYSWARN("Failed to turn on seccomp nop-skip, continuing");
+       }
 #endif
 
        ret = seccomp_arch_exist(ctx, arch);
@@ -730,8 +732,10 @@ static int parse_config_v2(FILE *f, char *line, size_t *line_bufsz, struct lxc_c
 
 #ifdef SCMP_FLTATR_ATL_TSKIP
                ret = seccomp_attr_set(conf->seccomp_ctx, SCMP_FLTATR_ATL_TSKIP, 1);
-               if (ret < 0)
-                       WARN("%s - Failed to turn on seccomp nop-skip, continuing", strerror(-ret));
+               if (ret < 0) {
+                       errno = -ret;
+                       SYSWARN("Failed to turn on seccomp nop-skip, continuing");
+               }
 #endif
        }
 
@@ -1156,11 +1160,13 @@ int lxc_read_seccomp_config(struct lxc_conf *conf)
                ERROR("%s - Failed to turn off no-new-privs", strerror(-ret));
                return -1;
        }
+
 #ifdef SCMP_FLTATR_ATL_TSKIP
        ret = seccomp_attr_set(conf->seccomp_ctx, SCMP_FLTATR_ATL_TSKIP, 1);
-       if (ret < 0)
-               WARN("%s - Failed to turn on seccomp nop-skip, continuing",
-                    strerror(-ret));
+       if (ret < 0) {
+               errno = -ret;
+               SYSWARN("Failed to turn on seccomp nop-skip, continuing");
+       }
 #endif
 
        f = fopen(conf->seccomp, "r");
@@ -1203,8 +1209,10 @@ int lxc_seccomp_load(struct lxc_conf *conf)
            lxc_log_fd >= 0) {
                ret = seccomp_export_pfc(conf->seccomp_ctx, lxc_log_fd);
                /* Just give an warning when export error */
-               if (ret < 0)
-                       WARN("%s - Failed to export seccomp filter to log file", strerror(-ret));
+               if (ret < 0) {
+                       errno = -ret;
+                       SYSWARN("Failed to export seccomp filter to log file");
+               }
        }
 #endif
 
index 2dae6652ad72e1b4bd3cd44f0762d9e39a4d6189..8359d356a7540d9a604313e2453cfaa1df807921 100644 (file)
@@ -160,8 +160,7 @@ static int lxc_try_preserve_ns(const int pid, const char *ns)
                        return -EINVAL;
                }
 
-               WARN("%s - Kernel does not support preserving %s namespaces",
-                    strerror(errno), ns);
+               SYSWARN("Kernel does not support preserving %s namespaces", ns);
                return -EOPNOTSUPP;
        }
 
@@ -228,7 +227,7 @@ int lxc_check_inherited(struct lxc_conf *conf, bool closeall,
 restart:
        dir = opendir("/proc/self/fd");
        if (!dir) {
-               WARN("%s - Failed to open directory", strerror(errno));
+               SYSWARN("Failed to open directory");
                return -1;
        }
 
@@ -987,7 +986,7 @@ void lxc_fini(const char *name, struct lxc_handler *handler)
        /* Reset mask set by setup_signal_fd. */
        ret = pthread_sigmask(SIG_SETMASK, &handler->oldmask, NULL);
        if (ret < 0)
-               WARN("%s - Failed to restore signal mask", strerror(errno));
+               SYSWARN("Failed to restore signal mask");
 
        lxc_terminal_delete(&handler->conf->console);
        lxc_delete_tty(&handler->conf->ttys);
index f30dc47035700f2a590eeecf136d997a4430dd3a..ad5d51e7e87cc30d7a16225bff0fe124a8ca42ec 100644 (file)
@@ -132,8 +132,7 @@ int btrfs_list_get_path_rootid(int fd, u64 *treeid)
 
        ret = ioctl(fd, BTRFS_IOC_INO_LOOKUP, &args);
        if (ret < 0) {
-               WARN("Warning: can't perform the search -%s\n",
-                               strerror(errno));
+               SYSWARN("Warning: can't perform the search");
                return ret;
        }
        *treeid = args.treeid;
index 7acb9eac1c888b8ebc53576f4a51b7007b69232e..0d1f818207f098da547e050e36812c67f6b9b1c5 100644 (file)
@@ -786,9 +786,9 @@ int ovl_mkdir(const struct mntent *mntent, const struct lxc_rootfs *rootfs,
                else if (!strncmp(upperdir, lxcpath, dirlen) &&
                         strncmp(upperdir, rootfs_dir, rootfslen))
                        ret = mkdir_p(upperdir, 0755);
+
                if (ret < 0)
-                       WARN("Failed to create directory \"%s\": %s", upperdir,
-                            strerror(errno));
+                       SYSWARN("Failed to create directory \"%s\"", upperdir);
        }
 
        ret = 0;
@@ -798,9 +798,9 @@ int ovl_mkdir(const struct mntent *mntent, const struct lxc_rootfs *rootfs,
                else if (!strncmp(workdir, lxcpath, dirlen) &&
                         strncmp(workdir, rootfs_dir, rootfslen))
                        ret = mkdir_p(workdir, 0755);
+
                if (ret < 0)
-                       WARN("Failed to create directory \"%s\": %s", workdir,
-                            strerror(errno));
+                       SYSWARN("Failed to create directory \"%s\"", workdir);
        }
 
        fret = 0;
index e1089acf3eb4bf5fa4bbd855bddc910a126fab21..b942e4921436663a7f8282b9339d7dc2cd9387c1 100644 (file)
@@ -209,7 +209,7 @@ void lxc_terminal_signal_fini(struct lxc_terminal_state *ts)
                close(ts->sigfd);
 
                if (pthread_sigmask(SIG_SETMASK, &ts->oldmask, NULL) < 0)
-                       WARN("%s - Failed to restore signal mask", strerror(errno));
+                       SYSWARN("Failed to restore signal mask");
        }
 
        if (isatty(ts->stdinfd))
@@ -771,7 +771,7 @@ void lxc_terminal_delete(struct lxc_terminal *terminal)
        if (terminal->tios && terminal->peer >= 0) {
                ret = tcsetattr(terminal->peer, TCSAFLUSH, terminal->tios);
                if (ret < 0)
-                       WARN("%s - Failed to set old terminal settings", strerror(errno));
+                       SYSWARN("Failed to set old terminal settings");
        }
        free(terminal->tios);
        terminal->tios = NULL;
@@ -1106,8 +1106,7 @@ restore_tios:
        if (istty) {
                istty = tcsetattr(stdinfd, TCSAFLUSH, &oldtios);
                if (istty < 0)
-                       WARN("%s - Failed to restore terminal properties",
-                            strerror(errno));
+                       SYSWARN("Failed to restore terminal properties");
        }
 
 close_mainloop: