[lxc-devel] [PATCH] cgroup: re-introduce ns cgroup support

Serge Hallyn serge.hallyn at ubuntu.com
Wed Sep 11 21:52:23 UTC 2013


Quoting Christian Seiler (christian at iwakd.de):
> Hi Serge,
> 
> Sorry about 'ns' support in my rewrite, I completely forgot that it's
> removal was not so long ago.
> 
> I have a two very minor nit-picky comments:
> 
> > +static char *cgroup_rename_nsgroup(char *mountpath, const char *oldname, int pid, const char *name)
> > +lxc_cgroup_create(..., int pid)
> 
> pid_t instead of int would be a better idea for pid. Also, mountpath in
> the first function should probably be const to indicate it's contents
> won't be modified.

Agreed, those would be good.

> > +	fulloldpath = alloca(strlen(oldname) + strlen(mountpath) + 22);
> > +	sprintf(fulloldpath, "%s/%s/%d", mountpath, oldname, pid);
> 
> Even though you allocated a correctly-sized buffer, I'd personally
> prefer to always use snprintf to be on the safe side...

Any time I think there's a chance of the underlying variable changing
(i.e. if i'm dereferencing a field from a possibly shared struct) I
so so, but I didn't here.  At some point it always seems like I'm
adversely affecting readability.  But I'll add it back, along with
the other two above fixes, and push that to staging - thanks.

-serge




More information about the lxc-devel mailing list