diff --git a/Zend/zend_builtin_functions.c b/Zend/zend_builtin_functions.c index 355e562489d89..c16d8e74f2bde 100644 --- a/Zend/zend_builtin_functions.c +++ b/Zend/zend_builtin_functions.c @@ -1088,7 +1088,7 @@ flf_clean:; Z_FLF_PARAM_FREE_STR(2, property_tmp) } -static inline void _class_exists_impl(zval *return_value, zend_string *name, bool autoload, int flags, int skip_flags) /* {{{ */ +static zend_always_inline void _class_exists_impl(zval *return_value, zend_string *name, bool autoload, int flags, int skip_flags) /* {{{ */ { zend_string *lcname; zend_class_entry *ce; diff --git a/Zend/zend_hash.c b/Zend/zend_hash.c index c00397e9fe9e3..e0e789cb7cb40 100644 --- a/Zend/zend_hash.c +++ b/Zend/zend_hash.c @@ -168,7 +168,7 @@ static zend_always_inline void zend_hash_real_init_mixed_ex(HashTable *ht) void *data; uint32_t nSize = ht->nTableSize; - ZEND_ASSERT(HT_SIZE_TO_MASK(nSize)); + ZEND_ASSERT(HT_SIZE_TO_MASK(nSize) != 0); if (UNEXPECTED(GC_FLAGS(ht) & IS_ARRAY_PERSISTENT)) { data = pemalloc(HT_SIZE_EX(nSize, HT_SIZE_TO_MASK(nSize)), 1); @@ -350,7 +350,7 @@ ZEND_API void ZEND_FASTCALL zend_hash_packed_to_hash(HashTable *ht) uint32_t i; uint32_t nSize = ht->nTableSize; - ZEND_ASSERT(HT_SIZE_TO_MASK(nSize)); + ZEND_ASSERT(HT_SIZE_TO_MASK(nSize) != 0); HT_ASSERT_RC1(ht); // Alloc before assign to avoid inconsistencies on OOM @@ -398,7 +398,7 @@ ZEND_API void ZEND_FASTCALL zend_hash_extend(HashTable *ht, uint32_t nSize, bool if (nSize == 0) return; - ZEND_ASSERT(HT_SIZE_TO_MASK(nSize)); + ZEND_ASSERT(HT_SIZE_TO_MASK(nSize) != 0); if (UNEXPECTED(HT_FLAGS(ht) & HASH_FLAG_UNINITIALIZED)) { if (nSize > ht->nTableSize) { @@ -1324,7 +1324,7 @@ static void ZEND_FASTCALL zend_hash_do_resize(HashTable *ht) uint32_t nSize = ht->nTableSize + ht->nTableSize; Bucket *old_buckets = ht->arData; - ZEND_ASSERT(HT_SIZE_TO_MASK(nSize)); + ZEND_ASSERT(HT_SIZE_TO_MASK(nSize) != 0); new_data = pemalloc(HT_SIZE_EX(nSize, HT_SIZE_TO_MASK(nSize)), GC_FLAGS(ht) & IS_ARRAY_PERSISTENT); ht->nTableSize = nSize; diff --git a/ext/standard/array.c b/ext/standard/array.c index f8dd7d891dd39..de889154edd42 100644 --- a/ext/standard/array.c +++ b/ext/standard/array.c @@ -1527,7 +1527,7 @@ PHP_FUNCTION(array_walk_recursive) * 0 = return boolean * 1 = return key */ -static inline void _php_search_array(zval *return_value, zval *value, zval *array, bool strict, int behavior) /* {{{ */ +static zend_always_inline void _php_search_array(zval *return_value, zval *value, zval *array, bool strict, int behavior) /* {{{ */ { zval *entry; /* pointer to array entry */ zend_ulong num_idx; diff --git a/ext/standard/exec.c b/ext/standard/exec.c index 762d8bee13c22..7bacc976eac50 100644 --- a/ext/standard/exec.c +++ b/ext/standard/exec.c @@ -272,7 +272,7 @@ PHPAPI zend_string *php_escape_shell_cmd(const zend_string *unescaped_cmd) size_t x, y; zend_string *cmd; #ifndef PHP_WIN32 - char *p = NULL; + const char *p = NULL; #endif ZEND_ASSERT(!zend_str_has_nul_byte(unescaped_cmd) && "Must be a binary safe string"); diff --git a/ext/standard/filters.c b/ext/standard/filters.c index 34393be54d8b4..0faa0eda6863a 100644 --- a/ext/standard/filters.c +++ b/ext/standard/filters.c @@ -1558,7 +1558,7 @@ static php_stream_filter *strfilter_convert_create(const char *filtername, zval { php_convert_filter *inst; - char *dot; + const char *dot; int conv_mode = 0; if (filterparams != NULL && Z_TYPE_P(filterparams) != IS_ARRAY) { diff --git a/ext/standard/string.c b/ext/standard/string.c index 0b7d5be1a2576..d146b4534e275 100644 --- a/ext/standard/string.c +++ b/ext/standard/string.c @@ -1500,7 +1500,7 @@ PHPAPI size_t php_dirname(char *path, size_t len) } /* }}} */ -static inline void _zend_dirname(zval *return_value, zend_string *str, zend_long levels) +static zend_always_inline void _zend_dirname(zval *return_value, zend_string *str, zend_long levels) { zend_string *ret; @@ -1745,7 +1745,7 @@ PHP_FUNCTION(stristr) } /* }}} */ -static inline void _zend_strstr(zval *return_value, zend_string *haystack, zend_string *needle, bool part) +static zend_always_inline void _zend_strstr(zval *return_value, zend_string *haystack, zend_string *needle, bool part) { const char *found = NULL; zend_long found_offset; @@ -1889,7 +1889,7 @@ PHP_FUNCTION(str_ends_with) } /* }}} */ -static inline void _zend_strpos(zval *return_value, zend_string *haystack, zend_string *needle, zend_long offset) +static zend_always_inline void _zend_strpos(zval *return_value, zend_string *haystack, zend_string *needle, zend_long offset) { const char *found = NULL; diff --git a/ext/standard/type.c b/ext/standard/type.c index c05926b1a3770..5bb7b3b803eee 100644 --- a/ext/standard/type.c +++ b/ext/standard/type.c @@ -344,7 +344,7 @@ PHP_FUNCTION(is_object) } /* }}} */ -static inline void _zend_is_numeric(zval *return_value, zval *arg) +static zend_always_inline void _zend_is_numeric(zval *return_value, zval *arg) { switch (Z_TYPE_P(arg)) { case IS_LONG: diff --git a/ext/standard/user_filters.c b/ext/standard/user_filters.c index da8260dfd6de3..610784e547e45 100644 --- a/ext/standard/user_filters.c +++ b/ext/standard/user_filters.c @@ -260,7 +260,7 @@ static php_stream_filter *user_filter_factory_create(const char *filtername, /* determine the classname/class entry */ if (NULL == (fdat = zend_hash_str_find_ptr(BG(user_filter_map), filtername, len))) { - char *period; + const char *period; /* Userspace Filters using ambiguous wildcards could cause problems. i.e.: myfilter.foo.bar will always call into myfilter.foo.* @@ -272,16 +272,16 @@ static php_stream_filter *user_filter_factory_create(const char *filtername, /* Search for wildcard matches instead */ memcpy(wildcard, filtername, len + 1); /* copy \0 */ - period = wildcard + (period - filtername); - while (period) { - ZEND_ASSERT(period[0] == '.'); - period[1] = '*'; - period[2] = '\0'; + char *new_period = wildcard + (period - filtername); + while (new_period) { + ZEND_ASSERT(new_period[0] == '.'); + new_period[1] = '*'; + new_period[2] = '\0'; if (NULL != (fdat = zend_hash_str_find_ptr(BG(user_filter_map), wildcard, strlen(wildcard)))) { - period = NULL; + new_period = NULL; } else { - *period = '\0'; - period = strrchr(wildcard, '.'); + *new_period = '\0'; + new_period = strrchr(wildcard, '.'); } } efree(wildcard); diff --git a/main/fastcgi.c b/main/fastcgi.c index bee1fa47e662e..3488d6e21eaea 100644 --- a/main/fastcgi.c +++ b/main/fastcgi.c @@ -641,7 +641,7 @@ static int is_port_number(const char *bindpath) int fcgi_listen(const char *path, int backlog) { - char *s; + const char *s; int tcp = 0; char host[MAXPATHLEN]; short port = 0; diff --git a/main/main.c b/main/main.c index 8062f92fe1bdb..bbd2d18ba187b 100644 --- a/main/main.c +++ b/main/main.c @@ -1062,7 +1062,7 @@ PHPAPI ZEND_COLD void php_verror(const char *docref, const char *params, int typ { zend_string *replace_origin = NULL; char *docref_buf = NULL, *target = NULL; - char *docref_target = "", *docref_root = ""; + const char *docref_target = "", *docref_root = ""; char *p; const char *space = ""; const char *class_name = ""; diff --git a/main/network.c b/main/network.c index c4e2ab2e67daa..54dbf2b8e580f 100644 --- a/main/network.c +++ b/main/network.c @@ -599,7 +599,7 @@ php_socket_t php_network_bind_socket_to_local_addr(const char *host, unsigned po PHPAPI zend_result php_network_parse_network_address_with_port(const char *addr, size_t addrlen, struct sockaddr *sa, socklen_t *sl) { - char *colon; + const char *colon; char *tmp; zend_result ret = FAILURE; short port; diff --git a/main/streams/filter.c b/main/streams/filter.c index b63d789190792..d0c1fdc8e788c 100644 --- a/main/streams/filter.c +++ b/main/streams/filter.c @@ -222,7 +222,7 @@ PHPAPI php_stream_filter *php_stream_filter_create(const char *filtername, zval const php_stream_filter_factory *factory = NULL; php_stream_filter *filter = NULL; size_t n; - char *period; + const char *period; n = strlen(filtername); @@ -234,17 +234,17 @@ PHPAPI php_stream_filter *php_stream_filter_create(const char *filtername, zval wildname = safe_emalloc(1, n, 3); memcpy(wildname, filtername, n+1); - period = wildname + (period - filtername); - while (period && !filter) { - ZEND_ASSERT(period[0] == '.'); - period[1] = '*'; - period[2] = '\0'; + char *new_period = wildname + (period - filtername); + while (new_period && !filter) { + ZEND_ASSERT(new_period[0] == '.'); + new_period[1] = '*'; + new_period[2] = '\0'; if (NULL != (factory = zend_hash_str_find_ptr(filter_hash, wildname, strlen(wildname)))) { filter = factory->create_filter(filtername, filterparams, persistent); } - *period = '\0'; - period = strrchr(wildname, '.'); + *new_period = '\0'; + new_period = strrchr(wildname, '.'); } efree(wildname); } diff --git a/main/streams/memory.c b/main/streams/memory.c index 66e0abe2c5fd9..9cb94542df6f5 100644 --- a/main/streams/memory.c +++ b/main/streams/memory.c @@ -617,7 +617,8 @@ static php_stream * php_stream_url_wrap_rfc2397(php_stream_wrapper *wrapper, con { php_stream *stream; php_stream_temp_data *ts; - char *comma, *semi, *sep; + char *comma; + const char *semi, *sep; size_t mlen, dlen, plen, vlen, ilen; zend_off_t newoffs; zval meta; @@ -639,7 +640,7 @@ static php_stream * php_stream_url_wrap_rfc2397(php_stream_wrapper *wrapper, con path += 2; } - if ((comma = memchr(path, ',', dlen)) == NULL) { + if ((comma = (char *) memchr(path, ',', dlen)) == NULL) { php_stream_wrapper_log_error(wrapper, options, "rfc2397: no comma in URL"); return NULL; } diff --git a/main/streams/plain_wrapper.c b/main/streams/plain_wrapper.c index 688d271db8147..74d8877a7f381 100644 --- a/main/streams/plain_wrapper.c +++ b/main/streams/plain_wrapper.c @@ -1778,7 +1778,7 @@ PHPAPI php_stream *_php_stream_fopen_with_path(const char *filename, const char ptr = pathbuf; while (ptr && *ptr) { - end = strchr(ptr, DEFAULT_DIR_SEPARATOR); + end = (char *) strchr(ptr, DEFAULT_DIR_SEPARATOR); if (end != NULL) { *end = '\0'; end++; diff --git a/main/streams/xp_socket.c b/main/streams/xp_socket.c index edf1751ec33b5..9eae9e460e475 100644 --- a/main/streams/xp_socket.c +++ b/main/streams/xp_socket.c @@ -627,7 +627,7 @@ static inline int parse_unix_address(php_stream_xport_param *xparam, struct sock static inline char *parse_ip_address_ex(const char *str, size_t str_len, int *portno, int get_err, zend_string **err) { - char *colon; + const char *colon; char *host = NULL; if (memchr(str, '\0', str_len)) { @@ -638,7 +638,7 @@ static inline char *parse_ip_address_ex(const char *str, size_t str_len, int *po #ifdef HAVE_IPV6 if (*(str) == '[' && str_len > 1) { /* IPV6 notation to specify raw address with port (i.e. [fe80::1]:80) */ - char *p = memchr(str + 1, ']', str_len - 2); + const char *p = memchr(str + 1, ']', str_len - 2); if (!p || *(p + 1) != ':') { if (get_err) { *err = strpprintf(0, "Failed to parse IPv6 address \"%s\"", str); diff --git a/sapi/phpdbg/phpdbg_utils.c b/sapi/phpdbg/phpdbg_utils.c index 55d97acc38759..728baa92124c2 100644 --- a/sapi/phpdbg/phpdbg_utils.c +++ b/sapi/phpdbg/phpdbg_utils.c @@ -111,7 +111,7 @@ PHPDBG_API int phpdbg_is_addr(const char *str) /* {{{ */ PHPDBG_API int phpdbg_is_class_method(const char *str, size_t len, char **class, char **method) /* {{{ */ { - char *sep = NULL; + const char *sep = NULL; if (strstr(str, "#") != NULL) return 0;