From: Carlos Martín Nieto Date: Mon, 21 Mar 2011 09:56:19 GMT Subject: Re: [PATCH] system_path: use a static buffer Message-ID: <1300701380.2583.13.camel@bee.lab.cmartin.tk> In-Reply-To: <7vpqpoyjo3.fsf@alter.siamese.dyndns.org> On vie, 2011-03-18 at 00:25 -0700, Junio C Hamano wrote: > Carlos Martín Nieto writes: > > > + ret = snprintf(buf, sizeof(buf), "%s/%s", prefix, path); > > + if (ret >= sizeof(buf)) > > + die("system path too long for %s", path); > > + else if (ret < 0) > > + die_errno("encoding error"); > > POSIX says snprintf() should set errno in this case, and your use of > die_errno() would show that information, but what is "encoding error"? > > Just being curious, as I suspect that "snprintf() returned an error" may > be more appropriate, if the answer is "I don't know what kind of error it > is, but snprintf() found something faulty while encoding so I chose to > call it encoding error". My manpage says snprintf returns -1 if there was an output or encoding error. As there couldn't be an output error because it's writing to memory and we can't output what snprintf chocked on because whatever die_errno uses will also choke on it, I just put "encoding error". I'd put "error assembling system path" as the actual error message, I guess. cmn