> We do the same thing three times => create a function for it. > > In order to save lines of code, this code sacrifices a bit of > performance by taking a spinlock in va_print twice. > > Signed-off-by: Radim Krčmář <rkrcmar@xxxxxxxxxx> Looks good, thanks. Paolo > --- > lib/report.c | 33 +++++++++++++++------------------ > 1 file changed, 15 insertions(+), 18 deletions(-) > > diff --git a/lib/report.c b/lib/report.c > index fc0ef494f412..0cff607c8923 100644 > --- a/lib/report.c > +++ b/lib/report.c > @@ -43,6 +43,16 @@ void report_prefix_pop(void) > spin_unlock(&lock); > } > > +static void report_print(const char *prefix, const char *msg_fmt, va_list > va) > +{ > + spin_lock(&lock); > + printf("%s: ", prefix); > + puts(prefixes); > + vprintf(msg_fmt, va); > + puts("\n"); > + spin_unlock(&lock); > +} > + > static void va_report(const char *msg_fmt, > bool pass, bool xfail, bool skip, va_list va) > { > @@ -50,20 +60,16 @@ static void va_report(const char *msg_fmt, > : xfail ? (pass ? "XPASS" : "XFAIL") > : (pass ? "PASS" : "FAIL"); > > - spin_lock(&lock); > + report_print(prefix, msg_fmt, va); > > + spin_lock(&lock); > tests++; > - printf("%s: ", prefix); > - puts(prefixes); > - vprintf(msg_fmt, va); > - puts("\n"); > if (skip) > skipped++; > else if (xfail && !pass) > xfailures++; > else if (xfail || !pass) > failures++; > - > spin_unlock(&lock); > } > > @@ -95,14 +101,9 @@ void report_info(const char *msg_fmt, ...) > { > va_list va; > > - spin_lock(&lock); > - puts("INFO: "); > - puts(prefixes); > va_start(va, msg_fmt); > - vprintf(msg_fmt, va); > + report_print("INFO", msg_fmt, va); > va_end(va); > - puts("\n"); > - spin_unlock(&lock); > } > > int report_summary(void) > @@ -132,14 +133,10 @@ void report_abort(const char *msg_fmt, ...) > { > va_list va; > > - spin_lock(&lock); > - puts("ABORT: "); > - puts(prefixes); > va_start(va, msg_fmt); > - vprintf(msg_fmt, va); > + report_print("ABORT", msg_fmt, va); > va_end(va); > - puts("\n"); > - spin_unlock(&lock); > + > report_summary(); > abort(); > } > -- > 2.10.2 > > -- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html