From: Ralph Corderoy Date: Mon, 17 Apr 2017 09:57:54 +0000 (+0100) Subject: Fix bug in advertise("", "", "foo", ap). X-Git-Url: https://diplodocus.org/git/nmh/commitdiff_plain/ba5c4a5dd8748d16592ba1d77aa23447c1d6a6ff?hp=8a14191c0a0ad15bb8f35b49748c75c1e0a8c2f4 Fix bug in advertise("", "", "foo", ap). A non-NULL but empty `what' would result in "fooerrno\n" without separation. Improve the function's comment to try and make it obvious how its out of order parameters appear. --- diff --git a/sbr/error.c b/sbr/error.c index 7b2f5064..65055ecd 100644 --- a/sbr/error.c +++ b/sbr/error.c @@ -71,13 +71,12 @@ admonish (char *what, char *fmt, ...) /* advertise prints fmt and ap to stderr after flushing stdout. - * If invo_name isn't NULL or empty, it precedes the output seperated by ": ". - * If what isn't NULL, errno as a string is appended. - * A non-empty what separates fmt from errno, surrounded by " " and ": ". - * BUG: No space separator before errno if what is "". - * If tail isn't NULL or empty then ", " and tail are appended - * before the finishing "\n". - * In summary: "invo_name: fmt what: errno, tail\n". */ + * If invo_name isn't NULL or empty then "invo_name: " precedes fmt. + * If what isn't NULL or empty then " what" is appended. + * If what isn't NULL then ": errno" is appended. + * If tail isn't NULL or empty then ", tail" is appended. + * A "\n" finishes the output to stderr. + * In summary: "[invo_name: ]fmt[[ what]: errno][, tail]\n". */ void advertise (const char *what, char *tail, const char *fmt, va_list ap) { @@ -107,8 +106,8 @@ advertise (const char *what, char *tail, const char *fmt, va_list ap) if (*what) { ADD_LITERAL(" "); ADD_VAR((void *)what); - ADD_LITERAL(": "); } + ADD_LITERAL(": "); err = strerror(eindex); if (!err) { /* this shouldn't happen, but we'll test for it just in case */