On Wed, Feb 17, 2016 at 07:40:47PM +0100, Andrew Jones wrote: > va_report_xfail has the pattern > > char buf[] > vsnprintf(buf, ...) > puts(buf) > > Before adding another one, replace it with vprintf. > > Suggested-by: David Gibson <david@xxxxxxxxxxxxxxxxxxxxx> > Signed-off-by: Andrew Jones <drjones@xxxxxxxxxx> Reviewed-by: David Gibson <david@xxxxxxxxxxxxxxxxxxxxx> > --- > lib/libcflat.h | 1 + > lib/printf.c | 14 +++++++++++++- > lib/report.c | 4 +--- > 3 files changed, 15 insertions(+), 4 deletions(-) > > diff --git a/lib/libcflat.h b/lib/libcflat.h > index 9747ccdbc9f1d..f7a5728c6759a 100644 > --- a/lib/libcflat.h > +++ b/lib/libcflat.h > @@ -55,6 +55,7 @@ extern void abort(void); > extern int printf(const char *fmt, ...); > extern int snprintf(char *buf, int size, const char *fmt, ...); > extern int vsnprintf(char *buf, int size, const char *fmt, va_list va); > +extern int vprintf(const char *fmt, va_list va); > extern long atol(const char *ptr); > > void report_prefix_push(const char *prefix); > diff --git a/lib/printf.c b/lib/printf.c > index 5d83605afe829..2aec59aa6d6d4 100644 > --- a/lib/printf.c > +++ b/lib/printf.c > @@ -1,5 +1,7 @@ > #include "libcflat.h" > > +#define BUFSZ 2000 > + > typedef struct pstream { > char *buffer; > int remain; > @@ -235,10 +237,20 @@ int snprintf(char *buf, int size, const char *fmt, ...) > return r; > } > > +int vprintf(const char *fmt, va_list va) > +{ > + char buf[BUFSZ]; > + int r; > + > + r = vsnprintf(buf, sizeof(buf), fmt, va); > + puts(buf); > + return r; > +} > + > int printf(const char *fmt, ...) > { > va_list va; > - char buf[2000]; > + char buf[BUFSZ]; > int r; > > va_start(va, fmt); > diff --git a/lib/report.c b/lib/report.c > index 35e664108a921..c29e835b9c751 100644 > --- a/lib/report.c > +++ b/lib/report.c > @@ -47,15 +47,13 @@ void va_report_xfail(const char *msg_fmt, bool xfail, bool cond, va_list va) > { > char *pass = xfail ? "XPASS" : "PASS"; > char *fail = xfail ? "XFAIL" : "FAIL"; > - char buf[2000]; > > spin_lock(&lock); > > tests++; > printf("%s: ", cond ? pass : fail); > puts(prefixes); > - vsnprintf(buf, sizeof(buf), msg_fmt, va); > - puts(buf); > + vprintf(msg_fmt, va); > puts("\n"); > if (xfail && cond) > failures++; -- David Gibson | I'll have my music baroque, and my code david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_ | _way_ _around_! http://www.ozlabs.org/~dgibson
Attachment:
signature.asc
Description: PGP signature