linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Geert Uytterhoeven <geert@linux-m68k.org>
To: Grant Likely <grant.likely@linaro.org>,
	Rob Herring <robh+dt@kernel.org>,
	David Howells <dhowells@redhat.com>,
	Andrew Morton <akpm@linux-foundation.org>
Cc: devicetree@vger.kernel.org, linux-kernel@vger.kernel.org,
	Geert Uytterhoeven <geert@linux-m68k.org>
Subject: [PATCH] of: Fix uninitialized child warning in for_each_child_of_node() if !OF
Date: Sun, 26 Jan 2014 11:21:08 +0100	[thread overview]
Message-ID: <1390731668-904-1-git-send-email-geert@linux-m68k.org> (raw)

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


             reply	other threads:[~2014-01-26 10:21 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-01-26 10:21 Geert Uytterhoeven [this message]
2014-01-27 14:16 ` [PATCH] of: Fix uninitialized child warning in for_each_child_of_node() if !OF Rob Herring
2014-01-27 14:52   ` Geert Uytterhoeven
2014-01-27 16:21     ` Rob Herring
2014-01-27 16:23       ` Geert Uytterhoeven

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1390731668-904-1-git-send-email-geert@linux-m68k.org \
    --to=geert@linux-m68k.org \
    --cc=akpm@linux-foundation.org \
    --cc=devicetree@vger.kernel.org \
    --cc=dhowells@redhat.com \
    --cc=grant.likely@linaro.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=robh+dt@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).