Closed Bug 1403660 Opened 7 years ago Closed 7 years ago

Do not use 'else' after 'break' in /memory/build/rb.h

Categories

(Core :: Memory Allocator, defect)

47 Branch
defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla58
Tracking Status
firefox58 --- fixed

People

(Reporter: janx, Assigned: janx)

References

Details

Attachments

(1 file, 1 obsolete file)

While inspecting patches, our static analyzer found a readability issue in the 'rb_remove' macro in /memory/build/rb.h:

> In /memory/build/rb.h:
> @@ -622,14 +622,13 @@
>                               rbp_r_t);                                 \
>                         }                                               \
>                         break;                                          \
>                     } else {                                            \
>                       ^
> Warning: Do not use 'else' after 'break' [clang-tidy: readability-else-after-return]

This code could indeed be simplified by removing the unnecessary 'else'.
New try push: https://treeherder.mozilla.org/#/jobs?repo=try&revision=1aa5b6aab773

(I cancelled the previous one, as it seems there was a race condition that included many other changesets in my push.)
glandium is completely changing this code over in bug 1403444, maybe ping him there?
Indeed, thanks!

Glandium, feel free to take over this bug and steal my fix for the 'rb_remove' macro.
Flags: needinfo?(mh+mozilla)
Comment on attachment 8912825 [details] [diff] [review]
Do not use 'else' after 'break' in /memory/build/rb.h.

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

The else is still there after bug 1403444, but please rebase on top of that bug.
Attachment #8912825 - Flags: review?(n.nethercote)
Flags: needinfo?(mh+mozilla)
(In reply to Mike Hommey [:glandium] from comment #5)
> The else is still there after bug 1403444, but please rebase on top of that
> bug.

I will, thanks!
Depends on: 1403444
Rebased on top of bug 1403444.
Attachment #8913230 - Flags: review?(n.nethercote)
Attachment #8912825 - Attachment is obsolete: true
Comment on attachment 8913230 [details] [diff] [review]
Do not use 'else' after 'break' in /memory/build/rb.h.

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

This is harmless, but the Mozilla Coding Style (https://developer.mozilla.org/en-US/docs/Mozilla/Developer_guide/Coding_Style) doesn't say anything about no-else-after-break, it only bans no-else-after-return. I can see that clang-tidy is lumping no-else-after-break into its "readability-else-after-return" check.
Attachment #8913230 - Flags: review?(n.nethercote) → review+
Thanks!

> This is harmless, but the Mozilla Coding Style (https://developer.mozilla.org/en-US/docs/Mozilla/Developer_guide/Coding_Style) doesn't say anything about no-else-after-break, it only bans no-else-after-return. I can see that clang-tidy is lumping no-else-after-break into its "readability-else-after-return" check.

Good catch. I've updated the MDN page to add "(or a `break`)" to clarify.
Keywords: checkin-needed
Pushed by ryanvm@gmail.com:
https://hg.mozilla.org/integration/mozilla-inbound/rev/c93d12aca502
Do not use 'else' after 'break' in /memory/build/rb.h. r=njn
Keywords: checkin-needed
https://hg.mozilla.org/mozilla-central/rev/c93d12aca502
Status: NEW → RESOLVED
Closed: 7 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla58
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: