[lxc-devel] [PATCH v2] Remove a comment part from a config value

Stéphane Graber stgraber at ubuntu.com
Thu Aug 28 13:54:32 UTC 2014


On Thu, Aug 28, 2014 at 10:11:42PM +0900, TAMUKI Shoichi wrote:
> Hello KATOH-san,
> 
> From: KATOH Yasufumi <karma at jazz.email.ne.jp>
> Subject: [lxc-devel] [PATCH v2] Remove a comment part from a config value
> Date: Thu, 28 Aug 2014 19:51:06 +0900
> 
> > @@ -1743,6 +1744,9 @@ static int parse_line(char *buffer, void *data)
> >  	*dot = '\0';
> >  	value = dot + 1;
> >  
> > +	comment = strstr(value, "#");
> > +	*comment = '\0';
> > +
> >  	key = line;
> >  	key[lxc_char_right_gc(key, strlen(key))] = '\0';
>  
> This will not do.  If "#" is not found, strstr() returns NULL. :-(
> 
> I just intended to point out like this:
> 
> 	if (comment = strstr(value, "#"))
> 		*comment = '\0';
> 
> By the way, do you mean a hash mark ("#") can be anywhere on a line?
> 
> lxc.utsname = ct01 # the rest of the line will be treated as a comment.
> 
> If so, that requires careful consideration for the following case.
> 
> lxc.rootfs = /mnt/rootfs.test#01
> 
> I think that a hash mark ("#") as a comment must be at the beginning
> of a line.

So my understanding there is that we simply don't support in-line
comments (comments after meaningful content), one of the reason being
for the case you just described.

Comments on their own line should already be properly handled by the
config parser, that is, they are stored in a separate list and restored
on save_config.


I suspect this is a case where the right answer is additional
documentation, making it clear that we only support comments on their
own lines.

-- 
Stéphane Graber
Ubuntu developer
http://www.ubuntu.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20140828/3071face/attachment.sig>


More information about the lxc-devel mailing list