Closed
Bug 1289366
Opened 8 years ago
Closed 8 years ago
[Static Analysis] Control may reach end of non-void function in CharToByte from CTTestUtils.cpp
Categories
(Core :: Security: PSM, defect, P1)
Core
Security: PSM
Tracking
()
RESOLVED
FIXED
mozilla50
Tracking | Status | |
---|---|---|
firefox50 | --- | fixed |
People
(Reporter: andi, Assigned: andi)
References
Details
(Whiteboard: [psm-assigned])
Attachments
(1 file)
As we are trying to integrate 1283395, i'm having this error when building:
security/certverifier/tests/gtest/CTTestUtils.cpp:128:1: error: control may reach end of non-void function [-Werror,-Wreturn-type]
This is because function CharToByte doesn't return a value on all it's return paths.
>>static uint8_t
>>CharToByte(char c)
>>{
>> if (c >= '0' && c <= '9') {
>> return c - '0';
>> } else if (c >= 'a' && c <= 'f') {
>> return c - 'a' + 10;
>> } else if (c >= 'A' && c <= 'F') {
>> return c - 'A' + 10;
>> }
>> MOZ_RELEASE_ASSERT(false);
}
I think this worked now since the branch prediction for MOZ_RELEASE_ASSERT(false) was consistent thus in this case function would have always abort.
As we have added a signature function on static analysis builds - clang based analysis, this is not the case anymore so i think branching cannot be predicted so well and in this case a control flow problem is signalled by the compiler.
Assignee | ||
Comment 1•8 years ago
|
||
Review commit: https://reviewboard.mozilla.org/r/67130/diff/#index_header See other reviews: https://reviewboard.mozilla.org/r/67130/
Attachment #8774671 -
Flags: review?(dkeeler)
Updated•8 years ago
|
Assignee | ||
Updated•8 years ago
|
No longer blocks: coverity-analysis
Attachment #8774671 -
Flags: review?(dkeeler) → review+
Comment on attachment 8774671 [details] Bug 1289366 - added return statement for CharToByte when assertion fails. https://reviewboard.mozilla.org/r/67130/#review64126 LGTM. Thanks for taking care of this.
Pushed by bpostelnicu@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/232175372fa0 added return statement for CharToByte when assertion fails. r=keeler
Comment 4•8 years ago
|
||
bugherder |
https://hg.mozilla.org/mozilla-central/rev/232175372fa0
Status: ASSIGNED → RESOLVED
Closed: 8 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla50
You need to log in
before you can comment on or make changes to this bug.
Description
•