From: Dmitry Torokhov <dmitry.torokhov@gmail.com>
To: Arnd Bergmann <arnd@arndb.de>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Andrew Lunn <andrew@lunn.ch>,
"David S. Miller" <davem@davemloft.net>,
Hiroshi Doyu <hdoyu@nvidia.com>,
Aaron Conole <aconole@redhat.com>,
"Rafael J. Wysocki" <rafael.j.wysocki@intel.com>,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] driver-core: use 'dev' argument in dev_dbg_ratelimited stub
Date: Thu, 31 Mar 2016 11:13:47 -0700 [thread overview]
Message-ID: <20160331181347.GH39098@dtor-ws> (raw)
In-Reply-To: <1458854400-3659802-1-git-send-email-arnd@arndb.de>
On Thu, Mar 24, 2016 at 10:19:40PM +0100, Arnd Bergmann wrote:
> dev_dbg_ratelimited() is a macro that ignores its first argument when DEBUG is
> not set, which can lead to unused variable warnings:
>
> ethernet/mellanox/mlxsw/pci.c: In function 'mlxsw_pci_cqe_sdq_handle':
> ethernet/mellanox/mlxsw/pci.c:646:18: warning: unused variable 'pdev' [-Wunused-variable]
> ethernet/mellanox/mlxsw/pci.c: In function 'mlxsw_pci_cqe_rdq_handle':
> ethernet/mellanox/mlxsw/pci.c:671:18: warning: unused variable 'pdev' [-Wunused-variable]
>
> The macro already ensures that all its other arguments are silently
> ignored by the compiler without triggering a warning, through the
> use of the no_printk() macro, but the dev argument is not passed into
> that.
>
> This changes the definition to use the same trick as no_printk() with
> an if(0) that leads the compiler to not evaluate the side-effects but
> still see that 'dev' might not be unused.
>
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> Suggested-by: Andrew Lunn <andrew@lunn.ch>
> Fixes: 6f586e663e3b ("driver-core: Shut up dev_dbg_reatelimited() without DEBUG")
Reviewed-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
> ---
> include/linux/device.h | 7 +++++--
> 1 file changed, 5 insertions(+), 2 deletions(-)
>
> diff --git a/include/linux/device.h b/include/linux/device.h
> index 002c59728dbe..07f74c246cac 100644
> --- a/include/linux/device.h
> +++ b/include/linux/device.h
> @@ -1293,8 +1293,11 @@ do { \
> dev_printk(KERN_DEBUG, dev, fmt, ##__VA_ARGS__); \
> } while (0)
> #else
> -#define dev_dbg_ratelimited(dev, fmt, ...) \
> - no_printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__)
> +#define dev_dbg_ratelimited(dev, fmt, ...) \
> +do { \
> + if (0) \
> + dev_printk(KERN_DEBUG, dev, fmt, ##__VA_ARGS__); \
> +} while (0)
> #endif
>
> #ifdef VERBOSE_DEBUG
> --
> 2.7.0
>
--
Dmitry
prev parent reply other threads:[~2016-03-31 18:13 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-03-24 21:19 [PATCH] driver-core: use 'dev' argument in dev_dbg_ratelimited stub Arnd Bergmann
2016-03-31 18:13 ` Dmitry Torokhov [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=20160331181347.GH39098@dtor-ws \
--to=dmitry.torokhov@gmail.com \
--cc=aconole@redhat.com \
--cc=andrew@lunn.ch \
--cc=arnd@arndb.de \
--cc=davem@davemloft.net \
--cc=gregkh@linuxfoundation.org \
--cc=hdoyu@nvidia.com \
--cc=linux-kernel@vger.kernel.org \
--cc=rafael.j.wysocki@intel.com \
/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