diff mbox series

[net-next,4/7] drivers: net: smc911x: Fix set but unused status because of DBG macro

Message ID 20201031004958.1059797-5-andrew@lunn.ch
State Changes Requested
Delegated to: David Miller
Headers show
Series smsc W=1 warning fixes | expand

Checks

Context Check Description
jkicinski/cover_letter success Link
jkicinski/fixes_present success Link
jkicinski/patch_count success Link
jkicinski/tree_selection success Clearly marked for net-next
jkicinski/subject_prefix success Link
jkicinski/source_inline success Was 0 now: 0
jkicinski/verify_signedoff success Link
jkicinski/module_param success Was 0 now: 0
jkicinski/build_32bit success Errors and warnings before: 0 this patch: 0
jkicinski/kdoc success Errors and warnings before: 0 this patch: 0
jkicinski/verify_fixes success Link
jkicinski/checkpatch success total: 0 errors, 0 warnings, 0 checks, 12 lines checked
jkicinski/build_allmodconfig_warn success Errors and warnings before: 0 this patch: 0
jkicinski/header_inline success Link
jkicinski/stable success Stable not CCed

Commit Message

Andrew Lunn Oct. 31, 2020, 12:49 a.m. UTC
drivers/net/ethernet/smsc/smc911x.c: In function ‘smc911x_timeout’:
drivers/net/ethernet/smsc/smc911x.c:1251:6: warning: variable ‘status’ set but not used [-Wunused-but-set-variable]
 1251 |  int status, mask;

The status is read in order to print it via the DBG macro. However,
due to the way DBG is disabled, the compiler never sees it being used.

Change the DBG macro to actually make use of the passed parameters,
and the leave the optimiser to remove the unwanted code inside the if
(0).

Signed-off-by: Andrew Lunn <andrew@lunn.ch>
---
 drivers/net/ethernet/smsc/smc911x.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

Comments

Jakub Kicinski Nov. 2, 2020, 11:48 p.m. UTC | #1
On Sat, 31 Oct 2020 01:49:55 +0100 Andrew Lunn wrote:
> drivers/net/ethernet/smsc/smc911x.c: In function ‘smc911x_timeout’:
> drivers/net/ethernet/smsc/smc911x.c:1251:6: warning: variable ‘status’ set but not used [-Wunused-but-set-variable]
>  1251 |  int status, mask;
> 
> The status is read in order to print it via the DBG macro. However,
> due to the way DBG is disabled, the compiler never sees it being used.
> 
> Change the DBG macro to actually make use of the passed parameters,
> and the leave the optimiser to remove the unwanted code inside the if
> (0).
> 
> Signed-off-by: Andrew Lunn <andrew@lunn.ch>
> ---
>  drivers/net/ethernet/smsc/smc911x.c | 6 +++++-
>  1 file changed, 5 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/net/ethernet/smsc/smc911x.c b/drivers/net/ethernet/smsc/smc911x.c
> index 8f748a0c057e..33d0398c182e 100644
> --- a/drivers/net/ethernet/smsc/smc911x.c
> +++ b/drivers/net/ethernet/smsc/smc911x.c
> @@ -102,7 +102,11 @@ MODULE_ALIAS("platform:smc911x");
>  
>  #define PRINTK(dev, args...)   netdev_info(dev, args)
>  #else
> -#define DBG(n, dev, args...)   do { } while (0)
> +#define DBG(n, dev, args...)			 \
> +	do {					 \
> +		if (0)				 \
> +			netdev_dbg(dev, args);	 \
> +	} while (0)

nit: since you have to respin - while (0) { } would do here.
diff mbox series

Patch

diff --git a/drivers/net/ethernet/smsc/smc911x.c b/drivers/net/ethernet/smsc/smc911x.c
index 8f748a0c057e..33d0398c182e 100644
--- a/drivers/net/ethernet/smsc/smc911x.c
+++ b/drivers/net/ethernet/smsc/smc911x.c
@@ -102,7 +102,11 @@  MODULE_ALIAS("platform:smc911x");
 
 #define PRINTK(dev, args...)   netdev_info(dev, args)
 #else
-#define DBG(n, dev, args...)   do { } while (0)
+#define DBG(n, dev, args...)			 \
+	do {					 \
+		if (0)				 \
+			netdev_dbg(dev, args);	 \
+	} while (0)
 #define PRINTK(dev, args...)   netdev_dbg(dev, args)
 #endif