diff --git a/Zend/zend_signal.c b/Zend/zend_signal.c index aa74bdd147c98..e68ddcf029140 100644 --- a/Zend/zend_signal.c +++ b/Zend/zend_signal.c @@ -71,7 +71,7 @@ static int zend_signal_register(int signo, void (*handler)(int, siginfo_t*, void #define TIMEOUT_SIG SIGPROF #endif -static int zend_sigs[] = { TIMEOUT_SIG, SIGHUP, SIGINT, SIGQUIT, SIGTERM, SIGUSR1, SIGUSR2 }; +static const int zend_sigs[] = { TIMEOUT_SIG, SIGHUP, SIGINT, SIGQUIT, SIGTERM, SIGUSR1, SIGUSR2 }; #define SA_FLAGS_MASK ~(SA_NODEFER | SA_RESETHAND) diff --git a/ext/dba/dba.c b/ext/dba/dba.c index 7e0f56b443e09..f468016c8ea94 100644 --- a/ext/dba/dba.c +++ b/ext/dba/dba.c @@ -55,8 +55,8 @@ PHP_MSHUTDOWN_FUNCTION(dba); PHP_MINFO_FUNCTION(dba); ZEND_BEGIN_MODULE_GLOBALS(dba) - char *default_handler; - dba_handler *default_hptr; + const char *default_handler; + const dba_handler *default_hptr; ZEND_END_MODULE_GLOBALS(dba) ZEND_DECLARE_MODULE_GLOBALS(dba) @@ -159,7 +159,7 @@ static zend_string* php_dba_make_key(HashTable *key) /* {{{ globals */ -static dba_handler handler[] = { +static const dba_handler handler[] = { #ifdef DBA_GDBM DBA_HND(gdbm, DBA_LOCK_EXT) /* Locking done in library if set */ #endif @@ -249,7 +249,7 @@ PHPAPI void dba_fetch_resource(dba_info **pinfo, zval **id) /* {{{ dba_get_handler PHPAPI dba_handler *dba_get_handler(const char* handler_name) { - dba_handler *hptr; + const dba_handler *hptr; for (hptr = handler; hptr->name && strcasecmp(hptr->name, handler_name); hptr++); return hptr; } @@ -320,7 +320,7 @@ static void dba_close_pe_rsrc(zend_resource *rsrc) /* {{{ PHP_INI */ ZEND_INI_MH(OnUpdateDefaultHandler) { - dba_handler *hptr; + const dba_handler *hptr; if (!ZSTR_LEN(new_value)) { DBA_G(default_hptr) = NULL; @@ -377,7 +377,7 @@ PHP_MSHUTDOWN_FUNCTION(dba) /* {{{ PHP_MINFO_FUNCTION */ PHP_MINFO_FUNCTION(dba) { - dba_handler *hptr; + const dba_handler *hptr; smart_str handlers = {0}; for(hptr = handler; hptr->name; hptr++) { @@ -461,7 +461,7 @@ static void php_dba_open(INTERNAL_FUNCTION_PARAMETERS, bool persistent) { dba_mode_t modenr; dba_info *info, *other; - dba_handler *hptr; + const dba_handler *hptr; char *error = NULL; int lock_mode, lock_flag = 0; char *file_mode; @@ -1165,7 +1165,7 @@ PHP_FUNCTION(dba_sync) /* {{{ List configured database handlers */ PHP_FUNCTION(dba_handlers) { - dba_handler *hptr; + const dba_handler *hptr; bool full_info = 0; if (zend_parse_parameters(ZEND_NUM_ARGS(), "|b", &full_info) == FAILURE) { diff --git a/ext/dba/php_dba.h b/ext/dba/php_dba.h index ce59e4851d9f8..edeed50a84499 100644 --- a/ext/dba/php_dba.h +++ b/ext/dba/php_dba.h @@ -48,7 +48,7 @@ typedef struct dba_info { zend_long driver_flags; /* private */ int flags; /* whether and how dba did locking and other flags*/ - struct dba_handler *hnd; + const struct dba_handler *hnd; dba_lock lock; } dba_info; @@ -85,7 +85,7 @@ typedef struct dba_handler { zend_string* (*nextkey)(dba_info *); zend_result (*optimize)(dba_info *); zend_result (*sync)(dba_info *); - char* (*info)(struct dba_handler *hnd, dba_info *); + char* (*info)(const struct dba_handler *hnd, dba_info *); /* dba_info==NULL: Handler info, dba_info!=NULL: Database info */ } dba_handler; @@ -112,7 +112,7 @@ typedef struct dba_handler { #define DBA_SYNC_FUNC(x) \ zend_result dba_sync_##x(dba_info *info) #define DBA_INFO_FUNC(x) \ - char *dba_info_##x(dba_handler *hnd, dba_info *info) + char *dba_info_##x(const dba_handler *hnd, dba_info *info) #define DBA_FUNCS(x) \ DBA_OPEN_FUNC(x); \ diff --git a/ext/exif/exif.c b/ext/exif/exif.c index a6db8745b3a42..0b919e94696ba 100644 --- a/ext/exif/exif.c +++ b/ext/exif/exif.c @@ -230,10 +230,10 @@ static size_t php_strnlen(char* str, size_t maxlen) { /* }}} */ /* {{{ error messages */ -static const char * EXIF_ERROR_FILEEOF = "Unexpected end of file reached"; -static const char * EXIF_ERROR_CORRUPT = "File structure corrupted"; -static const char * EXIF_ERROR_THUMBEOF = "Thumbnail goes IFD boundary or end of file reached"; -static const char * EXIF_ERROR_FSREALLOC = "Illegal reallocating of undefined file section"; +static const char *const EXIF_ERROR_FILEEOF = "Unexpected end of file reached"; +static const char *const EXIF_ERROR_CORRUPT = "File structure corrupted"; +static const char *const EXIF_ERROR_THUMBEOF = "Thumbnail goes IFD boundary or end of file reached"; +static const char *const EXIF_ERROR_FSREALLOC = "Illegal reallocating of undefined file section"; #define EXIF_ERRLOG_FILEEOF(ImageInfo) exif_error_docref(NULL EXIFERR_CC, ImageInfo, E_WARNING, "%s", EXIF_ERROR_FILEEOF); #define EXIF_ERRLOG_CORRUPT(ImageInfo) exif_error_docref(NULL EXIFERR_CC, ImageInfo, E_WARNING, "%s", EXIF_ERROR_CORRUPT); @@ -244,7 +244,7 @@ static const char * EXIF_ERROR_FSREALLOC = "Illegal reallocating of undefined fi /* {{{ format description defines Describes format descriptor */ -static int php_tiff_bytes_per_format[] = {0, 1, 1, 2, 4, 8, 1, 1, 2, 4, 8, 4, 8, 1}; +static const int php_tiff_bytes_per_format[] = {0, 1, 1, 2, 4, 8, 1, 1, 2, 4, 8, 4, 8, 1}; #define NUM_FORMATS 13 #define TAG_FMT_BYTE 1 diff --git a/ext/intl/grapheme/grapheme_string.c b/ext/intl/grapheme/grapheme_string.c index 29bbdf7ff950c..a9cfd3d2ea6e5 100644 --- a/ext/intl/grapheme/grapheme_string.c +++ b/ext/intl/grapheme/grapheme_string.c @@ -679,7 +679,7 @@ grapheme_extract_count_iter(UBreakIterator *bi, int32_t size, unsigned char *pst /* {{{ grapheme extract iter function pointer array */ typedef int32_t (*grapheme_extract_iter)(UBreakIterator * /*bi*/, int32_t /*size*/, unsigned char * /*pstr*/, int32_t /*str_len*/); -static grapheme_extract_iter grapheme_extract_iters[] = { +static const grapheme_extract_iter grapheme_extract_iters[] = { &grapheme_extract_count_iter, &grapheme_extract_bytecount_iter, &grapheme_extract_charcount_iter, diff --git a/ext/mbstring/gen_rare_cp_bitvec.php b/ext/mbstring/gen_rare_cp_bitvec.php index 741c3827de509..ca1e85cb3d89a 100755 --- a/ext/mbstring/gen_rare_cp_bitvec.php +++ b/ext/mbstring/gen_rare_cp_bitvec.php @@ -40,7 +40,7 @@ * as less likely to be the correct one. */ -static uint32_t rare_codepoint_bitvec[] = { +static const uint32_t rare_codepoint_bitvec[] = { HEADER; for ($i = 0; $i < 0xFFFF / 32; $i++) { diff --git a/ext/mbstring/rare_cp_bitvec.h b/ext/mbstring/rare_cp_bitvec.h index 56a40478b5a34..dec97a7d74f50 100644 --- a/ext/mbstring/rare_cp_bitvec.h +++ b/ext/mbstring/rare_cp_bitvec.h @@ -9,7 +9,7 @@ * as less likely to be the correct one. */ -static uint32_t rare_codepoint_bitvec[] = { +static const uint32_t rare_codepoint_bitvec[] = { 0xffffd9ff, 0x00000000, 0x00000000, 0x80000000, 0xffffffff, 0x00002001, 0x00000000, 0x00000000, 0x70ff0f0f, 0xfffcffff, 0x70fcfe61, 0x81fc3fcc, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, diff --git a/ext/opcache/shared_alloc_mmap.c b/ext/opcache/shared_alloc_mmap.c index e180607efa186..20fbc51442092 100644 --- a/ext/opcache/shared_alloc_mmap.c +++ b/ext/opcache/shared_alloc_mmap.c @@ -276,7 +276,7 @@ static size_t segment_type_size(void) return sizeof(zend_shared_segment); } -zend_shared_memory_handlers zend_alloc_mmap_handlers = { +const zend_shared_memory_handlers zend_alloc_mmap_handlers = { create_segments, detach_segment, segment_type_size diff --git a/ext/opcache/shared_alloc_posix.c b/ext/opcache/shared_alloc_posix.c index bab4c4544ef91..c7489a247016f 100644 --- a/ext/opcache/shared_alloc_posix.c +++ b/ext/opcache/shared_alloc_posix.c @@ -89,7 +89,7 @@ static size_t segment_type_size(void) return sizeof(zend_shared_segment_posix); } -zend_shared_memory_handlers zend_alloc_posix_handlers = { +const zend_shared_memory_handlers zend_alloc_posix_handlers = { (create_segments_t)create_segments, (detach_segment_t)detach_segment, segment_type_size diff --git a/ext/opcache/shared_alloc_shm.c b/ext/opcache/shared_alloc_shm.c index c55e74e1f7db5..2764dffd5e43e 100644 --- a/ext/opcache/shared_alloc_shm.c +++ b/ext/opcache/shared_alloc_shm.c @@ -135,7 +135,7 @@ static size_t segment_type_size(void) return sizeof(zend_shared_segment_shm); } -zend_shared_memory_handlers zend_alloc_shm_handlers = { +const zend_shared_memory_handlers zend_alloc_shm_handlers = { (create_segments_t)create_segments, (detach_segment_t)detach_segment, segment_type_size diff --git a/ext/opcache/shared_alloc_win32.c b/ext/opcache/shared_alloc_win32.c index c64816c053def..97cae92ee2dba 100644 --- a/ext/opcache/shared_alloc_win32.c +++ b/ext/opcache/shared_alloc_win32.c @@ -352,7 +352,7 @@ static size_t segment_type_size(void) return sizeof(zend_shared_segment); } -zend_shared_memory_handlers zend_alloc_win32_handlers = { +const zend_shared_memory_handlers zend_alloc_win32_handlers = { create_segments, detach_segment, segment_type_size diff --git a/ext/opcache/zend_accelerator_hash.c b/ext/opcache/zend_accelerator_hash.c index 676ed32ce8ff3..2fd3dfb5ed56e 100644 --- a/ext/opcache/zend_accelerator_hash.c +++ b/ext/opcache/zend_accelerator_hash.c @@ -25,9 +25,9 @@ #include "zend_shared_alloc.h" /* Generated on an Octa-ALPHA 300MHz CPU & 2.5GB RAM monster */ -static uint32_t prime_numbers[] = +static const uint32_t prime_numbers[] = {5, 11, 19, 53, 107, 223, 463, 983, 1979, 3907, 7963, 16229, 32531, 65407, 130987, 262237, 524521, 1048793 }; -static uint32_t num_prime_numbers = sizeof(prime_numbers) / sizeof(uint32_t); +static const uint32_t num_prime_numbers = sizeof(prime_numbers) / sizeof(uint32_t); void zend_accel_hash_clean(zend_accel_hash *accel_hash) { diff --git a/ext/opcache/zend_shared_alloc.h b/ext/opcache/zend_shared_alloc.h index c56bd2bc8f4b2..7c52997f18a79 100644 --- a/ext/opcache/zend_shared_alloc.h +++ b/ext/opcache/zend_shared_alloc.h @@ -91,7 +91,7 @@ typedef struct { typedef struct _handler_entry { const char *name; - zend_shared_memory_handlers *handler; + const zend_shared_memory_handlers *handler; } zend_shared_memory_handler_entry; typedef struct _zend_shared_memory_state { @@ -197,19 +197,19 @@ const char *zend_accel_get_shared_model(void); void zend_accel_shared_protect(int mode); #ifdef USE_MMAP -extern zend_shared_memory_handlers zend_alloc_mmap_handlers; +extern const zend_shared_memory_handlers zend_alloc_mmap_handlers; #endif #ifdef USE_SHM -extern zend_shared_memory_handlers zend_alloc_shm_handlers; +extern const zend_shared_memory_handlers zend_alloc_shm_handlers; #endif #ifdef USE_SHM_OPEN -extern zend_shared_memory_handlers zend_alloc_posix_handlers; +extern const zend_shared_memory_handlers zend_alloc_posix_handlers; #endif #ifdef ZEND_WIN32 -extern zend_shared_memory_handlers zend_alloc_win32_handlers; +extern const zend_shared_memory_handlers zend_alloc_win32_handlers; void zend_shared_alloc_create_lock(void); void zend_shared_alloc_lock_win32(void); void zend_shared_alloc_unlock_win32(void); diff --git a/ext/snmp/snmp.c b/ext/snmp/snmp.c index 6c7a6f42e968c..a1cdcc7096752 100644 --- a/ext/snmp/snmp.c +++ b/ext/snmp/snmp.c @@ -91,7 +91,7 @@ ZEND_DECLARE_MODULE_GLOBALS(snmp) static PHP_GINIT_FUNCTION(snmp); /* constant - can be shared among threads */ -static oid objid_mib[] = {1, 3, 6, 1, 2, 1}; +static const oid objid_mib[] = {1, 3, 6, 1, 2, 1}; /* Handlers */ static zend_object_handlers php_snmp_object_handlers; @@ -765,7 +765,7 @@ static bool php_snmp_parse_oid( return false; } } else { - memmove((char *)objid_query->vars[0].name, (char *)objid_mib, sizeof(objid_mib)); + memmove((char *)objid_query->vars[0].name, (const char *)objid_mib, sizeof(objid_mib)); objid_query->vars[0].name_length = sizeof(objid_mib) / sizeof(oid); } } else {