* [PATCH] selftests: cgroup: Fix unsigned expression compared with zero
@ 2022-04-27 6:17 ` Jiapeng Chong
0 siblings, 0 replies; 4+ messages in thread
From: Jiapeng Chong @ 2022-04-27 6:17 UTC (permalink / raw)
To: tj
Cc: lizefan.x, hannes, shuah, cgroups, linux-kselftest, linux-kernel,
Jiapeng Chong, Abaci Robot
Fix the following coccicheck warnings:
./tools/testing/selftests/cgroup/cgroup_util.c:566:8-12: WARNING:
Unsigned expression compared with zero: size < 0.
Reported-by: Abaci Robot <abaci@linux.alibaba.com>
Signed-off-by: Jiapeng Chong <jiapeng.chong@linux.alibaba.com>
---
tools/testing/selftests/cgroup/cgroup_util.c | 2 +-
tools/testing/selftests/cgroup/cgroup_util.h | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/tools/testing/selftests/cgroup/cgroup_util.c b/tools/testing/selftests/cgroup/cgroup_util.c
index 4c52cc6f2f9c..661e06b94a43 100644
--- a/tools/testing/selftests/cgroup/cgroup_util.c
+++ b/tools/testing/selftests/cgroup/cgroup_util.c
@@ -552,7 +552,7 @@ int proc_mount_contains(const char *option)
return strstr(buf, option) != NULL;
}
-ssize_t proc_read_text(int pid, bool thread, const char *item, char *buf, size_t size)
+ssize_t proc_read_text(int pid, bool thread, const char *item, char *buf, ssize_t size)
{
char path[PATH_MAX];
diff --git a/tools/testing/selftests/cgroup/cgroup_util.h b/tools/testing/selftests/cgroup/cgroup_util.h
index c92df4e5d395..7b3865805f50 100644
--- a/tools/testing/selftests/cgroup/cgroup_util.h
+++ b/tools/testing/selftests/cgroup/cgroup_util.h
@@ -53,7 +53,7 @@ extern int set_oom_adj_score(int pid, int score);
extern int cg_wait_for_proc_count(const char *cgroup, int count);
extern int cg_killall(const char *cgroup);
int proc_mount_contains(const char *option);
-extern ssize_t proc_read_text(int pid, bool thread, const char *item, char *buf, size_t size);
+extern ssize_t proc_read_text(int pid, bool thread, const char *item, char *buf, ssize_t size);
extern int proc_read_strstr(int pid, bool thread, const char *item, const char *needle);
extern pid_t clone_into_cgroup(int cgroup_fd);
extern int clone_reap(pid_t pid, int options);
--
2.20.1.7.g153144c
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH] selftests: cgroup: Fix unsigned expression compared with zero
@ 2022-04-27 6:17 ` Jiapeng Chong
0 siblings, 0 replies; 4+ messages in thread
From: Jiapeng Chong @ 2022-04-27 6:17 UTC (permalink / raw)
To: tj-DgEjT+Ai2ygdnm+yROfE0A
Cc: lizefan.x-EC8Uxl6Npydl57MIdRCFDg, hannes-druUgvl0LCNAfugRpC6u6w,
shuah-DgEjT+Ai2ygdnm+yROfE0A, cgroups-u79uwXL29TY76Z2rM5mHXA,
linux-kselftest-u79uwXL29TY76Z2rM5mHXA,
linux-kernel-u79uwXL29TY76Z2rM5mHXA, Jiapeng Chong, Abaci Robot
Fix the following coccicheck warnings:
./tools/testing/selftests/cgroup/cgroup_util.c:566:8-12: WARNING:
Unsigned expression compared with zero: size < 0.
Reported-by: Abaci Robot <abaci-KPsoFbNs7GizrGE5bRqYAgC/G2K4zDHf@public.gmane.org>
Signed-off-by: Jiapeng Chong <jiapeng.chong-KPsoFbNs7GizrGE5bRqYAgC/G2K4zDHf@public.gmane.org>
---
tools/testing/selftests/cgroup/cgroup_util.c | 2 +-
tools/testing/selftests/cgroup/cgroup_util.h | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/tools/testing/selftests/cgroup/cgroup_util.c b/tools/testing/selftests/cgroup/cgroup_util.c
index 4c52cc6f2f9c..661e06b94a43 100644
--- a/tools/testing/selftests/cgroup/cgroup_util.c
+++ b/tools/testing/selftests/cgroup/cgroup_util.c
@@ -552,7 +552,7 @@ int proc_mount_contains(const char *option)
return strstr(buf, option) != NULL;
}
-ssize_t proc_read_text(int pid, bool thread, const char *item, char *buf, size_t size)
+ssize_t proc_read_text(int pid, bool thread, const char *item, char *buf, ssize_t size)
{
char path[PATH_MAX];
diff --git a/tools/testing/selftests/cgroup/cgroup_util.h b/tools/testing/selftests/cgroup/cgroup_util.h
index c92df4e5d395..7b3865805f50 100644
--- a/tools/testing/selftests/cgroup/cgroup_util.h
+++ b/tools/testing/selftests/cgroup/cgroup_util.h
@@ -53,7 +53,7 @@ extern int set_oom_adj_score(int pid, int score);
extern int cg_wait_for_proc_count(const char *cgroup, int count);
extern int cg_killall(const char *cgroup);
int proc_mount_contains(const char *option);
-extern ssize_t proc_read_text(int pid, bool thread, const char *item, char *buf, size_t size);
+extern ssize_t proc_read_text(int pid, bool thread, const char *item, char *buf, ssize_t size);
extern int proc_read_strstr(int pid, bool thread, const char *item, const char *needle);
extern pid_t clone_into_cgroup(int cgroup_fd);
extern int clone_reap(pid_t pid, int options);
--
2.20.1.7.g153144c
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] selftests: cgroup: Fix unsigned expression compared with zero
@ 2022-04-27 16:18 ` Tejun Heo
0 siblings, 0 replies; 4+ messages in thread
From: Tejun Heo @ 2022-04-27 16:18 UTC (permalink / raw)
To: Jiapeng Chong
Cc: lizefan.x, hannes, shuah, cgroups, linux-kselftest, linux-kernel,
Abaci Robot
On Wed, Apr 27, 2022 at 02:17:56PM +0800, Jiapeng Chong wrote:
> Fix the following coccicheck warnings:
>
> ./tools/testing/selftests/cgroup/cgroup_util.c:566:8-12: WARNING:
> Unsigned expression compared with zero: size < 0.
>
> Reported-by: Abaci Robot <abaci@linux.alibaba.com>
> Signed-off-by: Jiapeng Chong <jiapeng.chong@linux.alibaba.com>
> ---
> tools/testing/selftests/cgroup/cgroup_util.c | 2 +-
> tools/testing/selftests/cgroup/cgroup_util.h | 2 +-
> 2 files changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/tools/testing/selftests/cgroup/cgroup_util.c b/tools/testing/selftests/cgroup/cgroup_util.c
> index 4c52cc6f2f9c..661e06b94a43 100644
> --- a/tools/testing/selftests/cgroup/cgroup_util.c
> +++ b/tools/testing/selftests/cgroup/cgroup_util.c
> @@ -552,7 +552,7 @@ int proc_mount_contains(const char *option)
> return strstr(buf, option) != NULL;
> }
>
> -ssize_t proc_read_text(int pid, bool thread, const char *item, char *buf, size_t size)
> +ssize_t proc_read_text(int pid, bool thread, const char *item, char *buf, ssize_t size)
Converting input size parameter to ssize_t doesn't make sense. I don't see
where it's doing size < 0 either but that's probably where it should be
fixed.
--
tejun
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] selftests: cgroup: Fix unsigned expression compared with zero
@ 2022-04-27 16:18 ` Tejun Heo
0 siblings, 0 replies; 4+ messages in thread
From: Tejun Heo @ 2022-04-27 16:18 UTC (permalink / raw)
To: Jiapeng Chong
Cc: lizefan.x-EC8Uxl6Npydl57MIdRCFDg, hannes-druUgvl0LCNAfugRpC6u6w,
shuah-DgEjT+Ai2ygdnm+yROfE0A, cgroups-u79uwXL29TY76Z2rM5mHXA,
linux-kselftest-u79uwXL29TY76Z2rM5mHXA,
linux-kernel-u79uwXL29TY76Z2rM5mHXA, Abaci Robot
On Wed, Apr 27, 2022 at 02:17:56PM +0800, Jiapeng Chong wrote:
> Fix the following coccicheck warnings:
>
> ./tools/testing/selftests/cgroup/cgroup_util.c:566:8-12: WARNING:
> Unsigned expression compared with zero: size < 0.
>
> Reported-by: Abaci Robot <abaci-KPsoFbNs7GizrGE5bRqYAgC/G2K4zDHf@public.gmane.org>
> Signed-off-by: Jiapeng Chong <jiapeng.chong-KPsoFbNs7GizrGE5bRqYAgC/G2K4zDHf@public.gmane.org>
> ---
> tools/testing/selftests/cgroup/cgroup_util.c | 2 +-
> tools/testing/selftests/cgroup/cgroup_util.h | 2 +-
> 2 files changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/tools/testing/selftests/cgroup/cgroup_util.c b/tools/testing/selftests/cgroup/cgroup_util.c
> index 4c52cc6f2f9c..661e06b94a43 100644
> --- a/tools/testing/selftests/cgroup/cgroup_util.c
> +++ b/tools/testing/selftests/cgroup/cgroup_util.c
> @@ -552,7 +552,7 @@ int proc_mount_contains(const char *option)
> return strstr(buf, option) != NULL;
> }
>
> -ssize_t proc_read_text(int pid, bool thread, const char *item, char *buf, size_t size)
> +ssize_t proc_read_text(int pid, bool thread, const char *item, char *buf, ssize_t size)
Converting input size parameter to ssize_t doesn't make sense. I don't see
where it's doing size < 0 either but that's probably where it should be
fixed.
--
tejun
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2022-04-27 16:22 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-27 6:17 [PATCH] selftests: cgroup: Fix unsigned expression compared with zero Jiapeng Chong
2022-04-27 6:17 ` Jiapeng Chong
2022-04-27 16:18 ` Tejun Heo
2022-04-27 16:18 ` Tejun Heo
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.