Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 27 Oct 2013 23:07:58 +0100
From:      Jilles Tjoelker <jilles@stack.nl>
To:        Bruce Evans <brde@optusnet.com.au>
Cc:        svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org, Ian Lepore <ian@freebsd.org>
Subject:   Re: svn commit: r257203 - head/sys/arm/arm
Message-ID:  <20131027220758.GA12425@stack.nl>
In-Reply-To: <20131028081925.C2294@besplex.bde.org>
References:  <201310270329.r9R3Tcoi076809@svn.freebsd.org> <20131028040222.G929@besplex.bde.org> <1382900401.1170.227.camel@revolution.hippie.lan> <20131028081925.C2294@besplex.bde.org>

next in thread | previous in thread | raw e-mail | index | archive | help
On Mon, Oct 28, 2013 at 08:43:37AM +1100, Bruce Evans wrote:
> 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.

Clang takes advantage of its internal preprocessor to suppress certain
warnings in results of macro expansion. In fact, this is what makes
-Wparentheses-equality possible at all. It does not violate the C
standard, since it is only used to decide whether to issue certain
warnings and does not affect the semantics of the code.

This check breaks down when the internal preprocessor is not used, such
as with ccache.

-- 
Jilles Tjoelker



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20131027220758.GA12425>