diff --git a/Zend/zend_enum.c b/Zend/zend_enum.c index 85783fb56c7..99c828f9745 100644 --- a/Zend/zend_enum.c +++ b/Zend/zend_enum.c @@ -85,7 +85,7 @@ static void zend_verify_enum_magic_methods(zend_class_entry *ce) ZEND_ENUM_DISALLOW_MAGIC_METHOD(__serialize, "__serialize"); ZEND_ENUM_DISALLOW_MAGIC_METHOD(__unserialize, "__unserialize"); - const char *forbidden_methods[] = { + static const char *const forbidden_methods[] = { "__sleep", "__wakeup", "__set_state", diff --git a/ext/bcmath/libbcmath/src/output.c b/ext/bcmath/libbcmath/src/output.c index 79a386eda79..fb7976cc67f 100644 --- a/ext/bcmath/libbcmath/src/output.c +++ b/ext/bcmath/libbcmath/src/output.c @@ -48,7 +48,7 @@ typedef struct stk_rec { } stk_rec; /* The reference string for digits. */ -static char ref_str[] = "0123456789ABCDEF"; +static const char ref_str[] = "0123456789ABCDEF"; /* A special output routine for "multi-character digits." Exactly diff --git a/ext/ffi/ffi.c b/ext/ffi/ffi.c index f22c44e80c4..0c236f2b71d 100644 --- a/ext/ffi/ffi.c +++ b/ext/ffi/ffi.c @@ -5538,7 +5538,7 @@ static const zend_ffi_type zend_ffi_type_long_double = {.kind=ZEND_FFI_TYPE_LONG static const zend_ffi_type zend_ffi_type_ptr = {.kind=ZEND_FFI_TYPE_POINTER, .size=sizeof(void*), .align=_Alignof(void*), .pointer.type = (zend_ffi_type*)&zend_ffi_type_void}; -const struct { +static const struct { const char *name; const zend_ffi_type *type; } zend_ffi_types[] = { diff --git a/ext/phar/phar.c b/ext/phar/phar.c index 3c0f3eb50b7..8fc921ac6d2 100644 --- a/ext/phar/phar.c +++ b/ext/phar/phar.c @@ -1622,10 +1622,10 @@ static inline char *phar_strnstr(const char *buf, int buf_len, const char *searc */ static int phar_open_from_fp(php_stream* fp, char *fname, size_t fname_len, char *alias, size_t alias_len, uint32_t options, phar_archive_data** pphar, int is_data, char **error) /* {{{ */ { - const char token[] = "__HALT_COMPILER();"; - const char zip_magic[] = "PK\x03\x04"; - const char gz_magic[] = "\x1f\x8b\x08"; - const char bz_magic[] = "BZh"; + static const char token[] = "__HALT_COMPILER();"; + static const char zip_magic[] = "PK\x03\x04"; + static const char gz_magic[] = "\x1f\x8b\x08"; + static const char bz_magic[] = "BZh"; char *pos, test = '\0'; int recursion_count = 3; // arbitrary limit to avoid too deep or even infinite recursion const int window_size = 1024; diff --git a/ext/phar/phar_object.c b/ext/phar/phar_object.c index 0737c0db9f3..ba47cd88439 100644 --- a/ext/phar/phar_object.c +++ b/ext/phar/phar_object.c @@ -1975,7 +1975,7 @@ static zend_object *phar_rename_archive(phar_archive_data **sphar, char *ext) /* char *ext_pos = NULL; /* Array of PHAR extensions, Must be in order, starting with longest * ending with the shortest. */ - char *phar_ext_list[] = { + static const char *const phar_ext_list[] = { ".phar.tar.bz2", ".phar.tar.gz", ".phar.php", diff --git a/main/php_syslog.c b/main/php_syslog.c index fa71a863134..975a0423df1 100644 --- a/main/php_syslog.c +++ b/main/php_syslog.c @@ -58,7 +58,7 @@ PHPAPI void php_syslog_str(int priority, const zend_string* message) } else if ((c < 0x20) && (PG(syslog_filter) == PHP_SYSLOG_FILTER_ALL)) { smart_string_appendc(&sbuf, c); } else { - const char xdigits[] = "0123456789abcdef"; + static const char xdigits[] = "0123456789abcdef"; smart_string_appendl(&sbuf, "\\x", 2); smart_string_appendc(&sbuf, xdigits[c >> 4]); diff --git a/sapi/cli/php_cli_server.c b/sapi/cli/php_cli_server.c index 901281ddfdf..4d218000d0d 100644 --- a/sapi/cli/php_cli_server.c +++ b/sapi/cli/php_cli_server.c @@ -208,7 +208,7 @@ typedef struct php_cli_server_http_response_status_code_pair { const char *str; } php_cli_server_http_response_status_code_pair; -static php_cli_server_http_response_status_code_pair template_map[] = { +static const php_cli_server_http_response_status_code_pair template_map[] = { { 400, "

%s

Your browser sent a request that this server could not understand.

" }, { 404, "

%s

The requested resource %s was not found on this server.

" }, { 405, "

%s

Requested method not allowed.

" }, diff --git a/sapi/fpm/fpm/fpm_conf.c b/sapi/fpm/fpm/fpm_conf.c index 124c12b4068..5684a46190e 100644 --- a/sapi/fpm/fpm/fpm_conf.c +++ b/sapi/fpm/fpm/fpm_conf.c @@ -84,7 +84,7 @@ static char *ini_include = NULL; /* * Please keep the same order as in fpm_conf.h and in php-fpm.conf.in */ -static struct ini_value_parser_s ini_fpm_global_options[] = { +static const struct ini_value_parser_s ini_fpm_global_options[] = { { "pid", &fpm_conf_set_string, GO(pid_file) }, { "error_log", &fpm_conf_set_string, GO(error_log) }, #ifdef HAVE_SYSLOG_H @@ -112,7 +112,7 @@ static struct ini_value_parser_s ini_fpm_global_options[] = { /* * Please keep the same order as in fpm_conf.h and in php-fpm.conf.in */ -static struct ini_value_parser_s ini_fpm_pool_options[] = { +static const struct ini_value_parser_s ini_fpm_pool_options[] = { { "prefix", &fpm_conf_set_string, WPO(prefix) }, { "user", &fpm_conf_set_string, WPO(user) }, { "group", &fpm_conf_set_string, WPO(group) }, @@ -1183,11 +1183,10 @@ static int fpm_conf_process_all_pools(void) /* env[], php_value[], php_admin_values[] */ if (!wp->config->chroot) { struct key_value_s *kv; - char *options[] = FPM_PHP_INI_TO_EXPAND; - char **p; + static const char *const options[] = FPM_PHP_INI_TO_EXPAND; for (kv = wp->config->php_values; kv; kv = kv->next) { - for (p = options; *p; p++) { + for (const char *const*p = options; *p; p++) { if (!strcasecmp(kv->key, *p)) { fpm_evaluate_full_path(&kv->value, wp, NULL, 0); } @@ -1197,7 +1196,7 @@ static int fpm_conf_process_all_pools(void) if (!strcasecmp(kv->key, "error_log") && !strcasecmp(kv->value, "syslog")) { continue; } - for (p = options; *p; p++) { + for (const char *const*p = options; *p; p++) { if (!strcasecmp(kv->key, *p)) { fpm_evaluate_full_path(&kv->value, wp, NULL, 0); } @@ -1464,7 +1463,7 @@ static void fpm_conf_ini_parser_section(zval *section, void *arg) /* {{{ */ static void fpm_conf_ini_parser_entry(zval *name, zval *value, void *arg) /* {{{ */ { - struct ini_value_parser_s *parser; + const struct ini_value_parser_s *parser; void *config = NULL; int *error = (int *)arg; diff --git a/sapi/fpm/fpm/fpm_signals.c b/sapi/fpm/fpm/fpm_signals.c index 6aad4403768..aca7c9ed58c 100644 --- a/sapi/fpm/fpm/fpm_signals.c +++ b/sapi/fpm/fpm/fpm_signals.c @@ -267,7 +267,7 @@ int fpm_signals_init_mask(void) /* Subset of signals from fpm_signals_init_main() and fpm_got_signal() blocked to avoid unexpected death during early init or during reload just after execvp() or fork */ - int init_signal_array[] = { SIGUSR1, SIGUSR2, SIGCHLD }; + static const int init_signal_array[] = { SIGUSR1, SIGUSR2, SIGCHLD }; size_t size = sizeof(init_signal_array)/sizeof(init_signal_array[0]); size_t i = 0; if (0 > sigemptyset(&block_sigset) || diff --git a/sapi/phpdbg/phpdbg.c b/sapi/phpdbg/phpdbg.c index 5af72138ce2..fb2a7978dda 100644 --- a/sapi/phpdbg/phpdbg.c +++ b/sapi/phpdbg/phpdbg.c @@ -963,7 +963,7 @@ static sapi_module_struct phpdbg_sapi_module = { }; /* }}} */ -const opt_struct OPTIONS[] = { /* {{{ */ +static const opt_struct OPTIONS[] = { /* {{{ */ {'c', 1, "ini path override"}, {'d', 1, "define ini entry on command line"}, {'n', 0, "no php.ini"}, diff --git a/sapi/phpdbg/phpdbg_help.c b/sapi/phpdbg/phpdbg_help.c index b162c4b39fe..f1f9bf4fab1 100644 --- a/sapi/phpdbg/phpdbg_help.c +++ b/sapi/phpdbg/phpdbg_help.c @@ -38,9 +38,9 @@ const phpdbg_command_t phpdbg_help_commands[] = { }; /* }}} */ /* {{{ pretty_print. Formatting escapes and wrapping text in a string before printing it. */ -void pretty_print(char *text) +static void pretty_print(const char *text) { - char *new, *p, *q; + char *new, *q; const char *prompt_escape = phpdbg_get_prompt(); size_t prompt_escape_len = strlen(prompt_escape); @@ -60,6 +60,7 @@ void pretty_print(char *text) uint32_t line_count = 0; /* number printable chars on current line */ /* First pass calculates a safe size for the pretty print version */ + const char *p; for (p = text; *p; p++) { if (UNEXPECTED(p[0] == '*') && p[1] == '*') { size += bold_escape_len - 2; @@ -143,9 +144,9 @@ void summary_print(phpdbg_command_t const * const cmd) } /* {{{ get_help. Retries and formats text from the phpdbg help text table */ -static char *get_help(const char * const key) +static const char *get_help(const char * const key) { - phpdbg_help_text_t *p; + const phpdbg_help_text_t *p; /* Note that phpdbg_help_text is not assumed to be collated in key order. This is an inconvenience that means that help can't be logically grouped Not worth @@ -201,8 +202,8 @@ static int get_command( } /* }}} */ -void phpdbg_do_help_cmd(char *type) { /* {{{ */ - char *help; +void phpdbg_do_help_cmd(const char *type) { /* {{{ */ + const char *help; if (!type) { pretty_print(get_help("overview!")); @@ -329,7 +330,7 @@ PHPDBG_HELP(aliases) /* {{{ */ * has a key ending in ! */ #define CR "\n" -phpdbg_help_text_t phpdbg_help_text[] = { +const phpdbg_help_text_t phpdbg_help_text[] = { /******************************** General Help Topics ********************************/ {"overview!", CR diff --git a/sapi/phpdbg/phpdbg_help.h b/sapi/phpdbg/phpdbg_help.h index ef9a3507987..e4c9dd63881 100644 --- a/sapi/phpdbg/phpdbg_help.h +++ b/sapi/phpdbg/phpdbg_help.h @@ -42,7 +42,7 @@ typedef struct _phpdbg_help_text_t { char *text; } phpdbg_help_text_t; -extern phpdbg_help_text_t phpdbg_help_text[]; +extern const phpdbg_help_text_t phpdbg_help_text[]; -extern void phpdbg_do_help_cmd(char *type); +extern void phpdbg_do_help_cmd(const char *type); #endif /* PHPDBG_HELP_H */