From: David Laight <David.Laight@ACULAB.COM>
To: 'Andrew Lunn' <andrew@lunn.ch>, Joe Perches <joe@perches.com>
Cc: Alex Shi <alex.shi@linux.alibaba.com>,
Florian Fainelli <f.fainelli@gmail.com>,
Vivien Didelot <vivien.didelot@gmail.com>,
"Vladimir Oltean" <olteanv@gmail.com>,
"David S. Miller" <davem@davemloft.net>,
"Jakub Kicinski" <kuba@kernel.org>,
"netdev@vger.kernel.org" <netdev@vger.kernel.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: RE: [PATCH] net/dsa: remove unused macros to tame gcc warning
Date: Sun, 8 Nov 2020 12:39:03 +0000 [thread overview]
Message-ID: <e0a266295d4e4e9b96546f99b2ebc3a5@AcuMS.aculab.com> (raw)
In-Reply-To: <20201107223301.GY933237@lunn.ch>
From: Andrew Lunn
> Sent: 07 November 2020 22:33
>
> On Sat, Nov 07, 2020 at 09:39:42AM -0800, Joe Perches wrote:
> > On Sat, 2020-11-07 at 20:54 +0800, Alex Shi wrote:
> > > 在 2020/11/7 上午12:39, Florian Fainelli 写道:
> > > > > It is good to remember that there are multiple readers of source
> > > > > files. There is the compiler which generates code from it, and there
> > > > > is the human trying to understand what is going on, what the hardware
> > > > > can do, how we could maybe extend the code in the future to make use
> > > > > of bits are currently don't, etc.
> > > > >
> > > > > The compiler has no use of these macros, at the moment. But i as a
> > > > > human do. It is valuable documentation, given that there is no open
> > > > > datasheet for this hardware.
> > > > >
> > > > > I would say these warnings are bogus, and the code should be left
> > > > > alone.
> > > > Agreed, these definitions are intended to document what the hardware
> > > > does. These warnings are getting too far.
> > >
> > > Thanks for all comments! I agree these info are much meaningful.
> > > Is there other way to tame the gcc warning? like put them into a .h file
> > > or covered by comments?
> >
> > Does _any_ version of gcc have this warning on by default?
> >
> > I still think my proposal of moving the warning from W=2 to W=3
> > quite reasonable.
> >
> > Another possibility is to turn the warning off altogether.
>
> Lets tern the question around first. How many real bugs have you found
> with this warning? Places where the #define should of been used, but
> was not? Then we can get an idea of the value of this warning. My
> guess would be, its value is ~ 0 for the kernel. If so, we should just
> turn it off.
Sometimes there are defines for 0, 1 and 2 (enumeration or bitmap)
and the one for 0 is never used.
Rather than delete the define for 0 (which has been proposed at
least once in this series) the 'fix' would be to find the
initialisation and replace the literal 0 with the define.
OTOH it is probably implicit from a memset().
Even if never actually used the define for 0 helps the
human reading the code.
The same is true when there are defines for hardware register bits.
It is useful to know what they all mean - even if some aren't used.
David
-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)
prev parent reply other threads:[~2020-11-08 12:44 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-11-06 5:37 [PATCH] net/dsa: remove unused macros to tame gcc warning Alex Shi
2020-11-06 6:36 ` Joe Perches
2020-11-06 8:28 ` Alex Shi
2020-11-06 8:52 ` Joe Perches
2020-11-06 8:57 ` Alex Shi
2020-11-06 9:24 ` David Laight
2020-11-06 14:18 ` Andrew Lunn
2020-11-06 16:39 ` Florian Fainelli
2020-11-07 12:54 ` Alex Shi
2020-11-07 17:39 ` Joe Perches
2020-11-07 22:33 ` Andrew Lunn
2020-11-08 12:39 ` David Laight [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=e0a266295d4e4e9b96546f99b2ebc3a5@AcuMS.aculab.com \
--to=david.laight@aculab.com \
--cc=alex.shi@linux.alibaba.com \
--cc=andrew@lunn.ch \
--cc=davem@davemloft.net \
--cc=f.fainelli@gmail.com \
--cc=joe@perches.com \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=olteanv@gmail.com \
--cc=vivien.didelot@gmail.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