mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Mukesh Ojha <quic_mojha@quicinc.com>
To: YueHaibing <yuehaibing@huawei.com>, <tj@kernel.org>,
	<lizefan.x@bytedance.com>, <hannes@cmpxchg.org>,
	<shuah@kernel.org>, <yosryahmed@google.com>,
	<roman.gushchin@linux.dev>, <shakeelb@google.com>,
	<rientjes@google.com>, <akpm@linux-foundation.org>
Cc: <cgroups@vger.kernel.org>, <linux-kselftest@vger.kernel.org>,
	<linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] selftests: cgroup: Fix unsigned comparison with less than zero
Date: Tue, 8 Nov 2022 11:59:34 +0530	[thread overview]
Message-ID: <b123bd21-241c-de06-c3d7-e4505ee6e1e3@quicinc.com> (raw)
In-Reply-To: <20221105110611.28920-1-yuehaibing@huawei.com>

Hi,

On 11/5/2022 4:36 PM, YueHaibing wrote:
> 'size' is unsigned, it never less than zero.
> 
> Fixes: 6c26df84e1f2 ("selftests: cgroup: return -errno from cg_read()/cg_write() on failure")
> Signed-off-by: YueHaibing <yuehaibing@huawei.com>

LGTM.
Reviewed-by: Mukesh Ojha <quic_mojha@quicinc.com>

-Mukesh
> ---
>   tools/testing/selftests/cgroup/cgroup_util.c | 5 +++--
>   1 file changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/tools/testing/selftests/cgroup/cgroup_util.c b/tools/testing/selftests/cgroup/cgroup_util.c
> index 4c52cc6f2f9c..e8bbbdb77e0d 100644
> --- a/tools/testing/selftests/cgroup/cgroup_util.c
> +++ b/tools/testing/selftests/cgroup/cgroup_util.c
> @@ -555,6 +555,7 @@ 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",
> @@ -562,8 +563,8 @@ ssize_t proc_read_text(int pid, bool thread, const char *item, char *buf, size_t
>   	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)

  parent reply	other threads:[~2022-11-08  6:29 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-05 11:06 YueHaibing
2022-11-05 22:29 ` Yosry Ahmed
2022-11-08  1:00 ` Roman Gushchin
2022-11-08  6:29 ` Mukesh Ojha [this message]
2022-11-08 13:24 ` Kamalesh Babulal

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=b123bd21-241c-de06-c3d7-e4505ee6e1e3@quicinc.com \
    --to=quic_mojha@quicinc.com \
    --cc=akpm@linux-foundation.org \
    --cc=cgroups@vger.kernel.org \
    --cc=hannes@cmpxchg.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=lizefan.x@bytedance.com \
    --cc=rientjes@google.com \
    --cc=roman.gushchin@linux.dev \
    --cc=shakeelb@google.com \
    --cc=shuah@kernel.org \
    --cc=tj@kernel.org \
    --cc=yosryahmed@google.com \
    --cc=yuehaibing@huawei.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®