Re: [PATCH 1/3] add binary printf

From: Ingo Molnar
Date: Thu Feb 26 2009 - 13:57:13 EST



* Frederic Weisbecker <fweisbec@xxxxxxxxx> wrote:

> Instead of calling the in/out helper from the decoder, why not
> calling the decoder from these three functions and let them
> take the appropriate actions for each decoded format token?
>
> Naive example:
>
> bstr_printf() {
> while (decode_format(...))
> if (type == number)
> read_number_from_buf()
> str = number(....)
> ....
> }
>
> vsnprintf {
> while (decode_format(...))
> if (type == number)
> var_arg(...)
> str = number(....)
> ....
> }
>
> vbin_printf {
> while (decode_format(...))
> if (type == number)
> var_arg(...)
> write_number_to_buffer()
> ...
> }
>
> And the standard in/out pieces can be invoked through helpers.

ok, that looks rather clean too. And maybe vsnprintf() and
bstr_printf() could be further unified?

I guess it depends on how it all looks like in the end. Only one
way to find out ...

Ingo
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/