[CRIU] [PATCH] cgroup: don't overwrite the offset value in a loop
Tycho Andersen
tycho.andersen at canonical.com
Fri Aug 15 05:15:23 PDT 2014
Hi Pavel, Andrew,
On Fri, Aug 15, 2014 at 04:05:31PM +0400, Pavel Emelyanov wrote:
> On 08/15/2014 04:03 PM, Andrew Vagin wrote:
> > prepare_cgroup_dirs() gets a path and an offset.
> > Then we add substrings to the source string and handle them.
>
> The same place exists in prepare_cgroup_dir_properties().
> Can we also add the 2nd empty cgroup into cgroup01 test
> to catch such things in the future?
Yes, I can add the test if you want Andrew.
Tycho
> > Cc: Tycho Andersen <tycho.andersen at canonical.com>
> > Signed-off-by: Andrew Vagin <avagin at openvz.org>
> > ---
> > cgroup.c | 5 +++--
> > 1 file changed, 3 insertions(+), 2 deletions(-)
> >
> > diff --git a/cgroup.c b/cgroup.c
> > index 1d297e6..e277657 100644
> > --- a/cgroup.c
> > +++ b/cgroup.c
> > @@ -1023,9 +1023,10 @@ static int prepare_cgroup_dirs(char *paux, size_t off, CgroupDirEntry **ents, si
> > CgroupDirEntry *e;
> >
> > for (i = 0; i < n_ents; i++) {
> > + size_t off2 = off;
> > e = ents[i];
> >
> > - off += sprintf(paux + off, "/%s", e->dir_name);
> > + off2 += sprintf(paux + off, "/%s", e->dir_name);
> >
> > /*
> > * Checking to see if file already exists. If not, create it. If
> > @@ -1047,7 +1048,7 @@ static int prepare_cgroup_dirs(char *paux, size_t off, CgroupDirEntry **ents, si
> > pr_info("Determined dir %s already existed\n", paux);
> > }
> >
> > - if (prepare_cgroup_dirs(paux, off, e->children, e->n_children) < 0)
> > + if (prepare_cgroup_dirs(paux, off2, e->children, e->n_children) < 0)
> > return -1;
> > }
> >
> >
>
More information about the CRIU
mailing list