[U-Boot] [PATCH 08/23] Add pr_fmt() macro

Simon Glass sjg at chromium.org
Tue Aug 19 14:58:34 CEST 2014


Hi Thierry,

On 19 August 2014 06:27, Thierry Reding <thierry.reding at gmail.com> wrote:
> On Mon, Aug 18, 2014 at 12:24:06PM -0600, Simon Glass wrote:
>> On 18 August 2014 01:16, Thierry Reding <thierry.reding at gmail.com> wrote:
>> > From: Thierry Reding <treding at nvidia.com>
>> >
>> > This macro can be overridden in source files (before including common.h)
>> > and can be used to specify a prefix for debug and error messages. An
>> > example of how to use this is shown below:
>> >
>> >         #define pr_fmt(fmt) "foo: " fmt
>> >
>> >         #include <common.h>
>> >
>> >         ...
>> >         debug("bar");
>> >
>> > The resulting message will read:
>> >
>> >         foo: bar
>> >
>> > Signed-off-by: Thierry Reding <treding at nvidia.com>
>>
>> Acked-by: Simon Glass <sjg at chromium.org>
>>
>> Seems OK. But I wonder if a string might be simpler?
>>
>> #define DEBUG_PREFIX "foo: "
>>
>> +#ifndef DEBUG_PREFIX
>> +#define DEBUG_PREFIX ""
>> +#endif
>
> The advantage of using the macro is that it can perform more complicated
> transformations on the format string, like this for example:
>
>         #define pr_fmt(fmt) "foo: %s():" fmt, __func__

OK, I figured you might want something like that.

>
> Thierry

Regards,
Simon


More information about the U-Boot mailing list