[LTP] [PATCH] lib/tst_cgroup: fix short reads of mems/cpus

Jan Stancek jstancek@redhat.com
Mon Nov 9 13:49:08 CET 2020



----- Original Message -----
> On Wed, Nov 4, 2020 at 2:22 PM Li Wang <liwang@redhat.com> wrote:
> 
> > ...
> >> -       tst_cgroup_cpuset_read_files(PATH_TMP_CG_CST, "cpus", buf);
> >> +       tst_cgroup_cpuset_read_files(PATH_TMP_CG_CST, "cpus", buf,
> >> sizeof(buf));
> >>         tst_cgroup_cpuset_write_files(PATH_TMP_CG_CST, "cpus", buf);
> >> -       tst_cgroup_cpuset_read_files(PATH_TMP_CG_CST, "mems", mems);
> >> +       tst_cgroup_cpuset_read_files(PATH_TMP_CG_CST, "mems", mems,
> >> sizeof(buf));
> >>
> >
> > sizeof() is generally used to calculate the size (in bytes) of a data type,
> > e.g sizeof(char *).
> > I think here to pass 'BUFSIZ' directly is better than sizeof(buf).
> >
> 
> Jan, do you agree with this point?
> If yes, I can help to modify and apply this patch.

2nd line should have been sizeof(mems), but BUFSIZ will work too.



More information about the ltp mailing list