Closed Bug 1222887 Opened 10 years ago Closed 10 years ago

Fix -Wunreachable-code warning in tools/power

Categories

(Core :: General, defect)

Unspecified
macOS
defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla45
Tracking Status
firefox45 --- fixed

People

(Reporter: cpeterson, Assigned: cpeterson)

References

Details

Attachments

(1 file, 1 obsolete file)

tools/power/rapl.cpp:844:5 [-Wunreachable-code] code will never be executed clang reports a -Wunreachable-code warning for sigemptyset() because Darwin's sigemptyset() is a macro that always returns 0. Thus `if (sigemptyset(&sa.sa_mask) < 0)` is always false and `Abort("sigemptyset() failed")` is never called. Linux's sigemptyset() can return 0 or -1. /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk/usr/include/signal.h #define sigemptyset(set) (*(set) = 0, 0)
Attachment #8684753 - Flags: review?(n.nethercote)
Comment on attachment 8684753 [details] [diff] [review] Wunreachable-code_tools-power.patch Review of attachment 8684753 [details] [diff] [review]: ----------------------------------------------------------------- This is fine for Mac but on Linux it removes the checking, which is bad. I suggest instead either (a) having different code paths for Linux and Mac, or (b) using a pragma to disable -Wunreachable for that line of code. What do you think? BTW, do you know why this doesn't show up on TreeHerder? This file should be compiled with warnings as errors.
Attachment #8684753 - Flags: review?(n.nethercote) → review-
(In reply to Nicholas Nethercote [:njn] from comment #1) > Comment on attachment 8684753 [details] [diff] [review] > Wunreachable-code_tools-power.patch > > Review of attachment 8684753 [details] [diff] [review]: > ----------------------------------------------------------------- > > This is fine for Mac but on Linux it removes the checking, which is bad. I > suggest instead either (a) having different code paths for Linux and Mac, or Fair enough. :) > (b) using a pragma to disable -Wunreachable for that line of code. What do > you think? This patch uses clang's suggested approach to suppress the warning: add extra parens around the 0 in `if (sigemptyset(&sa.sa_mask) < (0))`. > BTW, do you know why this doesn't show up on TreeHerder? This file should be > compiled with warnings as errors. clang's and gcc's -Wunreachable-code warning is not enabled by default. I'm close to fixing the last dozen -Wunreachable-code warnings in mozilla-central so we can opt into the warning.
Attachment #8684753 - Attachment is obsolete: true
Attachment #8685049 - Flags: review?(n.nethercote)
Comment on attachment 8685049 [details] [diff] [review] Wunreachable-code_rapl_v2.patch Review of attachment 8685049 [details] [diff] [review]: ----------------------------------------------------------------- Interesting!
Attachment #8685049 - Flags: review?(n.nethercote) → review+
> clang's and gcc's -Wunreachable-code warning is not enabled by default. I'm > close to fixing the last dozen -Wunreachable-code warnings in > mozilla-central so we can opt into the warning. Excellent.
Status: NEW → RESOLVED
Closed: 10 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla45
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: