bpo-32241: Add the const qualifire to declarations of umodifiable strings. (#4748)

This commit is contained in:
Serhiy Storchaka 2017-12-12 13:55:04 +02:00 committed by GitHub
parent 5ce0a2a100
commit 4ae06c5337
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
15 changed files with 59 additions and 56 deletions

View file

@ -533,16 +533,16 @@ _PyOS_URandomNonblock(void *buffer, Py_ssize_t size)
return pyurandom(buffer, size, 0, 1);
}
int Py_ReadHashSeed(char *seed_text,
int Py_ReadHashSeed(const char *seed_text,
int *use_hash_seed,
unsigned long *hash_seed)
{
Py_BUILD_ASSERT(sizeof(_Py_HashSecret_t) == sizeof(_Py_HashSecret.uc));
/* Convert a text seed to a numeric one */
if (seed_text && *seed_text != '\0' && strcmp(seed_text, "random") != 0) {
char *endptr = seed_text;
const char *endptr = seed_text;
unsigned long seed;
seed = strtoul(seed_text, &endptr, 10);
seed = strtoul(seed_text, (char **)&endptr, 10);
if (*endptr != '\0'
|| seed > 4294967295UL
|| (errno == ERANGE && seed == ULONG_MAX))
@ -604,7 +604,7 @@ init_hash_secret(int use_hash_seed,
_PyInitError
_Py_HashRandomization_Init(_PyCoreConfig *core_config)
{
char *seed_text;
const char *seed_text;
int use_hash_seed = core_config->use_hash_seed;
unsigned long hash_seed = core_config->hash_seed;

View file

@ -120,7 +120,7 @@ static int GetRunningOnValgrind(void) {
#endif
#ifndef _MSC_VER
char *running_on_valgrind_str = getenv("RUNNING_ON_VALGRIND");
const char *running_on_valgrind_str = getenv("RUNNING_ON_VALGRIND");
if (running_on_valgrind_str) {
return strcmp(running_on_valgrind_str, "0") != 0;
}

View file

@ -23,7 +23,7 @@ Py_FrozenMain(int argc, char **argv)
exit(1);
}
char *p;
const char *p;
int i, n, sts = 1;
int inspect = 0;
int unbuffered = 0;

View file

@ -168,7 +168,7 @@ Py_SetPath(const wchar_t *path)
void
Py_SetPythonHome(wchar_t *home)
Py_SetPythonHome(const wchar_t *home)
{
if (home == NULL) {
return;
@ -189,7 +189,7 @@ Py_SetPythonHome(wchar_t *home)
void
Py_SetProgramName(wchar_t *program_name)
Py_SetProgramName(const wchar_t *program_name)
{
if (program_name == NULL || program_name[0] == L'\0') {
return;

View file

@ -414,7 +414,7 @@ static _LocaleCoercionTarget _TARGET_LOCALES[] = {
{NULL}
};
static char *
static const char *
get_default_standard_stream_error_handler(void)
{
const char *ctype_loc = setlocale(LC_CTYPE, NULL);
@ -440,7 +440,7 @@ get_default_standard_stream_error_handler(void)
}
#ifdef PY_COERCE_C_LOCALE
static const char *_C_LOCALE_COERCION_WARNING =
static const char _C_LOCALE_COERCION_WARNING[] =
"Python detected LC_CTYPE=C: LC_CTYPE coerced to %.20s (set another locale "
"or PYTHONCOERCECLOCALE=0 to disable this locale coercion behavior).\n";
@ -1757,7 +1757,8 @@ init_sys_streams(void)
PyObject *std = NULL;
int fd;
PyObject * encoding_attr;
char *pythonioencoding = NULL, *encoding, *errors;
char *pythonioencoding = NULL;
const char *encoding, *errors;
_PyInitError res = _Py_INIT_OK();
/* Hack to avoid a nasty recursion issue when Python is invoked

View file

@ -100,7 +100,7 @@ static PyObject *
sys_breakpointhook(PyObject *self, PyObject **args, Py_ssize_t nargs, PyObject *keywords)
{
assert(!PyErr_Occurred());
char *envar = Py_GETENV("PYTHONBREAKPOINT");
const char *envar = Py_GETENV("PYTHONBREAKPOINT");
if (envar == NULL || strlen(envar) == 0) {
envar = "pdb.set_trace";
@ -109,8 +109,8 @@ sys_breakpointhook(PyObject *self, PyObject **args, Py_ssize_t nargs, PyObject *
/* The breakpoint is explicitly no-op'd. */
Py_RETURN_NONE;
}
char *last_dot = strrchr(envar, '.');
char *attrname = NULL;
const char *last_dot = strrchr(envar, '.');
const char *attrname = NULL;
PyObject *modulepath = NULL;
if (last_dot == NULL) {

View file

@ -61,7 +61,7 @@ void
PyThread_init_thread(void)
{
#ifdef Py_DEBUG
char *p = Py_GETENV("PYTHONTHREADDEBUG");
const char *p = Py_GETENV("PYTHONTHREADDEBUG");
if (p) {
if (*p)