* [PATCH] of: Fix uninitialized child warning in for_each_child_of_node() if !OF
@ 2014-01-26 10:21 Geert Uytterhoeven
[not found] ` <1390731668-904-1-git-send-email-geert-Td1EMuHUCqxL1ZNQvxDV9g@public.gmane.org>
0 siblings, 1 reply; 5+ messages in thread
From: Geert Uytterhoeven @ 2014-01-26 10:21 UTC (permalink / raw)
To: Grant Likely, Rob Herring, David Howells, Andrew Morton
Cc: devicetree, linux-kernel, Geert Uytterhoeven
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@linux-m68k.org>
---
include/linux/of.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/include/linux/of.h b/include/linux/of.h
index 70c64ba17fa5..0bf44f2fe092 100644
--- a/include/linux/of.h
+++ b/include/linux/of.h
@@ -383,7 +383,7 @@ static inline void __of_use_dn(const struct device_node *np)
}
#define for_each_child_of_node(parent, child) \
- while (__of_use_dn(parent), __of_use_dn(child), 0)
+ while (__of_use_dn(parent), child = NULL, 0)
#define for_each_available_child_of_node(parent, child) \
while (0)
--
1.7.9.5
^ permalink raw reply related [flat|nested] 5+ messages in thread[parent not found: <1390731668-904-1-git-send-email-geert-Td1EMuHUCqxL1ZNQvxDV9g@public.gmane.org>]
* Re: [PATCH] of: Fix uninitialized child warning in for_each_child_of_node() if !OF [not found] ` <1390731668-904-1-git-send-email-geert-Td1EMuHUCqxL1ZNQvxDV9g@public.gmane.org> @ 2014-01-27 14:16 ` Rob Herring 2014-01-27 14:52 ` Geert Uytterhoeven 0 siblings, 1 reply; 5+ messages in thread From: Rob Herring @ 2014-01-27 14:16 UTC (permalink / raw) To: Geert Uytterhoeven Cc: Grant Likely, Rob Herring, David Howells, Andrew Morton, devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org On Sun, Jan 26, 2014 at 4:21 AM, Geert Uytterhoeven <geert-Td1EMuHUCqxL1ZNQvxDV9g@public.gmane.org> 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-Td1EMuHUCqxL1ZNQvxDV9g@public.gmane.org> Just got fixed in mainline: commit 00b2c76a6abbe082bb5afb89ee49ec325e9cd4d2 Author: David Howells <dhowells-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org> 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-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org> Cc: Grant Likely <grant.likely-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org> Cc: Rob Herring <robh+dt-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org> Signed-off-by: Andrew Morton <akpm-de/tnXTf+JLsfHDXvbKv3WD2FQJk+8+b@public.gmane.org> Signed-off-by: Linus Torvalds <torvalds-de/tnXTf+JLsfHDXvbKv3WD2FQJk+8+b@public.gmane.org> > --- > include/linux/of.h | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/include/linux/of.h b/include/linux/of.h > index 70c64ba17fa5..0bf44f2fe092 100644 > --- a/include/linux/of.h > +++ b/include/linux/of.h > @@ -383,7 +383,7 @@ static inline void __of_use_dn(const struct device_node *np) > } > > #define for_each_child_of_node(parent, child) \ > - while (__of_use_dn(parent), __of_use_dn(child), 0) > + while (__of_use_dn(parent), child = NULL, 0) > > #define for_each_available_child_of_node(parent, child) \ > while (0) > -- > 1.7.9.5 > > -- > To unsubscribe from this list: send the line "unsubscribe devicetree" in > the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org > More majordomo info at http://vger.kernel.org/majordomo-info.html -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org More majordomo info at http://vger.kernel.org/majordomo-info.html ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] of: Fix uninitialized child warning in for_each_child_of_node() if !OF 2014-01-27 14:16 ` Rob Herring @ 2014-01-27 14:52 ` Geert Uytterhoeven [not found] ` <CAMuHMdVNLYoWD=Q+utHUgEBJ1619Q5x=DsZEtmeEbogrQM2a0Q-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org> 0 siblings, 1 reply; 5+ messages in thread From: Geert Uytterhoeven @ 2014-01-27 14:52 UTC (permalink / raw) To: Rob Herring Cc: Grant Likely, Rob Herring, David Howells, Andrew Morton, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org On Mon, Jan 27, 2014 at 3:16 PM, Rob Herring <robherring2@gmail.com> wrote: > On Sun, Jan 26, 2014 at 4:21 AM, Geert Uytterhoeven > <geert@linux-m68k.org> 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@linux-m68k.org> > > Just got fixed in mainline: > > commit 00b2c76a6abbe082bb5afb89ee49ec325e9cd4d2 Nope, this is the one that introduced new warnings. > Author: David Howells <dhowells@redhat.com> > 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@redhat.com> > Cc: Grant Likely <grant.likely@linaro.org> > Cc: Rob Herring <robh+dt@kernel.org> > Signed-off-by: Andrew Morton <akpm@linux-foundation.org> > Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> -- Gr{oetje,eeting}s, Geert -- Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org 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 ^ permalink raw reply [flat|nested] 5+ messages in thread
[parent not found: <CAMuHMdVNLYoWD=Q+utHUgEBJ1619Q5x=DsZEtmeEbogrQM2a0Q-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>]
* Re: [PATCH] of: Fix uninitialized child warning in for_each_child_of_node() if !OF [not found] ` <CAMuHMdVNLYoWD=Q+utHUgEBJ1619Q5x=DsZEtmeEbogrQM2a0Q-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org> @ 2014-01-27 16:21 ` Rob Herring [not found] ` <CAL_JsqJyaMDkj6jE+qk6AuUNB0-TOLdqeYDBdjH+1YJFu2V0DQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org> 0 siblings, 1 reply; 5+ messages in thread From: Rob Herring @ 2014-01-27 16:21 UTC (permalink / raw) To: Geert Uytterhoeven Cc: Grant Likely, Rob Herring, David Howells, Andrew Morton, devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org On Mon, Jan 27, 2014 at 8:52 AM, Geert Uytterhoeven <geert-Td1EMuHUCqxL1ZNQvxDV9g@public.gmane.org> wrote: > On Mon, Jan 27, 2014 at 3:16 PM, Rob Herring <robherring2-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >> On Sun, Jan 26, 2014 at 4:21 AM, Geert Uytterhoeven >> <geert-Td1EMuHUCqxL1ZNQvxDV9g@public.gmane.org> 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-Td1EMuHUCqxL1ZNQvxDV9g@public.gmane.org> >> >> Just got fixed in mainline: >> >> commit 00b2c76a6abbe082bb5afb89ee49ec325e9cd4d2 > > Nope, this is the one that introduced new warnings. Oh right, sorry. Read that too fast. Won't your change trigger warnings from -Wunused-but-set-variable in cases where child is not used? That would only be enabled for "W=1" though. I think the right fix here is all the for_each_X macros should not be conditional on CONFIG_OF and we should rely on the functions they call like of_get_next_child to do the right thing for !OF. Rob -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org More majordomo info at http://vger.kernel.org/majordomo-info.html ^ permalink raw reply [flat|nested] 5+ messages in thread
[parent not found: <CAL_JsqJyaMDkj6jE+qk6AuUNB0-TOLdqeYDBdjH+1YJFu2V0DQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>]
* Re: [PATCH] of: Fix uninitialized child warning in for_each_child_of_node() if !OF [not found] ` <CAL_JsqJyaMDkj6jE+qk6AuUNB0-TOLdqeYDBdjH+1YJFu2V0DQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org> @ 2014-01-27 16:23 ` Geert Uytterhoeven 0 siblings, 0 replies; 5+ messages in thread From: Geert Uytterhoeven @ 2014-01-27 16:23 UTC (permalink / raw) To: Rob Herring Cc: Grant Likely, Rob Herring, David Howells, Andrew Morton, devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org On Mon, Jan 27, 2014 at 5:21 PM, Rob Herring <robherring2-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > On Mon, Jan 27, 2014 at 8:52 AM, Geert Uytterhoeven > <geert-Td1EMuHUCqxL1ZNQvxDV9g@public.gmane.org> wrote: >> On Mon, Jan 27, 2014 at 3:16 PM, Rob Herring <robherring2-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >>> On Sun, Jan 26, 2014 at 4:21 AM, Geert Uytterhoeven >>> <geert-Td1EMuHUCqxL1ZNQvxDV9g@public.gmane.org> 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-Td1EMuHUCqxL1ZNQvxDV9g@public.gmane.org> >>> >>> Just got fixed in mainline: >>> >>> commit 00b2c76a6abbe082bb5afb89ee49ec325e9cd4d2 >> >> Nope, this is the one that introduced new warnings. > > Oh right, sorry. Read that too fast. > > Won't your change trigger warnings from -Wunused-but-set-variable in > cases where child is not used? That would only be enabled for "W=1" > though. > > I think the right fix here is all the for_each_X macros should not be > conditional on CONFIG_OF and we should rely on the functions they call > like of_get_next_child to do the right thing for !OF. That's indeed an alternative fix. As long as of_get_next_child() and friends return NULL, that'll work fine. Gr{oetje,eeting}s, Geert -- Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org 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 devicetree" in the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org More majordomo info at http://vger.kernel.org/majordomo-info.html ^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2014-01-27 16:23 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-01-26 10:21 [PATCH] of: Fix uninitialized child warning in for_each_child_of_node() if !OF Geert Uytterhoeven
[not found] ` <1390731668-904-1-git-send-email-geert-Td1EMuHUCqxL1ZNQvxDV9g@public.gmane.org>
2014-01-27 14:16 ` Rob Herring
2014-01-27 14:52 ` Geert Uytterhoeven
[not found] ` <CAMuHMdVNLYoWD=Q+utHUgEBJ1619Q5x=DsZEtmeEbogrQM2a0Q-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2014-01-27 16:21 ` Rob Herring
[not found] ` <CAL_JsqJyaMDkj6jE+qk6AuUNB0-TOLdqeYDBdjH+1YJFu2V0DQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2014-01-27 16:23 ` Geert Uytterhoeven
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).