Re: [PATCH] omap2/omapfb: make DBG() more resistant in if-else constructions

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, May 10, 2011 at 10:42 AM, Geert Uytterhoeven
<geert@xxxxxxxxxxxxxx> wrote:
> On Tue, May 10, 2011 at 11:20, Niels de Vos <ndevos@xxxxxxxxxx> wrote:
>> When DBG() is used in a simple if-else, the resulting code path
>> currently depends on the definition of DBG(). Inserting the statement in
>> a "do { ... } while (0)" prevents this possible misuse.
>>
>> Signed-off-by: Niels de Vos <ndevos@xxxxxxxxxx>
>
>> --- a/drivers/video/omap2/omapfb/omapfb.h
>> +++ b/drivers/video/omap2/omapfb/omapfb.h
>> @@ -34,8 +34,10 @@
>> Â#ifdef DEBUG
>> Âextern unsigned int omapfb_debug;
>> Â#define DBG(format, ...) \
>> - Â Â Â if (omapfb_debug) \
>> - Â Â Â Â Â Â Â printk(KERN_DEBUG "OMAPFB: " format, ## __VA_ARGS__)
>> + Â Â Â do { \
>> + Â Â Â Â Â Â Â if (omapfb_debug) \
>> + Â Â Â Â Â Â Â Â Â Â Â printk(KERN_DEBUG "OMAPFB: " format, ## __VA_ARGS__); \
>> + Â Â Â while (0)
>
> Where's the closing '}'?

Good catch! That's in a "fixup!" that I forgot to squash :-/
I'll post an update version in a bit.


>> Â#else
>> Â#define DBG(format, ...)
>
> BTW, no printf()-style format checking here.
>
>> Â#endif
>
> What about using the standard pr_debug()/dev_dbg() instead?
> With dynamic debug, it can be enabled at run time.
> As a bonus, you get printf()-style format checking if debugging is disabled.

I think removing DBG() and the omapfb_debug module-parameter is surely
a good thing. Unfortunately DBG() is used quite a bit in the code and
replacing them 'll take some more time. I don't know yet when I find
some time to do and test that.

Thanks for the pointers,
Niels


> Gr{oetje,eeting}s,
>
> Â Â Â Â Â Â Â Â Â Â Â Â Geert
>
> --
> Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@xxxxxxxxxxxxxx
>
> In personal conversations with technical people, I call myself a hacker. But
> when I'm talking to journalists I just say "programmer" or something like that.
> Â Â Â Â Â Â Â Â Â Â Â Â Â ÂÂ ÂÂ -- Linus Torvalds
> --
> 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/
>
>
>
--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Arm (vger)]     [ARM Kernel]     [ARM MSM]     [Linux Tegra]     [Linux WPAN Networking]     [Linux Wireless Networking]     [Maemo Users]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite Trails]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux