mirror of
https://github.com/python/cpython.git
synced 2025-11-25 21:11:09 +00:00
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
This commit is contained in:
parent
029e8401b7
commit
e6be9b59a9
11 changed files with 39 additions and 39 deletions
|
|
@ -1682,8 +1682,8 @@ unpack_single(const char *ptr, const char *fmt)
|
|||
switch (fmt[0]) {
|
||||
|
||||
/* signed integers and fast path for 'B' */
|
||||
case 'B': uc = *((unsigned char *)ptr); goto convert_uc;
|
||||
case 'b': ld = *((signed char *)ptr); goto convert_ld;
|
||||
case 'B': uc = *((const unsigned char *)ptr); goto convert_uc;
|
||||
case 'b': ld = *((const signed char *)ptr); goto convert_ld;
|
||||
case 'h': UNPACK_SINGLE(ld, ptr, short); goto convert_ld;
|
||||
case 'i': UNPACK_SINGLE(ld, ptr, int); goto convert_ld;
|
||||
case 'l': UNPACK_SINGLE(ld, ptr, long); goto convert_ld;
|
||||
|
|
@ -2684,8 +2684,8 @@ unpack_cmp(const char *p, const char *q, char fmt,
|
|||
switch (fmt) {
|
||||
|
||||
/* signed integers and fast path for 'B' */
|
||||
case 'B': return *((unsigned char *)p) == *((unsigned char *)q);
|
||||
case 'b': return *((signed char *)p) == *((signed char *)q);
|
||||
case 'B': return *((const unsigned char *)p) == *((const unsigned char *)q);
|
||||
case 'b': return *((const signed char *)p) == *((const signed char *)q);
|
||||
case 'h': CMP_SINGLE(p, q, short); return equal;
|
||||
case 'i': CMP_SINGLE(p, q, int); return equal;
|
||||
case 'l': CMP_SINGLE(p, q, long); return equal;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue