Add the const qualifier to "char *" variables that refer to literal strings. (#4370)

This commit is contained in:
Serhiy Storchaka 2017-11-11 13:06:26 +02:00 committed by GitHub
parent e184cfd7bf
commit e2f92de6a9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
23 changed files with 46 additions and 41 deletions

View file

@ -1942,7 +1942,7 @@ builtin_input_impl(PyObject *module, PyObject *prompt)
/* If we're interactive, use (GNU) readline */
if (tty) {
PyObject *po = NULL;
char *promptstr;
const char *promptstr;
char *s = NULL;
PyObject *stdin_encoding = NULL, *stdin_errors = NULL;
PyObject *stdout_encoding = NULL, *stdout_errors = NULL;

View file

@ -4846,7 +4846,7 @@ compiler_visit_nested_slice(struct compiler *c, slice_ty s,
static int
compiler_visit_slice(struct compiler *c, slice_ty s, expr_context_ty ctx)
{
char * kindname = NULL;
const char * kindname = NULL;
switch (s->kind) {
case Index_kind:
kindname = "index";

View file

@ -196,7 +196,7 @@ _PyHash_Fini(void)
#ifdef Py_HASH_STATS
int i;
Py_ssize_t total = 0;
char *fmt = "%2i %8" PY_FORMAT_SIZE_T "d %8" PY_FORMAT_SIZE_T "d\n";
const char *fmt = "%2i %8" PY_FORMAT_SIZE_T "d %8" PY_FORMAT_SIZE_T "d\n";
fprintf(stderr, "len calls total\n");
for (i = 1; i <= Py_HASH_STATS_MAX; i++) {

View file

@ -597,7 +597,8 @@ Py_LOCAL_INLINE(char *)
ensure_decimal_point(char* buffer, size_t buf_size, int precision)
{
int digit_count, insert_count = 0, convert_to_exp = 0;
char *chars_to_insert, *digits_start;
const char *chars_to_insert;
char *digits_start;
/* search for the first non-digit character */
char *p = buffer;

View file

@ -1300,7 +1300,7 @@ err_input(perrdetail *err)
{
PyObject *v, *w, *errtype, *errtext;
PyObject *msg_obj = NULL;
char *msg = NULL;
const char *msg = NULL;
int offset = err->offset;
errtype = PyExc_SyntaxError;