From: Arran Cudbard-Bell Date: Mon, 15 May 2017 17:20:25 +0000 (-0400) Subject: Add prefix to all lines in fr_perror X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=32c4796cd882f66ff1d6162261dbf7597420c8cb;p=thirdparty%2Ffreeradius-server.git Add prefix to all lines in fr_perror ...else it looks dumb --- diff --git a/src/lib/util/strerror.c b/src/lib/util/strerror.c index 65a1d60eca4..f167be2b623 100644 --- a/src/lib/util/strerror.c +++ b/src/lib/util/strerror.c @@ -259,15 +259,17 @@ char const *fr_strerror_pop(void) */ void fr_perror(char const *fmt, ...) { - char const *error; - va_list ap; + char const *error; + char *prefix; + va_list ap; va_start(ap, fmt); - vfprintf(stderr, fmt, ap); + prefix = talloc_vasprintf(NULL, fmt, ap); + va_end(ap); error = fr_strerror_pop(); if (error && (error[0] != '\0')) { - fprintf(stderr, ": %s\n", error); + fprintf(stderr, "%s: %s\n", prefix, error); } else { fputs("\n", stderr); } @@ -277,10 +279,10 @@ void fr_perror(char const *fmt, ...) */ while ((error = fr_strerror_pop())) { if (error && (error[0] != '\0')) { - fprintf(stderr, "%s\n", error); + fprintf(stderr, "%s: %s\n", prefix, error); } } - va_end(ap); + talloc_free(prefix); }