]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
tree-wide: s/syerrno_set()/syserror_set()/g
authorChristian Brauner <christian.brauner@ubuntu.com>
Thu, 25 Feb 2021 23:26:26 +0000 (00:26 +0100)
committerChristian Brauner <christian.brauner@ubuntu.com>
Thu, 25 Feb 2021 23:37:50 +0000 (00:37 +0100)
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
src/lxc/af_unix.c
src/lxc/cgroups/cgfsng.c
src/lxc/cgroups/cgroup2_devices.c
src/lxc/commands.c
src/lxc/confile.c
src/lxc/log.h

index f1d36c5dd3d797164212417757ce820d69619e4a..493599cd3d0ed386a0eca529356cb31bc4ea8038 100644 (file)
@@ -228,14 +228,14 @@ again:
                                for (idx = 0; idx < num_raw; idx++)
                                        close(fds_raw[idx]);
 
-                               return syserrno_set(-EFBIG, "Received excessive number of file descriptors");
+                               return syserror_set(-EFBIG, "Received excessive number of file descriptors");
                        }
 
                        if (msg.msg_flags & MSG_CTRUNC) {
                                for (idx = 0; idx < num_raw; idx++)
                                        close(fds_raw[idx]);
 
-                               return syserrno_set(-EFBIG, "Control message was truncated; closing all fds and rejecting incomplete message");
+                               return syserror_set(-EFBIG, "Control message was truncated; closing all fds and rejecting incomplete message");
                        }
 
                        if (ret_fds->fd_count_max > num_raw) {
@@ -243,7 +243,7 @@ again:
                                        for (idx = 0; idx < num_raw; idx++)
                                                close(fds_raw[idx]);
 
-                                       return syserrno_set(-EINVAL, "Received fewer file descriptors than we expected %u != %u",
+                                       return syserror_set(-EINVAL, "Received fewer file descriptors than we expected %u != %u",
                                                            ret_fds->fd_count_max, num_raw);
                                }
 
@@ -261,7 +261,7 @@ again:
                                        for (idx = 0; idx < num_raw; idx++)
                                                close(fds_raw[idx]);
 
-                                       return syserrno_set(-EINVAL, "Received more file descriptors than we expected %u != %u",
+                                       return syserror_set(-EINVAL, "Received more file descriptors than we expected %u != %u",
                                                            ret_fds->fd_count_max, num_raw);
                                }
 
@@ -280,7 +280,7 @@ again:
                                for (idx = 0; idx < num_raw; idx++)
                                        close(fds_raw[idx]);
 
-                               return syserrno_set(-EINVAL, "Invalid flag combination; closing to not risk leaking fds %u != %u",
+                               return syserror_set(-EINVAL, "Invalid flag combination; closing to not risk leaking fds %u != %u",
                                                    ret_fds->fd_count_max, num_raw);
                        }
 
@@ -296,7 +296,7 @@ again:
                /* We expected to receive file descriptors. */
                if ((ret_fds->flags & UNIX_FDS_ACCEPT_MASK) &&
                    !(ret_fds->flags & UNIX_FDS_ACCEPT_NONE))
-                       return syserrno_set(-EINVAL, "Received no file descriptors");
+                       return syserror_set(-EINVAL, "Received no file descriptors");
        }
 
        return ret;
index 7d8fec5e850a3ef9e48cfd1b9eb8af159c4bbdff..f9d074c39835e286830126e02dc6c82efeba0dc0 100644 (file)
@@ -425,7 +425,7 @@ static int cgroup_hierarchy_add(struct cgroup_ops *ops, int dfd_mnt, char *mnt,
        int idx;
 
        if (abspath(base_cgroup))
-               return syserrno_set(-EINVAL, "Container base path must be relative to controller mount");
+               return syserror_set(-EINVAL, "Container base path must be relative to controller mount");
 
        new = zalloc(sizeof(*new));
        if (!new)
@@ -736,10 +736,10 @@ static int __cgroup_tree_create(int dfd_base, const char *path, mode_t mode,
                 * absolute nor walks upwards.
                 */
                if (abspath(cur))
-                       return syserrno_set(-EINVAL, "No absolute paths allowed");
+                       return syserror_set(-EINVAL, "No absolute paths allowed");
 
                if (strnequal(cur, "..", STRLITERALLEN("..")))
-                       return syserrno_set(-EINVAL, "No upward walking paths allowed");
+                       return syserror_set(-EINVAL, "No upward walking paths allowed");
 
                ret = mkdirat(dfd_cur, cur, mode);
                if (ret < 0) {
@@ -768,7 +768,7 @@ static int __cgroup_tree_create(int dfd_base, const char *path, mode_t mode,
        /* The final cgroup must be succesfully creatd by us. */
        if (ret) {
                if (ret != -EEXIST || !eexist_ignore)
-                       return syserrno_set(ret, "Creating the final cgroup %d(%s) failed", dfd_base, path);
+                       return syserror_set(ret, "Creating the final cgroup %d(%s) failed", dfd_base, path);
        }
 
        return move_fd(dfd_final);
@@ -1339,7 +1339,7 @@ static int chown_cgroup_wrapper(void *data)
                int dirfd = arg->hierarchies[i]->dfd_con;
 
                if (dirfd < 0)
-                       return syserrno_set(-EBADF, "Invalid cgroup file descriptor");
+                       return syserror_set(-EBADF, "Invalid cgroup file descriptor");
 
                (void)fchowmodat(dirfd, "", destuid, nsgid, 0775);
 
@@ -2787,7 +2787,7 @@ static int bpf_device_cgroup_prepare(struct cgroup_ops *ops,
        else
                ret = device_cgroup_rule_parse(&device_item, key, val);
        if (ret < 0)
-               return syserrno_set(EINVAL, "Failed to parse device rule %s=%s", key, val);
+               return syserror_set(EINVAL, "Failed to parse device rule %s=%s", key, val);
 
        /*
         * Note that bpf_list_add_device() returns 1 if it altered the device
@@ -2930,10 +2930,10 @@ static bool __cgfsng_delegate_controllers(struct cgroup_ops *ops, const char *cg
                 * absolute nor walks upwards.
                 */
                if (abspath(cur))
-                       return syserrno_set(-EINVAL, "No absolute paths allowed");
+                       return syserror_set(-EINVAL, "No absolute paths allowed");
 
                if (strnequal(cur, "..", STRLITERALLEN("..")))
-                       return syserrno_set(-EINVAL, "No upward walking paths allowed");
+                       return syserror_set(-EINVAL, "No upward walking paths allowed");
 
                ret = lxc_writeat(dfd_cur, "cgroup.subtree_control", add_controllers, full_len);
                if (ret < 0)
@@ -3258,7 +3258,7 @@ static int __initialize_cgroups(struct cgroup_ops *ops, bool relative,
        }
 
        if (!controllers_available(ops))
-               return syserrno_set(-ENOENT, "One or more requested controllers unavailable or not delegated");
+               return syserror_set(-ENOENT, "One or more requested controllers unavailable or not delegated");
 
        return 0;
 }
@@ -3436,7 +3436,7 @@ static int __cgroup_attach_many(const struct lxc_conf *conf, const char *name,
        }
 
        if (idx == 0)
-               return syserrno_set(-ENOENT, "Failed to attach to cgroups");
+               return syserror_set(-ENOENT, "Failed to attach to cgroups");
 
        TRACE("Attached to %s cgroup layout", cgroup_layout_name(ctx->layout));
        return 0;
index db9177f73cf6f72190bf56644ce2f76b9686cae2..615defd55ff8e647237e9df52c8bd169ce403fdd 100644 (file)
@@ -352,7 +352,7 @@ static int bpf_program_cgroup_attach(struct bpf_program *prog, int type,
                return ret_errno(EBADF);
 
        if (flags & ~(BPF_F_ALLOW_OVERRIDE | BPF_F_ALLOW_MULTI | BPF_F_REPLACE))
-               return syserrno_set(-EINVAL, "Invalid flags for bpf program");
+               return syserror_set(-EINVAL, "Invalid flags for bpf program");
 
        /*
         * Don't allow the bpf program to be overwritten for now. If we ever
@@ -513,11 +513,11 @@ int bpf_list_add_device(struct bpf_devices *bpf_devices,
 
        list_elem = malloc(sizeof(*list_elem));
        if (!list_elem)
-               return syserrno_set(ENOMEM, "Failed to allocate new device list");
+               return syserror_set(ENOMEM, "Failed to allocate new device list");
 
        new_device = memdup(device, sizeof(struct device_item));
        if (!new_device)
-               return syserrno_set(ENOMEM, "Failed to allocate new device item");
+               return syserror_set(ENOMEM, "Failed to allocate new device item");
 
        lxc_list_add_elem(list_elem, move_ptr(new_device));
        lxc_list_add_tail(&bpf_devices->device_item, move_ptr(list_elem));
index 4909b148952889667a1a9ab2850e5a132aa7d8a6..06ea987c653715b1ac3f6473c351bcfd1921ea2d 100644 (file)
@@ -231,7 +231,7 @@ static ssize_t lxc_cmd_rsp_recv(int sock, struct lxc_cmd_rr *cmd)
         */
        if ((rsp->datalen > LXC_CMD_DATA_MAX) &&
            (cur_cmd != LXC_CMD_CONSOLE_LOG))
-               return syserrno_set(-E2BIG, "Response data for command \"%s\" is too long: %d bytes > %d",
+               return syserror_set(-E2BIG, "Response data for command \"%s\" is too long: %d bytes > %d",
                                    cur_cmdstr, rsp->datalen, LXC_CMD_DATA_MAX);
 
        /*
@@ -254,14 +254,14 @@ static ssize_t lxc_cmd_rsp_recv(int sock, struct lxc_cmd_rr *cmd)
                __fallthrough;
        case LXC_CMD_GET_LIMIT_CGROUP_FD:       /* data */
                if (rsp->datalen > sizeof(struct cgroup_fd))
-                       return syserrno_set(-EINVAL, "Invalid response size from server for \"%s\"", cur_cmdstr);
+                       return syserror_set(-EINVAL, "Invalid response size from server for \"%s\"", cur_cmdstr);
 
                /* Don't pointlessly allocate. */
                rsp->data = (void *)cmd->req.data;
                break;
        case LXC_CMD_GET_CGROUP_CTX:            /* data */
                if (rsp->datalen > sizeof(struct cgroup_ctx))
-                       return syserrno_set(-EINVAL, "Invalid response size from server for \"%s\"", cur_cmdstr);
+                       return syserror_set(-EINVAL, "Invalid response size from server for \"%s\"", cur_cmdstr);
 
                /* Don't pointlessly allocate. */
                rsp->data = (void *)cmd->req.data;
@@ -284,7 +284,7 @@ static ssize_t lxc_cmd_rsp_recv(int sock, struct lxc_cmd_rr *cmd)
                        rsp->data       = tty;
                        break;
                }
-               return syserrno_set(-ENOMEM, "Failed to receive response for command \"%s\"", cur_cmdstr);
+               return syserror_set(-ENOMEM, "Failed to receive response for command \"%s\"", cur_cmdstr);
        case LXC_CMD_CONSOLE_LOG:               /* data */
                __data = zalloc(rsp->datalen + 1);
                rsp->data = __data;
@@ -305,7 +305,7 @@ static ssize_t lxc_cmd_rsp_recv(int sock, struct lxc_cmd_rr *cmd)
                 * Either static or allocated memory.
                 */
                if (!rsp->data)
-                       return syserrno_set(-ENOMEM, "Failed to prepare response buffer for command \"%s\"",
+                       return syserror_set(-ENOMEM, "Failed to prepare response buffer for command \"%s\"",
                                            cur_cmdstr);
 
                bytes_recv = lxc_recv_nointr(sock, rsp->data, rsp->datalen, 0);
@@ -744,7 +744,7 @@ static int lxc_cmd_get_seccomp_notify_fd_callback(int fd, struct lxc_cmd_req *re
        rsp.ret = 0;
        return rsp_one_fd_reap(fd, handler->conf->seccomp.notifier.notify_fd, &rsp);
 #else
-       return syserrno_set(-EOPNOTSUPP, "Seccomp notifier not supported");
+       return syserror_set(-EOPNOTSUPP, "Seccomp notifier not supported");
 #endif
 }
 
@@ -1388,17 +1388,17 @@ int lxc_cmd_add_bpf_device_cgroup(const char *name, const char *lxcpath,
        struct lxc_cmd_rr cmd;
 
        if (strlen(device->access) > STRLITERALLEN("rwm"))
-               return syserrno_set(-EINVAL, "Invalid access mode specified %s", device->access);
+               return syserror_set(-EINVAL, "Invalid access mode specified %s", device->access);
 
        lxc_cmd_init(&cmd, LXC_CMD_ADD_BPF_DEVICE_CGROUP);
        lxc_cmd_data(&cmd, sizeof(struct device_item), device);
 
        ret = lxc_cmd(name, &cmd, &stopped, lxcpath, NULL);
        if (ret < 0)
-               return syserrno_set(ret, "Failed to process new bpf device cgroup command");
+               return syserror_set(ret, "Failed to process new bpf device cgroup command");
 
        if (cmd.rsp.ret < 0)
-               return syserrno_set(cmd.rsp.ret, "Failed to add new bpf device cgroup rule");
+               return syserror_set(cmd.rsp.ret, "Failed to add new bpf device cgroup rule");
 
        return 0;
 }
@@ -1856,7 +1856,7 @@ static int lxc_cmd_rsp_send_enosys(int fd, int id)
        };
 
        __lxc_cmd_rsp_send(fd, &rsp);
-       return syserrno_set(-ENOSYS, "Invalid command id %d", id);
+       return syserror_set(-ENOSYS, "Invalid command id %d", id);
 }
 
 static int lxc_cmd_process(int fd, struct lxc_cmd_req *req,
index 880c1c55c4a97aed07f27032f13140377161c753..33a86d7ccb7efe5874e2895a07707f4d44592754 100644 (file)
@@ -1825,10 +1825,10 @@ static int set_config_cgroup_dir(const char *key, const char *value,
                return clr_config_cgroup_dir(key, lxc_conf, NULL);
 
        if (abspath(value))
-               return syserrno_set(-EINVAL, "%s paths may not be absolute", key);
+               return syserror_set(-EINVAL, "%s paths may not be absolute", key);
 
        if (dotdot(value))
-               return syserrno_set(-EINVAL, "%s paths may not walk upwards via \"../\"", key);
+               return syserror_set(-EINVAL, "%s paths may not walk upwards via \"../\"", key);
 
        return set_config_path_item(&lxc_conf->cgroup_meta.dir, value);
 }
@@ -1840,10 +1840,10 @@ static int set_config_cgroup_monitor_dir(const char *key, const char *value,
                return clr_config_cgroup_monitor_dir(key, lxc_conf, NULL);
 
        if (abspath(value))
-               return syserrno_set(-EINVAL, "%s paths may not be absolute", key);
+               return syserror_set(-EINVAL, "%s paths may not be absolute", key);
 
        if (dotdot(value))
-               return syserrno_set(-EINVAL, "%s paths may not walk upwards via \"../\"", key);
+               return syserror_set(-EINVAL, "%s paths may not walk upwards via \"../\"", key);
 
        return set_config_path_item(&lxc_conf->cgroup_meta.monitor_dir, value);
 }
@@ -1855,10 +1855,10 @@ static int set_config_cgroup_monitor_pivot_dir(const char *key, const char *valu
                return clr_config_cgroup_monitor_pivot_dir(key, lxc_conf, NULL);
 
        if (abspath(value))
-               return syserrno_set(-EINVAL, "%s paths may not be absolute", key);
+               return syserror_set(-EINVAL, "%s paths may not be absolute", key);
 
        if (dotdot(value))
-               return syserrno_set(-EINVAL, "%s paths may not walk upwards via \"../\"", key);
+               return syserror_set(-EINVAL, "%s paths may not walk upwards via \"../\"", key);
 
        return set_config_path_item(&lxc_conf->cgroup_meta.monitor_pivot_dir, value);
 }
@@ -1871,10 +1871,10 @@ static int set_config_cgroup_container_dir(const char *key, const char *value,
                return clr_config_cgroup_container_dir(key, lxc_conf, NULL);
 
        if (abspath(value))
-               return syserrno_set(-EINVAL, "%s paths may not be absolute", key);
+               return syserror_set(-EINVAL, "%s paths may not be absolute", key);
 
        if (dotdot(value))
-               return syserrno_set(-EINVAL, "%s paths may not walk upwards via \"../\"", key);
+               return syserror_set(-EINVAL, "%s paths may not walk upwards via \"../\"", key);
 
        return set_config_path_item(&lxc_conf->cgroup_meta.container_dir, value);
 }
@@ -1888,7 +1888,7 @@ static int set_config_cgroup_container_inner_dir(const char *key,
                return clr_config_cgroup_container_inner_dir(key, lxc_conf, NULL);
 
        if (abspath(value))
-               return syserrno_set(-EINVAL, "%s paths may not be absolute", key);
+               return syserror_set(-EINVAL, "%s paths may not be absolute", key);
 
        if (strchr(value, '/') || strequal(value, ".") || strequal(value, ".."))
                return log_error_errno(-EINVAL, EINVAL, "lxc.cgroup.dir.container.inner must be a single directory name");
index fdf35bd7eac78b58b3f5253de1a900945ca20c33..6517c8156d63f7bfb254d4b0aaec9ac54f7d65bc 100644 (file)
@@ -522,14 +522,6 @@ __lxc_unused static inline void LXC_##LEVEL(struct lxc_log_locinfo* locinfo,       \
                __internal_ret__;                             \
        })
 
-#define syserrno_set(__ret__, format, ...)                    \
-       ({                                                    \
-               typeof(__ret__) __internal_ret__ = (__ret__); \
-               errno = labs(__ret__);                        \
-               SYSERROR(format, ##__VA_ARGS__);              \
-               __internal_ret__;                             \
-       })
-
 #define syswarn_set(__ret__, format, ...)                     \
        ({                                                    \
                typeof(__ret__) __internal_ret__ = (__ret__); \