-
Notifications
You must be signed in to change notification settings - Fork 722
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
Enable -Wsign-Compare-check_bin/_crypto/_stuffer/_utils/ #3825
Conversation
In general, we need to be really careful about conversions that
|
What would be a scenario where downcast (e.g. |
If you have an integer of two sizes you always want to cast to the largest-sized integer that will contain both sides of the comparison. For example, if I want to check if a s2n-tls/crypto/s2n_cbc_cipher_3des.c Line 38 in 09d90b6
This means that if In other words, try to avoid going to a lower bitsize, especially if you haven't checked that the value can actually fit in the lower value. Or just always cast up to the smallest bitsize that will fit the min and max from both operand types. |
That explains a lot, thanks. |
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.
sorry one more nit
Resolved issues:
related to : #3697
Description of changes:
This PR is a part of series of PR's to enable
-Wsign-compare
check. This check warns when a comparison between signed and unsigned values produce an incorrect result. Warning shown when the signed value is converted to unsigned value.This PR contains changes made to files in
bin/
,crypto/
,stuffer/
andutils/
.Call-outs:
To be consistent, I changed the data type int to size_t in for loops and where sizeof operator is used.
Testing:
All tests pass.
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.