[Libguestfs] [PATCH] test-charset-fidelity: allow to skip testing specific FSes

Pino Toscano ptoscano at redhat.com
Wed May 7 13:06:18 UTC 2014


On Wednesday 07 May 2014 10:05:56 Richard W.M. Jones wrote:
> On Mon, May 05, 2014 at 05:05:29PM +0200, Pino Toscano wrote:
> > +  snprintf (envvar, sizeof (envvar) - 1, "%s_%s", ourenvvar,
> > fs->fs_name);
> Is this right?
> 
> I'm tempted to say it should be `sizeof envvar'.  However my knowledge
> of C is not clear enough to say whether that would evaluate to the
> size of the array or the size of a pointer (8 bytes).

Yes, this works because envvar is a char array. (Theoretically it should 
be sizeof(buf)/sizeof(buf[0]), but since sizeof(char) == 1 usually then 
could be omitted.)

The "- 1" bit is because I always forget whether the size argument in 
the {,v}snprint functions include the \0 at the end. There is enough 
space in this case anyway, so it shouldn't matter that much.

-- 
Pino Toscano




More information about the Libguestfs mailing list