Fix bit offset undefined behaviour in SET#2
Open
Wesmania wants to merge 1 commit intothkala:masterfrom
Open
Conversation
SET macro is used to set bits of unsigned long, but the shifted numeric constants are ints, left-shifting too much causes undefined behaviour. Cast constants to target type before shifting. Signed-off-by: Igor Kotrasinski <ikotrasinsk@gmail.com>
Owner
|
(Disclaimer: I did not have the time to really look into this, so beware...) IIRC typeof() is a GNU compiler extension. Rather than using something like that, wouldn't it be simpler to just use 1U to force the constants to unsigned? How did this problem manifest, anyway? insert_rant_about_10yo_C_code_and_how_I_d_have_done_it_differently_now() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
SET macro is used to set bits of unsigned long, but the shifted numeric
constants are ints, left-shifting too much causes undefined behaviour.
Cast constants to target type before shifting.
Signed-off-by: Igor Kotrasinski ikotrasinsk@gmail.com