From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757450AbcCaSNw (ORCPT ); Thu, 31 Mar 2016 14:13:52 -0400 Received: from mail-pa0-f43.google.com ([209.85.220.43]:34992 "EHLO mail-pa0-f43.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751703AbcCaSNu (ORCPT ); Thu, 31 Mar 2016 14:13:50 -0400 Date: Thu, 31 Mar 2016 11:13:47 -0700 From: Dmitry Torokhov To: Arnd Bergmann Cc: Greg Kroah-Hartman , Andrew Lunn , "David S. Miller" , Hiroshi Doyu , Aaron Conole , "Rafael J. Wysocki" , linux-kernel@vger.kernel.org Subject: Re: [PATCH] driver-core: use 'dev' argument in dev_dbg_ratelimited stub Message-ID: <20160331181347.GH39098@dtor-ws> References: <1458854400-3659802-1-git-send-email-arnd@arndb.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1458854400-3659802-1-git-send-email-arnd@arndb.de> User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 > Suggested-by: Andrew Lunn > Fixes: 6f586e663e3b ("driver-core: Shut up dev_dbg_reatelimited() without DEBUG") Reviewed-by: Dmitry Torokhov > --- > 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