some question about snprintf

loody miloody at gmail.com
Sun Feb 6 04:23:01 EST 2011


hi:

2011/2/6 loody <miloody at gmail.com>:
> hi all:
> I want to use snprintf for collecting debug message and print it later.
> But I found :
> 1. when I add "\n" as below, the buffer will be cleared, that means
> the "irq status" will put at the head of Buffer instead of at the end
> of "ehci work".
>    Size -= snprintf (Buffer , Size,"ehci_work\n");
>    Size -= snprintf (Buffer , Size,"irq status 0x%x\n",status);
> is it possible to add "\n" in the buffer, but will will not reset the buffer?
>
> 2. instead of snprintf, is there any better idea for saving debug
> message and show it out later?
3. is there any function in kernel, like snprintf, which will also
collect strings but tread the buffer as ring buffer, such that I will
not need to take care the overflow.
BR,
miloody



More information about the Kernelnewbies mailing list