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)

defect

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.
Blocks: 1241574
Status: NEW → ASSIGNED
Priority: -- → P1
Whiteboard: [psm-assigned]
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
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.

Attachment

General

Creator:
Created:
Updated:
Size: