diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2017-11-11 11:06:26 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-11-11 11:06:26 (GMT) |
commit | e2f92de6a90ae11a6d8e01bd17fd88b005516835 (patch) | |
tree | a5bc255a98f488e5ecf195dc3f55665e9afecc47 /Objects | |
parent | e184cfd7bf8bcfd160e3b611d4351ca3ce52d9e2 (diff) | |
download | cpython-e2f92de6a90ae11a6d8e01bd17fd88b005516835.zip cpython-e2f92de6a90ae11a6d8e01bd17fd88b005516835.tar.gz cpython-e2f92de6a90ae11a6d8e01bd17fd88b005516835.tar.bz2 |
Add the const qualifier to "char *" variables that refer to literal strings. (#4370)
Diffstat (limited to 'Objects')
-rw-r--r-- | Objects/bytearrayobject.c | 15 | ||||
-rw-r--r-- | Objects/classobject.c | 2 | ||||
-rw-r--r-- | Objects/complexobject.c | 6 | ||||
-rw-r--r-- | Objects/genobject.c | 8 | ||||
-rw-r--r-- | Objects/obmalloc.c | 4 | ||||
-rw-r--r-- | Objects/odictobject.c | 4 | ||||
-rw-r--r-- | Objects/unicodeobject.c | 6 |
7 files changed, 24 insertions, 21 deletions
diff --git a/Objects/bytearrayobject.c b/Objects/bytearrayobject.c index 83c3549..dc1515a 100644 --- a/Objects/bytearrayobject.c +++ b/Objects/bytearrayobject.c @@ -1806,7 +1806,8 @@ bytearray_strip_impl(PyByteArrayObject *self, PyObject *bytes) /*[clinic end generated code: output=760412661a34ad5a input=ef7bb59b09c21d62]*/ { Py_ssize_t left, right, mysize, byteslen; - char *myptr, *bytesptr; + char *myptr; + const char *bytesptr; Py_buffer vbytes; if (bytes == Py_None) { @@ -1816,7 +1817,7 @@ bytearray_strip_impl(PyByteArrayObject *self, PyObject *bytes) else { if (PyObject_GetBuffer(bytes, &vbytes, PyBUF_SIMPLE) != 0) return NULL; - bytesptr = (char *) vbytes.buf; + bytesptr = (const char *) vbytes.buf; byteslen = vbytes.len; } myptr = PyByteArray_AS_STRING(self); @@ -1847,7 +1848,8 @@ bytearray_lstrip_impl(PyByteArrayObject *self, PyObject *bytes) /*[clinic end generated code: output=d005c9d0ab909e66 input=80843f975dd7c480]*/ { Py_ssize_t left, right, mysize, byteslen; - char *myptr, *bytesptr; + char *myptr; + const char *bytesptr; Py_buffer vbytes; if (bytes == Py_None) { @@ -1857,7 +1859,7 @@ bytearray_lstrip_impl(PyByteArrayObject *self, PyObject *bytes) else { if (PyObject_GetBuffer(bytes, &vbytes, PyBUF_SIMPLE) != 0) return NULL; - bytesptr = (char *) vbytes.buf; + bytesptr = (const char *) vbytes.buf; byteslen = vbytes.len; } myptr = PyByteArray_AS_STRING(self); @@ -1885,7 +1887,8 @@ bytearray_rstrip_impl(PyByteArrayObject *self, PyObject *bytes) /*[clinic end generated code: output=030e2fbd2f7276bd input=e728b994954cfd91]*/ { Py_ssize_t right, mysize, byteslen; - char *myptr, *bytesptr; + char *myptr; + const char *bytesptr; Py_buffer vbytes; if (bytes == Py_None) { @@ -1895,7 +1898,7 @@ bytearray_rstrip_impl(PyByteArrayObject *self, PyObject *bytes) else { if (PyObject_GetBuffer(bytes, &vbytes, PyBUF_SIMPLE) != 0) return NULL; - bytesptr = (char *) vbytes.buf; + bytesptr = (const char *) vbytes.buf; byteslen = vbytes.len; } myptr = PyByteArray_AS_STRING(self); diff --git a/Objects/classobject.c b/Objects/classobject.c index 063c24a..e88c95c 100644 --- a/Objects/classobject.c +++ b/Objects/classobject.c @@ -543,7 +543,7 @@ instancemethod_repr(PyObject *self) { PyObject *func = PyInstanceMethod_Function(self); PyObject *funcname = NULL , *result = NULL; - char *defname = "?"; + const char *defname = "?"; if (func == NULL) { PyErr_BadInternalCall(); diff --git a/Objects/complexobject.c b/Objects/complexobject.c index 3bf37ee..4bcf2ce 100644 --- a/Objects/complexobject.c +++ b/Objects/complexobject.c @@ -363,9 +363,9 @@ complex_repr(PyComplexObject *v) /* These do not need to be freed. re is either an alias for pre or a pointer to a constant. lead and tail are pointers to constants. */ - char *re = NULL; - char *lead = ""; - char *tail = ""; + const char *re = NULL; + const char *lead = ""; + const char *tail = ""; if (v->cval.real == 0. && copysign(1.0, v->cval.real)==1.0) { /* Real part is +0: just output the imaginary part and do not diff --git a/Objects/genobject.c b/Objects/genobject.c index 7793a54..00a8823 100644 --- a/Objects/genobject.c +++ b/Objects/genobject.c @@ -152,7 +152,7 @@ gen_send_ex(PyGenObject *gen, PyObject *arg, int exc, int closing) PyObject *result; if (gen->gi_running) { - char *msg = "generator already executing"; + const char *msg = "generator already executing"; if (PyCoro_CheckExact(gen)) { msg = "coroutine already executing"; } @@ -186,8 +186,8 @@ gen_send_ex(PyGenObject *gen, PyObject *arg, int exc, int closing) if (f->f_lasti == -1) { if (arg && arg != Py_None) { - char *msg = "can't send non-None value to a " - "just-started generator"; + const char *msg = "can't send non-None value to a " + "just-started generator"; if (PyCoro_CheckExact(gen)) { msg = NON_INIT_CORO_MSG; } @@ -410,7 +410,7 @@ gen_close(PyGenObject *gen, PyObject *args) PyErr_SetNone(PyExc_GeneratorExit); retval = gen_send_ex(gen, Py_None, 1, 1); if (retval) { - char *msg = "generator ignored GeneratorExit"; + const char *msg = "generator ignored GeneratorExit"; if (PyCoro_CheckExact(gen)) { msg = "coroutine ignored GeneratorExit"; } else if (PyAsyncGen_CheckExact(gen)) { diff --git a/Objects/obmalloc.c b/Objects/obmalloc.c index 7f5306f..4441c82 100644 --- a/Objects/obmalloc.c +++ b/Objects/obmalloc.c @@ -1646,7 +1646,7 @@ _PyMem_DebugCheckAddress(char api, const void *p) { const uint8_t *q = (const uint8_t *)p; char msgbuf[64]; - char *msg; + const char *msg; size_t nbytes; const uint8_t *tail; int i; @@ -1661,7 +1661,7 @@ _PyMem_DebugCheckAddress(char api, const void *p) id = (char)q[-SST]; if (id != api) { msg = msgbuf; - snprintf(msg, sizeof(msgbuf), "bad ID: Allocated using API '%c', verified using API '%c'", id, api); + snprintf(msgbuf, sizeof(msgbuf), "bad ID: Allocated using API '%c', verified using API '%c'", id, api); msgbuf[sizeof(msgbuf)-1] = 0; goto error; } diff --git a/Objects/odictobject.c b/Objects/odictobject.c index afacb36..5d22ce7 100644 --- a/Objects/odictobject.c +++ b/Objects/odictobject.c @@ -1625,7 +1625,7 @@ odict_init(PyObject *self, PyObject *args, PyObject *kwds) if (len == -1) return -1; if (len > 1) { - char *msg = "expected at most 1 arguments, got %d"; + const char *msg = "expected at most 1 arguments, got %d"; PyErr_Format(PyExc_TypeError, msg, len); return -1; } @@ -2337,7 +2337,7 @@ mutablemapping_update(PyObject *self, PyObject *args, PyObject *kwargs) assert(args == NULL || PyTuple_Check(args)); len = (args != NULL) ? PyTuple_GET_SIZE(args) : 0; if (len > 1) { - char *msg = "update() takes at most 1 positional argument (%d given)"; + const char *msg = "update() takes at most 1 positional argument (%d given)"; PyErr_Format(PyExc_TypeError, msg, len); return NULL; } diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c index 194c5bc..fdc3197 100644 --- a/Objects/unicodeobject.c +++ b/Objects/unicodeobject.c @@ -8396,8 +8396,8 @@ charmap_encoding_error( Py_ssize_t collstartpos = *inpos; Py_ssize_t collendpos = *inpos+1; Py_ssize_t collpos; - char *encoding = "charmap"; - char *reason = "character maps to <undefined>"; + const char *encoding = "charmap"; + const char *reason = "character maps to <undefined>"; charmapencode_result x; Py_UCS4 ch; int val; @@ -8928,7 +8928,7 @@ _PyUnicode_TranslateCharmap(PyObject *input, /* output buffer */ _PyUnicodeWriter writer; /* error handler */ - char *reason = "character maps to <undefined>"; + const char *reason = "character maps to <undefined>"; PyObject *errorHandler = NULL; PyObject *exc = NULL; int ignore; |