On Sun, 27 Oct 2013, Ian Lepore wrote:
On Mon, 2013-10-28 at 04:42 +1100, Bruce Evans wrote:
On Sun, 27 Oct 2013, Ian Lepore wrote:
Log:
Eliminate a compiler warning about extraneous parens.
Wow, what flags give these warnings?
--- busdma_machdep.o ---
/local/build/staging/freebsd/dp10/src/sys/arm/arm/busdma_machdep.c:811:24:
warning: equality comparison with extraneous parentheses
[-Wparentheses-equality]
if ((map->pagesneeded == 0)) {
~~~~~~~~~~~~~~~~~^~~~
Ahh. I guess what I really want is -Wredundant-parentheses
-Wredundant-braces ... The parser can easily tell what is redundant
than what is bogus since bogusness depends on style and too many
suboptions would be required to specify styles
(-Wparentheses[-operator][-context].
Oops, the parser easily can't do this right because macro parameters
must usually have redundant parentheses and C parsers are specified
to act as if on the output of the preprocessor so they can't easily
either have a special case to ignore these redundant parentheses or
know that they aren't in the unpreprocessed source so they should be
ignored.
/local/build/staging/freebsd/dp10/src/sys/arm/arm/busdma_machdep.c:811:24:
note: remove extraneous parentheses around the comparison to silence this
warning
if ((map->pagesneeded == 0)) {
~ ^ ~
/local/build/staging/freebsd/dp10/src/sys/arm/arm/busdma_machdep.c:811:24:
note: use '=' to turn this equality comparison into an assignment
if ((map->pagesneeded == 0)) {
^~
=
That's what the compiler had to say about it. I guess in somebody's
mind if it's a probable error to have done
...
This expression could be the result of a macro
#define ISZERO(x) ((x) == 0)
which for if (ISZERO(map->pagesneeded)) expands to almost the above. I
guess clang warns excessively about this.
The warning doesn't bother me as much as the two useless notes that
follow it (which are annoying when combined with my editor's feature of
parsing compiler output and jumping to the next error point in the
code). I've notice clang is particularly chatty, with things like
suggesting what you might have meant when you spell a variable name
wrong. Before long it's going to be like RPG and COBOL where it's
willing to assume what you meant and try to generate runnable code in
the face of almost any error.
The verbose prettyprinted output can be annoying. If clang would print
its man page then I might know its options so I could turn it off :-).
I probably date myself with references to RPG and COBOL, but it does
bring back fond memories of slapping a boilerplate header on every
interoffice memo issued by management and running it through the cobol
compiler, and grading them on whether their memos generated runnable
code or so many errors the compiler gave up.
I started late enough to not touch these or spend more than 2 years on
accounting-related software.
Bruce
_______________________________________________
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"