Closed Bug 829993 Opened 12 years ago Closed 11 years ago

nsCSSRenderingBorders.cpp:907:21: warning: variable 'borderRenderStyle' is used uninitialized whenever 'for' loop exits because its condition is false [-Wsometimes-uninitialized]

Categories

(Core :: CSS Parsing and Computation, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla28
Tracking Status
firefox28 --- fixed

People

(Reporter: dholbert, Assigned: jaas)

References

(Blocks 1 open bug, )

Details

(Whiteboard: [qa-])

Attachments

(2 files)

Build warning: { ../../../../layout/base/nsCSSRenderingBorders.cpp:907:21: warning: variable 'borderRenderStyle' is used uninitialized whenever 'for' loop exits because its condition is false [-Wsometimes-uninitialized] NS_FOR_CSS_SIDES (i) { ^~ ../../../../layout/base/nsStyleConsts.h:22:76: note: expanded from macro 'NS_FOR_CSS_SIDES' #define NS_FOR_CSS_SIDES(var_) for (mozilla::css::Side var_ = NS_SIDE_TOP; var_ <= NS_SIDE_LEFT; var_++) ^ ../../../../layout/base/nsCSSRenderingBorders.cpp:916:7: note: uninitialized use occurs here if (borderRenderStyle == NS_STYLE_BORDER_STYLE_NONE || ^~~~~~~~~~~~~~~~~ ../../../../layout/base/nsCSSRenderingBorders.cpp:907:21: note: remove the condition if it is always true NS_FOR_CSS_SIDES (i) { ^ ../../../../layout/base/nsStyleConsts.h:22:76: note: expanded from macro 'NS_FOR_CSS_SIDES' #define NS_FOR_CSS_SIDES(var_) for (mozilla::css::Side var_ = NS_SIDE_TOP; var_ <= NS_SIDE_LEFT; var_++) ^ ../../../../layout/base/nsCSSRenderingBorders.cpp:899:28: note: initialize the variable 'borderRenderStyle' to silence this warning uint8_t borderRenderStyle; ^ = '\0' 1 warning generated. } This is visible in e.g. the context in this build log (though it's not responsible for the build failure there -- it just happens to be in the same area of the shortlog): https://tbpl.mozilla.org/php/getParsedLog.php?id=18748969&tree=Mozilla-Inbound Looks like we probably want to initialize borderRenderStyle to NS_STYLE_BORDER_STYLE_NONE (?) This code dates back to this cset: https://hg.mozilla.org/mozilla-central/rev/f34a9f851cd1#l4.669 from bug 424423.
Attached patch Fix v1.0Splinter Review
Assignee: nobody → joshmoz
Attachment #813982 - Flags: review?(dbaron)
Comment on attachment 813982 [details] [diff] [review] Fix v1.0 I'd rather not make changes like this; I think it's more valuable to gave valgrind warnings when there are real problems than cover them up to silence compiler warnings when the compiler isn't able to analyze the code fully.
Attachment #813982 - Flags: review?(dbaron) → review-
Assignee: joshmoz → nobody
Is there another way we can silence the clang warning, with a #pragma maybe?
Not the prettiest thing to behold, but this squelches the warning.
Attachment #8339781 - Flags: review?(dbaron)
Comment on attachment 8339781 [details] [diff] [review] alternate patch, wrap pragmas around borderRenderStyle to squelch compiler warning This is even uglier; I guess I'd rather take Josh's patch.
Attachment #8339781 - Flags: review?(dbaron) → review-
Status: NEW → RESOLVED
Closed: 11 years ago
Resolution: --- → FIXED
Assignee: nobody → joshmoz
Target Milestone: --- → mozilla28
Whiteboard: [qa-]
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: