From: Anatol Belski Date: Sun, 22 Oct 2017 17:58:42 +0000 (+0200) Subject: Fix datatypes and compiler warnings X-Git-Tag: php-7.3.0alpha1~1206 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=793ca716fba66d3bee6448615a9a279857c286d5;p=php Fix datatypes and compiler warnings Switch to size_t Not critical as an unsigned is already used, but fixes a couple of warnings in other areas. Normalize signature It's a function with the usual compare semantics, returning a platform specific at least produces unnecessary warnings elsewhere and is otherwise inappropriate. Fix return value Drop unused var Fix compiler warnings Fix compiler warning Fix var name in arginfo Fix cast --- diff --git a/Zend/zend_ini.c b/Zend/zend_ini.c index b9212d6d8b..f585bba2d2 100644 --- a/Zend/zend_ini.c +++ b/Zend/zend_ini.c @@ -418,7 +418,7 @@ ZEND_API int zend_ini_register_displayer(char *name, uint32_t name_length, void * Data retrieval */ -ZEND_API zend_long zend_ini_long(char *name, uint32_t name_length, int orig) /* {{{ */ +ZEND_API zend_long zend_ini_long(char *name, size_t name_length, int orig) /* {{{ */ { zend_ini_entry *ini_entry; @@ -435,7 +435,7 @@ ZEND_API zend_long zend_ini_long(char *name, uint32_t name_length, int orig) /* } /* }}} */ -ZEND_API double zend_ini_double(char *name, uint32_t name_length, int orig) /* {{{ */ +ZEND_API double zend_ini_double(char *name, size_t name_length, int orig) /* {{{ */ { zend_ini_entry *ini_entry; @@ -452,7 +452,7 @@ ZEND_API double zend_ini_double(char *name, uint32_t name_length, int orig) /* { } /* }}} */ -ZEND_API char *zend_ini_string_ex(char *name, uint32_t name_length, int orig, zend_bool *exists) /* {{{ */ +ZEND_API char *zend_ini_string_ex(char *name, size_t name_length, int orig, zend_bool *exists) /* {{{ */ { zend_ini_entry *ini_entry; @@ -476,7 +476,7 @@ ZEND_API char *zend_ini_string_ex(char *name, uint32_t name_length, int orig, ze } /* }}} */ -ZEND_API char *zend_ini_string(char *name, uint32_t name_length, int orig) /* {{{ */ +ZEND_API char *zend_ini_string(char *name, size_t name_length, int orig) /* {{{ */ { zend_bool exists = 1; char *return_value; diff --git a/Zend/zend_ini.h b/Zend/zend_ini.h index 7c4fa39025..620b3013c4 100644 --- a/Zend/zend_ini.h +++ b/Zend/zend_ini.h @@ -83,10 +83,10 @@ ZEND_API int zend_alter_ini_entry_chars_ex(zend_string *name, const char *value, ZEND_API int zend_restore_ini_entry(zend_string *name, int stage); ZEND_API void display_ini_entries(zend_module_entry *module); -ZEND_API zend_long zend_ini_long(char *name, uint32_t name_length, int orig); -ZEND_API double zend_ini_double(char *name, uint32_t name_length, int orig); -ZEND_API char *zend_ini_string(char *name, uint32_t name_length, int orig); -ZEND_API char *zend_ini_string_ex(char *name, uint32_t name_length, int orig, zend_bool *exists); +ZEND_API zend_long zend_ini_long(char *name, size_t name_length, int orig); +ZEND_API double zend_ini_double(char *name, size_t name_length, int orig); +ZEND_API char *zend_ini_string(char *name, size_t name_length, int orig); +ZEND_API char *zend_ini_string_ex(char *name, size_t name_length, int orig, zend_bool *exists); ZEND_API int zend_ini_register_displayer(char *name, uint32_t name_length, void (*displayer)(zend_ini_entry *ini_entry, int type)); diff --git a/Zend/zend_operators.c b/Zend/zend_operators.c index 8a20d1ca28..fe6f97b12c 100644 --- a/Zend/zend_operators.c +++ b/Zend/zend_operators.c @@ -2757,7 +2757,7 @@ ZEND_API int ZEND_FASTCALL zend_binary_zval_strncasecmp(zval *s1, zval *s2, zval } /* }}} */ -ZEND_API zend_long ZEND_FASTCALL zendi_smart_strcmp(zend_string *s1, zend_string *s2) /* {{{ */ +ZEND_API int ZEND_FASTCALL zendi_smart_strcmp(zend_string *s1, zend_string *s2) /* {{{ */ { int ret1, ret2; int oflow1, oflow2; diff --git a/Zend/zend_operators.h b/Zend/zend_operators.h index b6e16c3430..e11d2551f5 100644 --- a/Zend/zend_operators.h +++ b/Zend/zend_operators.h @@ -361,7 +361,7 @@ ZEND_API int ZEND_FASTCALL zend_binary_strncasecmp(const char *s1, size_t len1, ZEND_API int ZEND_FASTCALL zend_binary_strcasecmp_l(const char *s1, size_t len1, const char *s2, size_t len2); ZEND_API int ZEND_FASTCALL zend_binary_strncasecmp_l(const char *s1, size_t len1, const char *s2, size_t len2, size_t length); -ZEND_API zend_long ZEND_FASTCALL zendi_smart_strcmp(zend_string *s1, zend_string *s2); +ZEND_API int ZEND_FASTCALL zendi_smart_strcmp(zend_string *s1, zend_string *s2); ZEND_API int ZEND_FASTCALL zend_compare_symbol_tables(HashTable *ht1, HashTable *ht2); ZEND_API int ZEND_FASTCALL zend_compare_arrays(zval *a1, zval *a2); ZEND_API int ZEND_FASTCALL zend_compare_objects(zval *o1, zval *o2); diff --git a/ext/intl/spoofchecker/spoofchecker_class.c b/ext/intl/spoofchecker/spoofchecker_class.c index 2b69290295..70ac89db7b 100644 --- a/ext/intl/spoofchecker/spoofchecker_class.c +++ b/ext/intl/spoofchecker/spoofchecker_class.c @@ -85,7 +85,7 @@ ZEND_BEGIN_ARG_INFO_EX(spoofchecker_are_confusable, 0, 0, 2) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(spoofchecker_set_restriction_level, 0, 0, 1) - ZEND_ARG_INFO(0, checks) + ZEND_ARG_INFO(0, level) ZEND_END_ARG_INFO() /* }}} */ diff --git a/ext/standard/array.c b/ext/standard/array.c index 50ca1d2c40..3d4c153f12 100644 --- a/ext/standard/array.c +++ b/ext/standard/array.c @@ -394,7 +394,7 @@ static int php_array_data_compare(const void *a, const void *b) /* {{{ */ } ZEND_ASSERT(Z_TYPE(result) == IS_LONG); - return Z_LVAL(result); + return ZEND_NORMALIZE_BOOL(Z_LVAL(result)); } /* }}} */ @@ -779,7 +779,6 @@ PHP_FUNCTION(count) zval *array; zend_long mode = COUNT_NORMAL; zend_long cnt; - zval *element; ZEND_PARSE_PARAMETERS_START(1, 2) Z_PARAM_ZVAL(array) @@ -2654,13 +2653,13 @@ PHP_FUNCTION(array_fill) array_init_size(return_value, (uint32_t)(start_key + num)); zend_hash_real_init(Z_ARRVAL_P(return_value), 1); - Z_ARRVAL_P(return_value)->nNumUsed = start_key + num; - Z_ARRVAL_P(return_value)->nNumOfElements = num; - Z_ARRVAL_P(return_value)->nInternalPointer = start_key; - Z_ARRVAL_P(return_value)->nNextFreeElement = start_key + num; + Z_ARRVAL_P(return_value)->nNumUsed = (uint32_t)(start_key + num); + Z_ARRVAL_P(return_value)->nNumOfElements = (uint32_t)num; + Z_ARRVAL_P(return_value)->nInternalPointer = (uint32_t)start_key; + Z_ARRVAL_P(return_value)->nNextFreeElement = (zend_long)(start_key + num); if (Z_REFCOUNTED_P(val)) { - GC_REFCOUNT(Z_COUNTED_P(val)) += num; + GC_REFCOUNT(Z_COUNTED_P(val)) += (uint32_t)num; } p = Z_ARRVAL_P(return_value)->arData; @@ -2681,7 +2680,7 @@ PHP_FUNCTION(array_fill) array_init_size(return_value, (uint32_t)num); zend_hash_real_init(Z_ARRVAL_P(return_value), 0); if (Z_REFCOUNTED_P(val)) { - GC_REFCOUNT(Z_COUNTED_P(val)) += num; + GC_REFCOUNT(Z_COUNTED_P(val)) += (uint32_t)num; } zend_hash_index_add_new(Z_ARRVAL_P(return_value), start_key, val); while (--num) { @@ -2949,7 +2948,7 @@ static void php_array_data_shuffle(zval *array) /* {{{ */ Bucket *p, temp; HashTable *hash; zend_long rnd_idx; - zend_long n_left; + uint32_t n_left; n_elems = zend_hash_num_elements(Z_ARRVAL_P(array));