From: Andrew Morton <akpm@linux-foundation.org>
To: David Howells <dhowells@redhat.com>
Cc: Grant Likely <grant.likely@linaro.org>,
devicetree@vger.kernel.org, Rob Herring <robh+dt@kernel.org>,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH 1/7] Make for_each_child_of_node() reference its args when CONFIG_OF=n
Date: Fri, 3 Jan 2014 14:30:48 -0800 [thread overview]
Message-ID: <20140103143048.ee945c557167755871f23c5f@linux-foundation.org> (raw)
In-Reply-To: <20140103160723.8153.14334.stgit@warthog.procyon.org.uk>
> Subject: [PATCH 1/7] Make for_each_child_of_node() reference its args when CONFIG_OF=n
Nit: Documentation/SubmittingPatches, section 15. "subsystem: " is
missing from all patche titles.
On Fri, 03 Jan 2014 16:07:23 +0000 David Howells <dhowells@redhat.com> wrote:
> 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;
> ^
> ...
>
> --- a/include/linux/of.h
> +++ b/include/linux/of.h
> @@ -377,8 +377,13 @@ static inline bool of_have_populated_dt(void)
> return false;
> }
>
> +/* Kill an unused variable warning on a device_node pointer */
> +static inline void __of_use_dn(const struct device_node *np)
> +{
> +}
> +
> #define for_each_child_of_node(parent, child) \
> - while (0)
> + while (__of_use_dn(parent), __of_use_dn(child), 0)
>
> #define for_each_available_child_of_node(parent, child) \
> while (0)
That's a bit ugly. __maybe_unused fixes it appropriately but can't be
placed into the macro.
I wonder if we should instead generalise it to
static inline void reference_var_to_squish_gcc_warning(const void *p)
{
}
I guess not, until/unless we find other macros which need the same
treatment.
Yes, passing a var to an empty function suppresses the warning. But is
this intentional or a happy accident? Future gcc's could quite
legitimately be enhanced to detect that the arg is still unused and
then we'd need to find a new way of suppressing the warning, if such
exists.
prev parent reply other threads:[~2014-01-03 22:30 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-01-03 16:07 David Howells
2014-01-03 22:30 ` Andrew Morton [this message]
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=20140103143048.ee945c557167755871f23c5f@linux-foundation.org \
--to=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
all inboxes | Powered by JetHome®