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 /Modules | |
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 'Modules')
-rw-r--r-- | Modules/_ctypes/callproc.c | 2 | ||||
-rw-r--r-- | Modules/_cursesmodule.c | 4 | ||||
-rw-r--r-- | Modules/_sqlite/connection.c | 2 | ||||
-rw-r--r-- | Modules/_testcapimodule.c | 2 | ||||
-rw-r--r-- | Modules/fpectlmodule.c | 3 | ||||
-rw-r--r-- | Modules/gcmodule.c | 2 | ||||
-rw-r--r-- | Modules/getaddrinfo.c | 2 | ||||
-rw-r--r-- | Modules/main.c | 2 | ||||
-rw-r--r-- | Modules/mmapmodule.c | 2 | ||||
-rw-r--r-- | Modules/ossaudiodev.c | 8 |
10 files changed, 15 insertions, 14 deletions
diff --git a/Modules/_ctypes/callproc.c b/Modules/_ctypes/callproc.c index 3a6ad86..bdc3728 100644 --- a/Modules/_ctypes/callproc.c +++ b/Modules/_ctypes/callproc.c @@ -1336,7 +1336,7 @@ static PyObject *py_dl_open(PyObject *self, PyObject *args) handle = ctypes_dlopen(name_str, mode); Py_XDECREF(name2); if (!handle) { - char *errmsg = ctypes_dlerror(); + const char *errmsg = ctypes_dlerror(); if (!errmsg) errmsg = "dlopen() error"; PyErr_SetString(PyExc_OSError, diff --git a/Modules/_cursesmodule.c b/Modules/_cursesmodule.c index ae1905b..42f4a85 100644 --- a/Modules/_cursesmodule.c +++ b/Modules/_cursesmodule.c @@ -96,7 +96,7 @@ /* Release Number */ -char *PyCursesVersion = "2.2"; +static const char PyCursesVersion[] = "2.2"; /* Includes */ @@ -2562,7 +2562,7 @@ PyCurses_setupterm(PyObject* self, PyObject *args, PyObject* keywds) } if (!initialised_setupterm && setupterm(termstr,fd,&err) == ERR) { - char* s = "setupterm: unknown error"; + const char* s = "setupterm: unknown error"; if (err == 0) { s = "setupterm: could not find terminal"; diff --git a/Modules/_sqlite/connection.c b/Modules/_sqlite/connection.c index 57eee2d..3e83fb6 100644 --- a/Modules/_sqlite/connection.c +++ b/Modules/_sqlite/connection.c @@ -1550,7 +1550,7 @@ static PyObject * pysqlite_connection_exit(pysqlite_Connection* self, PyObject* args) { PyObject* exc_type, *exc_value, *exc_tb; - char* method_name; + const char* method_name; PyObject* result; if (!PyArg_ParseTuple(args, "OOO", &exc_type, &exc_value, &exc_tb)) { diff --git a/Modules/_testcapimodule.c b/Modules/_testcapimodule.c index 5210809..7a57719 100644 --- a/Modules/_testcapimodule.c +++ b/Modules/_testcapimodule.c @@ -2413,7 +2413,7 @@ test_with_docstring(PyObject *self) static PyObject * test_string_to_double(PyObject *self) { double result; - char *msg; + const char *msg; #define CHECK_STRING(STR, expected) \ result = PyOS_string_to_double(STR, NULL, NULL); \ diff --git a/Modules/fpectlmodule.c b/Modules/fpectlmodule.c index 404f692..42ef0f6 100644 --- a/Modules/fpectlmodule.c +++ b/Modules/fpectlmodule.c @@ -125,7 +125,8 @@ static void fpe_reset(Sigfunc *handler) extern long ieee_handler(const char*, const char*, sigfpe_handler_type); #endif - char *mode="exception", *in="all", *out; + const char *mode="exception", *in="all"; + char *out; (void) nonstandard_arithmetic(); (void) ieee_flags("clearall",mode,in,&out); (void) ieee_handler("set","common",(sigfpe_handler_type)handler); diff --git a/Modules/gcmodule.c b/Modules/gcmodule.c index 6e26c7a..121eb46 100644 --- a/Modules/gcmodule.c +++ b/Modules/gcmodule.c @@ -1608,7 +1608,7 @@ _PyGC_DumpShutdownStats(void) { if (!(_PyRuntime.gc.debug & DEBUG_SAVEALL) && _PyRuntime.gc.garbage != NULL && PyList_GET_SIZE(_PyRuntime.gc.garbage) > 0) { - char *message; + const char *message; if (_PyRuntime.gc.debug & DEBUG_UNCOLLECTABLE) message = "gc: %zd uncollectable objects at " \ "shutdown"; diff --git a/Modules/getaddrinfo.c b/Modules/getaddrinfo.c index b6fb53c..06e87bf 100644 --- a/Modules/getaddrinfo.c +++ b/Modules/getaddrinfo.c @@ -342,7 +342,7 @@ getaddrinfo(const char*hostname, const char*servname, port = htons((u_short)atoi(servname)); } else { struct servent *sp; - char *proto; + const char *proto; proto = NULL; switch (pai->ai_socktype) { diff --git a/Modules/main.c b/Modules/main.c index 846ecb6..54abbcc 100644 --- a/Modules/main.c +++ b/Modules/main.c @@ -312,7 +312,7 @@ static int run_file(FILE *fp, const wchar_t *filename, PyCompilerFlags *p_cf) { PyObject *unicode, *bytes = NULL; - char *filename_str; + const char *filename_str; int run; /* call pending calls like signal handlers (SIGINT) */ diff --git a/Modules/mmapmodule.c b/Modules/mmapmodule.c index ea7baf4..6cf4545 100644 --- a/Modules/mmapmodule.c +++ b/Modules/mmapmodule.c @@ -1210,7 +1210,7 @@ new_mmap_object(PyTypeObject *type, PyObject *args, PyObject *kwdict) DWORD off_lo; /* lower 32 bits of offset */ DWORD size_hi; /* upper 32 bits of size */ DWORD size_lo; /* lower 32 bits of size */ - char *tagname = ""; + const char *tagname = ""; DWORD dwErr = 0; int fileno; HANDLE fh = 0; diff --git a/Modules/ossaudiodev.c b/Modules/ossaudiodev.c index 8bb4d0d..58ee71f 100644 --- a/Modules/ossaudiodev.c +++ b/Modules/ossaudiodev.c @@ -53,7 +53,7 @@ typedef unsigned long uint32_t; typedef struct { PyObject_HEAD - char *devicename; /* name of the device file */ + const char *devicename; /* name of the device file */ int fd; /* file descriptor */ int mode; /* file mode (O_RDONLY, etc.) */ Py_ssize_t icount; /* input count */ @@ -82,8 +82,8 @@ newossobject(PyObject *arg) { oss_audio_t *self; int fd, afmts, imode; - char *devicename = NULL; - char *mode = NULL; + const char *devicename = NULL; + const char *mode = NULL; /* Two ways to call open(): open(device, mode) (for consistency with builtin open()) @@ -167,7 +167,7 @@ oss_dealloc(oss_audio_t *self) static oss_mixer_t * newossmixerobject(PyObject *arg) { - char *devicename = NULL; + const char *devicename = NULL; int fd; oss_mixer_t *self; |