From: Andrew Cooper Date: Sun, 12 Apr 2015 01:55:01 +0000 (+0100) Subject: Use vsnprintf() to provide full formatting capabilities to the console X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=941682a94a532b81481bfe5a4ac0ea89593b3439;p=people%2Froyger%2Fxen-test-framework.git Use vsnprintf() to provide full formatting capabilities to the console Signed-off-by: Andrew Cooper --- diff --git a/common/console.c b/common/console.c index fe2551b..34cb89d 100644 --- a/common/console.c +++ b/common/console.c @@ -81,12 +81,25 @@ void init_pv_console(xencons_interface_t *ring, evtchn_port_t port) register_console_callback(pv_console_write); } -void printk(const char *fmt, ...) +void vprintk(const char *fmt, va_list args) { + static char buf[2048]; unsigned int i; + int rc; + + rc = vsnprintf(buf, sizeof(buf), fmt, args); for ( i = 0; i < nr_cons_cb; ++i ) - output_fns[i](fmt, strlen(fmt)); + output_fns[i](buf, rc); +} + +void printk(const char *fmt, ...) +{ + va_list args; + + va_start(args, fmt); + vprintk(fmt, args); + va_end(args); } /* diff --git a/include/xtf/console.h b/include/xtf/console.h index e85236b..2a93c06 100644 --- a/include/xtf/console.h +++ b/include/xtf/console.h @@ -1,6 +1,7 @@ #ifndef XTF_CONSOLE_H #define XTF_CONSOLE_H +#include #include #include @@ -21,6 +22,7 @@ void register_console_callback(cons_output_cb cb); void init_pv_console(xencons_interface_t *ring, evtchn_port_t port); +void vprintk(const char *fmt, va_list args) __printf(1, 0); void printk(const char *fmt, ...) __printf(1, 2); #endif /* XTF_CONSOLE_H */ diff --git a/tests/example/main.c b/tests/example/main.c index beb74de..6e2c53d 100644 --- a/tests/example/main.c +++ b/tests/example/main.c @@ -1,7 +1,9 @@ #include +#include void test_main(void) { + printk("Hello World\n"); } /*