summaryrefslogtreecommitdiffstats
path: root/Objects/bytes_methods.c
diff options
context:
space:
mode:
authorAndy Lester <andy@petdance.com>2020-02-12 02:28:35 (GMT)
committerGitHub <noreply@github.com>2020-02-12 02:28:35 (GMT)
commite6be9b59a911626d6597fe148c32f0342bd2bd24 (patch)
treef5912158983ae1a5adcdc2131c183d09012588f8 /Objects/bytes_methods.c
parent029e8401b7741cc0964b5f38d2c2264749dbff6b (diff)
downloadcpython-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 'Objects/bytes_methods.c')
-rw-r--r--Objects/bytes_methods.c16
1 files changed, 8 insertions, 8 deletions
diff --git a/Objects/bytes_methods.c b/Objects/bytes_methods.c
index 7d13184..db030be 100644
--- a/Objects/bytes_methods.c
+++ b/Objects/bytes_methods.c
@@ -12,7 +12,7 @@ PyObject*
_Py_bytes_isspace(const char *cptr, Py_ssize_t len)
{
const unsigned char *p
- = (unsigned char *) cptr;
+ = (const unsigned char *) cptr;
const unsigned char *e;
/* Shortcut for single character strings */
@@ -42,7 +42,7 @@ PyObject*
_Py_bytes_isalpha(const char *cptr, Py_ssize_t len)
{
const unsigned char *p
- = (unsigned char *) cptr;
+ = (const unsigned char *) cptr;
const unsigned char *e;
/* Shortcut for single character strings */
@@ -72,7 +72,7 @@ PyObject*
_Py_bytes_isalnum(const char *cptr, Py_ssize_t len)
{
const unsigned char *p
- = (unsigned char *) cptr;
+ = (const unsigned char *) cptr;
const unsigned char *e;
/* Shortcut for single character strings */
@@ -123,7 +123,7 @@ _Py_bytes_isascii(const char *cptr, Py_ssize_t len)
/* Help allocation */
const char *_p = p;
while (_p < aligned_end) {
- unsigned long value = *(unsigned long *) _p;
+ unsigned long value = *(const unsigned long *) _p;
if (value & ASCII_CHAR_MASK) {
Py_RETURN_FALSE;
}
@@ -154,7 +154,7 @@ PyObject*
_Py_bytes_isdigit(const char *cptr, Py_ssize_t len)
{
const unsigned char *p
- = (unsigned char *) cptr;
+ = (const unsigned char *) cptr;
const unsigned char *e;
/* Shortcut for single character strings */
@@ -184,7 +184,7 @@ PyObject*
_Py_bytes_islower(const char *cptr, Py_ssize_t len)
{
const unsigned char *p
- = (unsigned char *) cptr;
+ = (const unsigned char *) cptr;
const unsigned char *e;
int cased;
@@ -218,7 +218,7 @@ PyObject*
_Py_bytes_isupper(const char *cptr, Py_ssize_t len)
{
const unsigned char *p
- = (unsigned char *) cptr;
+ = (const unsigned char *) cptr;
const unsigned char *e;
int cased;
@@ -254,7 +254,7 @@ PyObject*
_Py_bytes_istitle(const char *cptr, Py_ssize_t len)
{
const unsigned char *p
- = (unsigned char *) cptr;
+ = (const unsigned char *) cptr;
const unsigned char *e;
int cased, previous_is_cased;