diff options
author | Andy Lester <andy@petdance.com> | 2020-02-11 20:28:35 -0600 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-02-11 18:28:35 -0800 |
commit | e6be9b59a911626d6597fe148c32f0342bd2bd24 (patch) | |
tree | f5912158983ae1a5adcdc2131c183d09012588f8 /Objects/stringlib/find_max_char.h | |
parent | 029e8401b7741cc0964b5f38d2c2264749dbff6b (diff) | |
download | cpython-e6be9b59a911626d6597fe148c32f0342bd2bd24.tar.gz cpython-e6be9b59a911626d6597fe148c32f0342bd2bd24.zip |
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 'Objects/stringlib/find_max_char.h')
-rw-r--r-- | Objects/stringlib/find_max_char.h | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/Objects/stringlib/find_max_char.h b/Objects/stringlib/find_max_char.h index 8ccbc309446..f4e0a7761d3 100644 --- a/Objects/stringlib/find_max_char.h +++ b/Objects/stringlib/find_max_char.h @@ -28,7 +28,7 @@ STRINGLIB(find_max_char)(const STRINGLIB_CHAR *begin, const STRINGLIB_CHAR *end) /* Help register allocation */ const unsigned char *_p = p; while (_p < aligned_end) { - unsigned long value = *(unsigned long *) _p; + unsigned long value = *(const unsigned long *) _p; if (value & UCS1_ASCII_CHAR_MASK) return 255; _p += SIZEOF_LONG; |