From: Christian Brauner Date: Thu, 25 Feb 2021 23:26:26 +0000 (+0100) Subject: tree-wide: s/syerrno_set()/syserror_set()/g X-Git-Tag: lxc-5.0.0~266^2~6 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=060aaa395a10e50c7b21df3b3e56a71720b20582;p=thirdparty%2Flxc.git tree-wide: s/syerrno_set()/syserror_set()/g Signed-off-by: Christian Brauner --- diff --git a/src/lxc/af_unix.c b/src/lxc/af_unix.c index f1d36c5dd..493599cd3 100644 --- a/src/lxc/af_unix.c +++ b/src/lxc/af_unix.c @@ -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; diff --git a/src/lxc/cgroups/cgfsng.c b/src/lxc/cgroups/cgfsng.c index 7d8fec5e8..f9d074c39 100644 --- a/src/lxc/cgroups/cgfsng.c +++ b/src/lxc/cgroups/cgfsng.c @@ -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; diff --git a/src/lxc/cgroups/cgroup2_devices.c b/src/lxc/cgroups/cgroup2_devices.c index db9177f73..615defd55 100644 --- a/src/lxc/cgroups/cgroup2_devices.c +++ b/src/lxc/cgroups/cgroup2_devices.c @@ -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)); diff --git a/src/lxc/commands.c b/src/lxc/commands.c index 4909b1489..06ea987c6 100644 --- a/src/lxc/commands.c +++ b/src/lxc/commands.c @@ -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, diff --git a/src/lxc/confile.c b/src/lxc/confile.c index 880c1c55c..33a86d7cc 100644 --- a/src/lxc/confile.c +++ b/src/lxc/confile.c @@ -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"); diff --git a/src/lxc/log.h b/src/lxc/log.h index fdf35bd7e..6517c8156 100644 --- a/src/lxc/log.h +++ b/src/lxc/log.h @@ -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__); \