Re: [PATCH] of: Fix uninitialized child warning infor_each_child_of_node() if !OF

From: Geert Uytterhoeven
Date: Mon Jan 27 2014 - 09:52:49 EST


On Mon, Jan 27, 2014 at 3:16 PM, Rob Herring <robherring2@xxxxxxxxx> wrote:
> On Sun, Jan 26, 2014 at 4:21 AM, Geert Uytterhoeven
> <geert@xxxxxxxxxxxxxx> wrote:
>> If CONFIG_OF=n:
>>
>> drivers/i2c/i2c-mux.c: In function âi2c_add_mux_adapterâ:
>> drivers/i2c/i2c-mux.c:158: warning: âchildâ is used uninitialized in this function
>> drivers/leds/leds-lp55xx-common.c: In function âlp55xx_of_populate_pdataâ:
>> drivers/leds/leds-lp55xx-common.c:560: warning: âchildâ is used uninitialized in this function
>> drivers/leds/leds-pwm.c: In function âled_pwm_probeâ:
>> drivers/leds/leds-pwm.c:89: warning: âchildâ is used uninitialized in this function
>> drivers/mfd/stmpe.c: In function âstmpe_of_probeâ:
>> drivers/mfd/stmpe.c:1112: warning: âchildâ is used uninitialized in this function
>> drivers/mfd/tc3589x.c: In function âtc3589x_probeâ:
>> drivers/mfd/tc3589x.c:324: warning: âchildâ is used uninitialized in this function
>> drivers/power/charger-manager.c: In function âof_cm_parse_descâ:
>> drivers/power/charger-manager.c:1606: warning: âchildâ is used uninitialized in this function
>>
>> Introduced by commit 00b2c76a6abbe082bb5afb89ee49ec325e9cd4d2
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
>> ("include/linux/of.h: make for_each_child_of_node() reference its args when
>> CONFIG_OF=n").
>>
>> Instead of dropping the "__of_use_dn(child)" again, explicitly set child
>> to NULL, to protect against code using child after the loop (child == NULL
>> is the loop termination condition if CONFIG_OF=y).
>>
>> Signed-off-by: Geert Uytterhoeven <geert@xxxxxxxxxxxxxx>
>
> Just got fixed in mainline:
>
> commit 00b2c76a6abbe082bb5afb89ee49ec325e9cd4d2

Nope, this is the one that introduced new warnings.

> Author: David Howells <dhowells@xxxxxxxxxx>
> Date: Thu Jan 23 15:54:02 2014 -0800
>
> include/linux/of.h: make for_each_child_of_node() reference its
> args when CONFIG_OF=n
>
> Make for_each_child_of_node() reference its args when CONFIG_OF=n to
> avoid warnings like:
>
> drivers/leds/leds-pwm.c:88:22: warning: unused variable 'node'
> [-Wunused-variable]
> struct device_node *node = pdev->dev.of_node;
> ^
>
> Signed-off-by: David Howells <dhowells@xxxxxxxxxx>
> Cc: Grant Likely <grant.likely@xxxxxxxxxx>
> Cc: Rob Herring <robh+dt@xxxxxxxxxx>
> Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx>
> Signed-off-by: Linus Torvalds <torvalds@xxxxxxxxxxxxxxxxxxxx>




--
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/