FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

gh-106550: Fix sign conversion in pycore_code.h by vstinner · Pull Request #112613 · python/cpython · GitHub

Repository navigation

gh-106550: Fix sign conversion in pycore_code.h - #112613

Merged
vstinner merged 1 commit into
python:mainfrom
vstinner:code_unsigned
Dec 4, 2023
Merged

vstinner merged 1 commit into
python:mainfrom
vstinner:code_unsigned

Conversation

vstinner commented Dec 2, 2023 •
edited by bedevere-app Bot
Loading

Copy link
Copy Markdown
Member

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.
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);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Is there difference between 1 << ADAPTIVE_BACKOFF_BITS and 1u << ADAPTIVE_BACKOFF_BITS?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

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.

vstinner merged commit a74902a into python:main Dec 4, 2023
vstinner deleted the code_unsigned branch December 4, 2023 10:43

Copy link
Copy Markdown

Thanks @vstinner for the PR 🌮🎉.. I'm working now to backport this PR to: 3.12.
🐍🍒⛏🤖

bedevere-app Bot commented Dec 4, 2023

Copy link
Copy Markdown

GH-112696 is a backport of this pull request to the 3.12 branch.

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Dec 4, 2023
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 <vstinner@python.org>
bedevere-app Bot removed the needs backport to 3.12 only security fixes label Dec 4, 2023

vstinner commented Dec 4, 2023

Copy link
Copy Markdown
Member Author

Merged, thanks for the review Serhiy.

vstinner added a commit that referenced this pull request Dec 4, 2023
…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 <vstinner@python.org>
aisk pushed a commit to aisk/cpython that referenced this pull request Feb 11, 2024
Fix sign conversion in pycore_code.h: use unsigned integers and cast
explicitly when needed.
Glyphack pushed a commit to Glyphack/cpython that referenced this pull request Sep 2, 2024
Fix sign conversion in pycore_code.h: use unsigned integers and cast
explicitly when needed.
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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants


Back | FazBrowse Home | New Git URL