-
-
Notifications
You must be signed in to change notification settings - Fork 32.2k
bpo-39605: Fix some casts to not cast away const #18453
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
Codecov Report
@@ Coverage Diff @@
## master #18453 +/- ##
==========================================
- Coverage 82.20% 82.11% -0.09%
==========================================
Files 1957 1954 -3
Lines 589324 583606 -5718
Branches 44428 44428
==========================================
- Hits 484430 479255 -5175
+ Misses 95233 94705 -528
+ Partials 9661 9646 -15
Continue to review full report at Codecov.
|
|
Thanks @petdance for the PR, and @benjaminp for merging it 🌮🎉.. I'm working now to backport this PR to: 3.8. |
|
GH-18471 is a backport of this pull request to the 3.8 branch. |
gcc -Wcast-qual turns up a number of instances of casting away constness of pointers. Some of these can be safely modified, by either: Adding the const to the type cast, as in: - return _PyUnicode_FromUCS1((unsigned char*)s, size); + return _PyUnicode_FromUCS1((const unsigned char*)s, size); or, Removing the cast entirely, because it's not necessary (but probably was at one time), as in: - PyDTrace_FUNCTION_ENTRY((char *)filename, (char *)funcname, lineno); + PyDTrace_FUNCTION_ENTRY(filename, funcname, lineno); These changes will not change code, but they will make it much easier to check for errors in consts (cherry picked from commit e6be9b5) Co-authored-by: Andy Lester <andy@petdance.com>
gcc -Wcast-qualturns up a number of instances of casting away constness of pointers. Some of these can be safely modified, by either:Adding the
constto the type cast, as in:or, Removing the cast entirely, because it's not necessary (but probably was at one time), as in:
These changes will not change code, but they will make it much easier to check for errors in consts.
https://bugs.python.org/issue39605