From: Alexander Potashev Date: Sun, 07 Jun 2009 11:12:39 GMT Subject: Re: [PATCH v2 1/3] Introduce die_errno() that appends strerror(errno) to die() Message-ID: <2325a7950906070412k3a440558h35db7511cc390e4b@mail.gmail.com> In-Reply-To: <20090606221320.GB30064@coredump.intra.peff.net> 2009/6/7 Jeff King : > On Sat, Jun 06, 2009 at 04:44:51PM +0200, Thomas Rast wrote: > >> Code by Jeff King and Alexander Potashev, name by Johannes Sixt. >> [...] >> +void die_errno(const char *err, ...) >> +{ >> +     va_list params; >> +     char msg[1024]; >> + >> +     va_start(params, err); >> + >> +     vsnprintf(msg, sizeof(msg), err, params); >> +     die("%s: %s", msg, strerror(errno)); >> + >> +     va_end(params); >> +} >> + This breaks theoretical usage of custom format string in custom die routines: 1. A custom die routine might not support %s. 2. If the die routine adds a custom format specifier, vsnprintf will fail. But I'm not sure that passing a format string and a va_list to die_routine/error_routine/warn_routine is really necessary. If there is no much external code depending on them, I would convert them to the style of usage_routine: void (*usage_routine)(const char *err) CC'ing Petr Baudis , see commit 39a3f5ea > > No, this approach is much more elegant than what I posted, so no need to > credit me, at least. ;) It was your idea of using 1024-character buffer here ;) Alexander