Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a `printk()` function supporting `va_list`?

Tags:

c

linux-kernel

I'm currently writing a Linux kernel module, and I need to handle va_list in one of my functions, which looks like:

void blah(int flag, va_list va) {
    ...
    if (flag & BLAH_1) {
        ...
        printk(... va here ...); // where I need the printk() with va_list support
        ...
    }
    ...
}

So I need a printk()-like function which supports varargs. Like vprintf() to printf().

I Google'd for vprintk, but had no luck finding it.

like image 364
Santa Zhang Avatar asked Nov 24 '11 13:11

Santa Zhang


1 Answers

You can always use vsnprintf() to format a va_list into a buffer, and pass that buffer to printk().

However, a vprintk() function seems to exist in the kernel.

like image 126
Frédéric Hamidi Avatar answered Oct 04 '22 21:10

Frédéric Hamidi