-
Notifications
You must be signed in to change notification settings - Fork 24
Resolve -Wconversion and -Wsign-conversion warnings #552
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
Conversation
878529f to
776981c
Compare
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.
Thank you @mkannwischer for embarking on this! There are a few cases where I think we should document why the cast is safe, or try to avoid it altogether. Otherwise, we may as well leave the warnings off.
51a6d72 to
3b6dd16
Compare
85beb05 to
3858af1
Compare
3858af1 to
5ed3488
Compare
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.
Thank you @mkannwischer, this is definitely an improvement. I quite like how the conversion warnings force you to think about the bounds.
This commit introduces helper functions mld_cast_uint32_to_int32, mld_cast_int32_to_uint32, and mld_cast_int64_to_uint32 for int64_t->uint32_t, and int32_t <-> uint32_t. This cleans up prior code and also removes the need for some pragmas stopping CBMC from flagging value-changing integer conversions. This commit is based on pq-code-package/mlkem-native@e5adf3a (but for 32-bit integers. Signed-off-by: Matthias J. Kannwischer <[email protected]>
This commit enables additional warnings (-Wconversion, -Wsign-conversions) requiring more explicit casts. All of those casts should already be safe as checked by CBMC. Resolves #543 Signed-off-by: Matthias J. Kannwischer <[email protected]>
Since the addition of -Wconversion and -Wsign-conversion to the default CFLAGS, compilation of the CMSIS files for AN547 fails. This commit allows custom Makefiles to not only provide EXTRA_SOURCES to specify additional sources, but also EXTRA_SOURCES_CFLAGS for additional CFLAGS, which in particular may overwrite default CFLAGS (they apply later). This is leveraged in the case of m55-an547/platform.mk to disable conversion and sign-conversion warnings for all CMSIS files. Port of pq-code-package/mlkem-native@15fa58e Signed-off-by: Matthias J. Kannwischer <[email protected]>
5ed3488 to
786e8f6
Compare
This commit enables additional warnings (-Wconversion, -Wsign-conversions) requiring more explicit casts.
All of those casts should already be safe as checked by CBMC.
-Wconversionand-Wsign-conversionwarnings (and resolve findings) #543