Skip to content

bpo-39943: Keep constness of pointers. #19210

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

Closed
wants to merge 1 commit into from
Closed

bpo-39943: Keep constness of pointers. #19210

wants to merge 1 commit into from

Conversation

petdance
Copy link
Contributor

@petdance petdance commented Mar 28, 2020

Make two pointers be const char *.  This quiets a warning from
-Wincompatible-pointer-types.

https://bugs.python.org/issue39943

Make two pointers be const char *.  This quiets a warning from
-Wincompatible-pointer-types.
@serhiy-storchaka
Copy link
Member

You can add const to WFILE.end, RFILE.ptr and RFILE.end.

@petdance
Copy link
Contributor Author

You can add const to WFILE.end, RFILE.ptr and RFILE.end.

I'm glad to do that. I was trying to keep changes minimal, but I'll resubmit.

Copy link
Member

@serhiy-storchaka serhiy-storchaka left a comment

Choose a reason for hiding this comment

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

I have done more cleanup in #19236.

@@ -1598,7 +1598,7 @@ PyMarshal_WriteObjectToString(PyObject *x, int version)
w_object(x, &wf);
w_clear_refs(&wf);
if (wf.str != NULL) {
char *base = PyBytes_AS_STRING((PyBytesObject *)wf.str);
const char *base = PyBytes_AS_STRING((PyBytesObject *)wf.str);
if (wf.ptr - base > PY_SSIZE_T_MAX) {
Copy link
Member

Choose a reason for hiding this comment

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

It seems to me, that this condition is always false (see w_reserve()). So you can remove it.

@@ -1598,7 +1598,7 @@ PyMarshal_WriteObjectToString(PyObject *x, int version)
w_object(x, &wf);
w_clear_refs(&wf);
if (wf.str != NULL) {
char *base = PyBytes_AS_STRING((PyBytesObject *)wf.str);
Copy link
Member

Choose a reason for hiding this comment

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

AFAIK the cast to PyBytesObject * is not needed.

@petdance petdance deleted the cast-Python-marshal branch April 3, 2020 03:03
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.

4 participants