On Thu, Mar 12, 2026 at 11:34:41PM -0700, Yosry Ahmed wrote:
> > diff --git a/tools/testing/selftests/cgroup/test_zswap.c 
> > b/tools/testing/selftests/cgroup/test_zswap.c
> > index 64ebc3f3f203..e69d845d3592 100644
> > --- a/tools/testing/selftests/cgroup/test_zswap.c
> > +++ b/tools/testing/selftests/cgroup/test_zswap.c
> > @@ -589,9 +589,21 @@ struct zswap_test {
> >  };
> >  #undef T
> >
> > -static bool zswap_configured(void)
> > +static void check_zswap_enabled(void)
> >  {
> > -       return access("/sys/module/zswap", F_OK) == 0;
> > +       char value[2];
> 
> Please wait for discussions on the previous version to conclude and
> give people a little bit of time to respond before sending the next
> version.

Sorry for the rush. I thought that I had clarified the issue there.

> I think this can just be be:
> 
>     char value;
>     ...
> 
>     if (read_text(.., &value, sizeof(value)) < 0)

This actuall introduce a problem to the code, as in read_text()
that achivement is:

  len = read(fd, buf, max_len - 1);

When 'sizeof(value) == 1' pass in that makes read(fd, &value, 0);
read zero, after that, the value is set to '\0'.

With your < 0 check, this is treated as success, then value == 'N' is false,
the check_zswap_enabled will report wrong status (enabled) on disabled.

-- 
Regards,
Li Wang


Reply via email to