Closed Bug 1235297 Opened 8 years ago Closed 8 years ago

Fix -Wimplicit-fallthrough warnings in image/decoders/

Categories

(Core :: Graphics: ImageLib, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla47
Tracking Status
firefox47 --- fixed

People

(Reporter: cpeterson, Assigned: cpeterson)

References

Details

Attachments

(1 file)

Comment on attachment 8702185 [details] [diff] [review]
image_MOZ_FALLTHROUGH.patch

clang's -Wimplicit-fallthrough warnings (not yet enabled in mozilla-central) warn about switch cases that fall through without a break or return statement. MOZ_FALLTHROUGH (bug 1215411) is an annotation to suppress -Wimplicit-fallthrough warnings where the fallthrough is intentional, but in this case, the switch code can be rearranged to return without falling through.

MOZ_FALLTHROUGH_ASSERT (bug 1235277) will suppress -Wimplicit-fallthrough warnings about switch cases that MOZ_ASSERT(false) (or its alias MOZ_ASSERT_UNREACHABLE) in debug builds, but intentionally fall through in release builds.

Why do we need MOZ_FALLTHROUGH_ASSERT in addition to MOZ_FALLTHROUGH? In release builds, the MOZ_ASSERT(false) will expand to `do { } while (0)`, requiring a MOZ_FALLTHROUGH annotation to suppress a -Wimplicit-fallthrough warning. In debug builds, the MOZ_ASSERT(false) will expand to something like `if (true) { MOZ_CRASH(); }` and the MOZ_FALLTHROUGH annotation will cause a -Wunreachable-code warning. The MOZ_FALLTHROUGH_ASSERT macro breaks this warning stalemate.

The warnings:

image/FrameAnimator.cpp:442:5: warning: unannotated fall-through between switch labels [-Wimplicit-fallthrough]
image/FrameAnimator.cpp:576:7: warning: unannotated fall-through between switch labels [-Wimplicit-fallthrough]

image/decoders/nsGIFDecoder2.cpp:1110:5 [-Wimplicit-fallthrough] unannotated fall-through between switch labels

image/decoders/nsJPEGDecoder.cpp:418:3 [-Wimplicit-fallthrough] unannotated fall-through between switch labels
image/decoders/nsJPEGDecoder.cpp:444:3 [-Wimplicit-fallthrough] unannotated fall-through between switch labels
image/decoders/nsJPEGDecoder.cpp:465:3 [-Wimplicit-fallthrough] unannotated fall-through between switch labels
image/decoders/nsJPEGDecoder.cpp:537:3 [-Wimplicit-fallthrough] unannotated fall-through between switch labels
Attachment #8702185 - Flags: review?(seth) → review?(tnikkel)
Comment on attachment 8702185 [details] [diff] [review]
image_MOZ_FALLTHROUGH.patch

Thanks for the explanation.
Attachment #8702185 - Flags: review?(tnikkel) → review+
https://hg.mozilla.org/mozilla-central/rev/70f3f851ab56
Status: NEW → RESOLVED
Closed: 8 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla47
Blocks: 1253170
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: