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