-Wlogical-op-parentheses warning in gfx/2d/DrawTargetCG.cpp

RESOLVED DUPLICATE of bug 839384

Status

()

defect
RESOLVED DUPLICATE of bug 839384
7 years ago
7 years ago

People

(Reporter: milan, Assigned: milan)

Tracking

(Blocks 1 bug)

Firefox Tracking Flags

(Not tracked)

Details

Attachments

(1 attachment, 1 obsolete attachment)

A compiler warning on something like this:
if (a == b && c == d || a == f && c == g)
may as well get rid of the warning and make things "safer" to read.

/Users/msreckovic/Development/mozilla-central/gfx/2d/DrawTargetCG.cpp:987:41: warning:

      '&&' within '||' [-Wlogical-op-parentheses]

  ...aType == NATIVE_SURFACE_CGCONTEXT && GetContextType(mCg) == CG_CONTEXT_TYPE_BITMAP ||

     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~

/Users/msreckovic/Development/mozilla-central/gfx/2d/DrawTargetCG.cpp:987:41: note:

      place parentheses around the '&&' expression to silence this warning

  ...aType == NATIVE_SURFACE_CGCONTEXT && GetContextType(mCg) == CG_CONTEXT_TYPE_BITMAP ...

                                       ^

     (                                                                                 )

/Users/msreckovic/Development/mozilla-central/gfx/2d/DrawTargetCG.cpp:988:53: warning:

      '&&' within '||' [-Wlogical-op-parentheses]

  ...aType == NATIVE_SURFACE_CGCONTEXT_ACCELERATED && GetContextType(mCg) == CG_CONTEXT_TYPE_IOSURFACE...

     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

/Users/msreckovic/Development/mozilla-central/gfx/2d/DrawTargetCG.cpp:988:53: note:

      place parentheses around the '&&' expression to silence this warning

  ...aType == NATIVE_SURFACE_CGCONTEXT_ACCELERATED && GetContextType(mCg) == CG_CONTEXT_TYPE_IOSURFACE)…
Add the reference to the beta bug to clean all the warnings.
Blocks: buildwarning
Assignee: nobody → milan
C++ operator precedence being what it is, the original:
if (a == b && c == d || a == f && c == g) {
is the same as:
if (((a == b) && (c == d)) || ((a == f) && (c == g))) {
But without the compiler warning.  No functional/logical change intended.
Attachment #691038 - Flags: review?(bgirard)
Comment on attachment 691038 [details] [diff] [review]
Add explicit parentheses in the compound logical statement

Review of attachment 691038 [details] [diff] [review]:
-----------------------------------------------------------------

Less warning noise masking useful warnings \o/.
NIT: I think adding parentheses around (a == b) is a bit to far.
Attachment #691038 - Flags: review?(bgirard) → review+
Comment on attachment 691100 [details] [diff] [review]
Updated with code review comments

FYI, checkin-needed will get your patches landed much faster in the future
Attachment #691100 - Flags: checkin?
dholbert fixed this in bug 839384 in the mean time :)
Status: NEW → RESOLVED
Closed: 7 years ago
Resolution: --- → DUPLICATE
Duplicate of bug: 839384
You need to log in before you can comment on or make changes to this bug.