Skip to content
/ linux Public
forked from torvalds/linux

Commit

Permalink
selftests: cgroup: fix unsigned comparison with less than zero
Browse files Browse the repository at this point in the history
'size' is unsigned, it never less than zero.

Link: https://lkml.kernel.org/r/[email protected]
Fixes: 6c26df8 ("selftests: cgroup: return -errno from cg_read()/cg_write() on failure")
Signed-off-by: YueHaibing <[email protected]>
Reviewed-by: Yosry Ahmed <[email protected]>
Acked-by: Roman Gushchin <[email protected]>
Reviewed-by: Kamalesh Babulal <[email protected]>
Cc: David Rientjes <[email protected]>
Cc: Johannes Weiner <[email protected]>
Cc: Shakeel Butt <[email protected]>
Cc: Shuah Khan <[email protected]>
Cc: Tejun Heo <[email protected]>
Cc: zefan li <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
  • Loading branch information
YueHaibing authored and akpm00 committed Nov 18, 2022
1 parent d51cf40 commit 333d073
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions tools/testing/selftests/cgroup/cgroup_util.c
Original file line number Diff line number Diff line change
Expand Up @@ -555,15 +555,16 @@ int proc_mount_contains(const char *option)
ssize_t proc_read_text(int pid, bool thread, const char *item, char *buf, size_t size)
{
char path[PATH_MAX];
ssize_t ret;

if (!pid)
snprintf(path, sizeof(path), "/proc/%s/%s",
thread ? "thread-self" : "self", item);
else
snprintf(path, sizeof(path), "/proc/%d/%s", pid, item);

size = read_text(path, buf, size);
return size < 0 ? -1 : size;
ret = read_text(path, buf, size);
return ret < 0 ? -1 : ret;
}

int proc_read_strstr(int pid, bool thread, const char *item, const char *needle)
Expand Down

0 comments on commit 333d073

Please sign in to comment.