* [PATCH] smc91x: avoid self-comparison warning
@ 2016-03-14 22:45 Arnd Bergmann
2016-03-14 23:37 ` David Miller
0 siblings, 1 reply; 2+ messages in thread
From: Arnd Bergmann @ 2016-03-14 22:45 UTC (permalink / raw)
To: Nicolas Pitre
Cc: Arnd Bergmann, David S. Miller, Robert Jarzmik,
Uwe Kleine-König, netdev, linux-kernel
The smc91x driver defines a macro that compares its argument to
itself, apparently to get a true result while using its argument
to avoid a warning about unused local variables.
Unfortunately, this triggers a warning with gcc-6, as the comparison
is obviously useless:
drivers/net/ethernet/smsc/smc91x.c: In function 'smc_hardware_send_pkt':
drivers/net/ethernet/smsc/smc91x.c:563:14: error: self-comparison always evaluates to true [-Werror=tautological-compare]
if (!smc_special_trylock(&lp->lock, flags)) {
This replaces the macro with another one that behaves similarly,
with a cast to (void) to ensure the argument is used, and using
a literal 'true' as its value.
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
drivers/net/ethernet/smsc/smc91x.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/net/ethernet/smsc/smc91x.c b/drivers/net/ethernet/smsc/smc91x.c
index db7db8ac4ca3..c5ed27c54724 100644
--- a/drivers/net/ethernet/smsc/smc91x.c
+++ b/drivers/net/ethernet/smsc/smc91x.c
@@ -540,7 +540,7 @@ static inline void smc_rcv(struct net_device *dev)
#define smc_special_lock(lock, flags) spin_lock_irqsave(lock, flags)
#define smc_special_unlock(lock, flags) spin_unlock_irqrestore(lock, flags)
#else
-#define smc_special_trylock(lock, flags) (flags == flags)
+#define smc_special_trylock(lock, flags) ((void)flags, true)
#define smc_special_lock(lock, flags) do { flags = 0; } while (0)
#define smc_special_unlock(lock, flags) do { flags = 0; } while (0)
#endif
--
2.7.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] smc91x: avoid self-comparison warning
2016-03-14 22:45 [PATCH] smc91x: avoid self-comparison warning Arnd Bergmann
@ 2016-03-14 23:37 ` David Miller
0 siblings, 0 replies; 2+ messages in thread
From: David Miller @ 2016-03-14 23:37 UTC (permalink / raw)
To: arnd; +Cc: nico, robert.jarzmik, u.kleine-koenig, netdev, linux-kernel
From: Arnd Bergmann <arnd@arndb.de>
Date: Mon, 14 Mar 2016 23:45:12 +0100
> The smc91x driver defines a macro that compares its argument to
> itself, apparently to get a true result while using its argument
> to avoid a warning about unused local variables.
>
> Unfortunately, this triggers a warning with gcc-6, as the comparison
> is obviously useless:
>
> drivers/net/ethernet/smsc/smc91x.c: In function 'smc_hardware_send_pkt':
> drivers/net/ethernet/smsc/smc91x.c:563:14: error: self-comparison always evaluates to true [-Werror=tautological-compare]
> if (!smc_special_trylock(&lp->lock, flags)) {
>
> This replaces the macro with another one that behaves similarly,
> with a cast to (void) to ensure the argument is used, and using
> a literal 'true' as its value.
>
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Applied, thanks.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2016-03-14 23:37 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-03-14 22:45 [PATCH] smc91x: avoid self-comparison warning Arnd Bergmann
2016-03-14 23:37 ` David Miller
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).