-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix coverity issue in block::initEmptyBlock #1491
Conversation
If result of |
Because it is scary change to do few days before deadline. To do it correctly we should change it from unsigned int to unsigned short in few places. TBH i would rewrite this function anyway at it has other issues, but few days before deadline, i just want fix coverity and do not create new issues. I checked that this code is correct, and added assert just to make coverity also aware that it code is fine. |
To late in the release circle is a good point. Could the TODO be added, to keep the intention explicit? I'm just curious, is moving the assert to |
getObjectSize should not return values bigger then 2^16-1. We are assigning it's return value, which is 32 bit to 16 bit one, so it is good to assert it anyway.
I added TODO. IMHO readability depends how you read this code. If thru GH maybe. If you use IDE then you can check that block::objectSize is uint_16_t so it make sense to assert before assessment were you do "type cast". |
Sorry, I'm not totally understand you position wrt moving the assert inside |
This is one argument. Also sure if you seen |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
getObjectSize should not return values bigger then 2^16-1. We are assigning it's return value, which is 32 bit to 16 bit one, so it is good to assert it anyway.
Description
getObjectSize should not return values bigger then 2^16-1. We are assigning it's return value, which is 32 bit to 16 bit one, so it is good to assert it anyway.
Fixes # - issue number(s) if exists
Type of change
Choose one or multiple, leave empty if none of the other choices apply
Add a respective label(s) to PR if you have permissions
Tests
Documentation
Breaks backward compatibility
Notify the following users
List users with
@
to send notificationsOther information