diff options
author | Andy Lester <andy@petdance.com> | 2020-02-12 02:28:35 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-02-12 02:28:35 (GMT) |
commit | e6be9b59a911626d6597fe148c32f0342bd2bd24 (patch) | |
tree | f5912158983ae1a5adcdc2131c183d09012588f8 /Modules/_io | |
parent | 029e8401b7741cc0964b5f38d2c2264749dbff6b (diff) | |
download | cpython-e6be9b59a911626d6597fe148c32f0342bd2bd24.zip cpython-e6be9b59a911626d6597fe148c32f0342bd2bd24.tar.gz cpython-e6be9b59a911626d6597fe148c32f0342bd2bd24.tar.bz2 |
closes bpo-39605: Fix some casts to not cast away const. (GH-18453)
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
Diffstat (limited to 'Modules/_io')
-rw-r--r-- | Modules/_io/textio.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/Modules/_io/textio.c b/Modules/_io/textio.c index 1d45c7a..3a9ce93 100644 --- a/Modules/_io/textio.c +++ b/Modules/_io/textio.c @@ -2025,7 +2025,7 @@ find_control_char(int kind, const char *s, const char *end, Py_UCS4 ch) { if (kind == PyUnicode_1BYTE_KIND) { assert(ch < 256); - return (char *) memchr((void *) s, (char) ch, end - s); + return (char *) memchr((const void *) s, (char) ch, end - s); } for (;;) { while (PyUnicode_READ(kind, s, 0) > ch) @@ -2043,7 +2043,7 @@ _PyIO_find_line_ending( int translated, int universal, PyObject *readnl, int kind, const char *start, const char *end, Py_ssize_t *consumed) { - Py_ssize_t len = ((char*)end - (char*)start)/kind; + Py_ssize_t len = (end - start)/kind; if (translated) { /* Newlines are already translated, only search for \n */ |