From: Christian Brauner Date: Fri, 3 Sep 2021 07:34:59 +0000 (+0200) Subject: cgroups: fix integer comparisons X-Git-Tag: lxc-5.0.0~92^2~59 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=45ef2e0c690f38a460765290c576ab5a6b1a50c5;p=thirdparty%2Flxc.git cgroups: fix integer comparisons Signed-off-by: Christian Brauner --- diff --git a/src/lxc/cgroups/cgfsng.c b/src/lxc/cgroups/cgfsng.c index 0e9cbcec6..3103263b3 100644 --- a/src/lxc/cgroups/cgfsng.c +++ b/src/lxc/cgroups/cgfsng.c @@ -163,7 +163,7 @@ int prepare_cgroup_fd(const struct cgroup_ops *ops, struct cgroup_fd *fd, bool l * The client requested that the controller must be in a specific * cgroup version. */ - if (fd->type != 0 && fd->type != h->fs_type) + if (fd->type != 0 && (cgroupfs_type_magic_t)fd->type != h->fs_type) return ret_errno(EINVAL); if (limit) @@ -2132,7 +2132,7 @@ static int cgroup_attach_leaf(const struct lxc_conf *conf, int unified_fd, pid_t * that a short write would cause a buffer overrun. So be on * the safe side. */ - if (ret < STRLITERALLEN(".lxc-/cgroup.procs")) + if ((size_t)ret < STRLITERALLEN(".lxc-/cgroup.procs")) return log_error_errno(-EINVAL, EINVAL, "Unexpected short write would cause buffer-overrun"); slash += (ret - STRLITERALLEN("/cgroup.procs")); @@ -2208,11 +2208,11 @@ static int cgroup_attach_move_into_leaf(const struct lxc_conf *conf, pidstr_len = sprintf(pidstr, INT64_FMT, (int64_t)pid); ret = lxc_write_nointr(target_fd0, pidstr, pidstr_len); - if (ret > 0 && ret == pidstr_len) + if (ret > 0 && (size_t)ret == pidstr_len) return log_debug(0, "Moved process into target cgroup via fd %d", target_fd0); ret = lxc_write_nointr(target_fd1, pidstr, pidstr_len); - if (ret > 0 && ret == pidstr_len) + if (ret > 0 && (size_t)ret == pidstr_len) return log_debug(0, "Moved process into target cgroup via fd %d", target_fd1); return log_debug_errno(-1, errno, "Failed to move process into target cgroup via fd %d and %d", @@ -2437,7 +2437,8 @@ static int device_cgroup_parse_access(struct device_item *device, const char *va static int device_cgroup_rule_parse(struct device_item *device, const char *key, const char *val) { - int count, ret; + size_t count; + int ret; char temp[50]; if (strequal("devices.allow", key))