-
-
Notifications
You must be signed in to change notification settings - Fork 32.3k
gh-106550: Fix sign conversion in pycore_code.h #112613
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
Fix sign conversion in pycore_code.h: use unsigned integers and cast explicitly when needed.
@@ -473,12 +475,12 @@ adaptive_counter_cooldown(void) { | |||
|
|||
static inline uint16_t | |||
adaptive_counter_backoff(uint16_t counter) { | |||
unsigned int backoff = counter & ((1<<ADAPTIVE_BACKOFF_BITS)-1); | |||
uint16_t backoff = counter & ((1 << ADAPTIVE_BACKOFF_BITS) - 1); |
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.
Is there difference between 1 << ADAPTIVE_BACKOFF_BITS
and 1u << ADAPTIVE_BACKOFF_BITS
?
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.
I hesitated to replace 1 with 1U. With proposed code, there is no warning. With 1U I got additional warnings 🤷🏻♂️ Maybe because "unsigned int" is larger than uint16_t. I don't know rules of implicit cast in C.
Thanks @vstinner for the PR 🌮🎉.. I'm working now to backport this PR to: 3.12. |
GH-112696 is a backport of this pull request to the 3.12 branch. |
Fix sign conversion in pycore_code.h: use unsigned integers and cast explicitly when needed. (cherry picked from commit a74902a) Co-authored-by: Victor Stinner <[email protected]>
Merged, thanks for the review Serhiy. |
…112696) gh-106550: Fix sign conversion in pycore_code.h (GH-112613) Fix sign conversion in pycore_code.h: use unsigned integers and cast explicitly when needed. (cherry picked from commit a74902a) Co-authored-by: Victor Stinner <[email protected]>
Fix sign conversion in pycore_code.h: use unsigned integers and cast explicitly when needed.
Fix sign conversion in pycore_code.h: use unsigned integers and cast explicitly when needed.
Fix sign conversion in pycore_code.h: use unsigned integers and cast explicitly when needed.