From 560e4fa39327e952652b6469d9644fc5fa2c15fa Mon Sep 17 00:00:00 2001 From: Dmitry Stogov Date: Tue, 29 Sep 2015 11:17:43 +0300 Subject: [PATCH] Removed or simplified incorrect SEPARATE_*() macros usage. --- Zend/zend_API.c | 2 +- ext/hash/hash.c | 4 +--- ext/intl/formatter/formatter_format.c | 1 - ext/intl/grapheme/grapheme_string.c | 2 +- ext/intl/transliterator/transliterator_methods.c | 1 - ext/ldap/ldap.c | 1 - ext/libxml/libxml.c | 1 - ext/pcntl/pcntl.c | 12 ++---------- ext/pcre/php_pcre.c | 2 -- ext/pdo_pgsql/pgsql_statement.c | 6 +++--- ext/standard/array.c | 9 +++------ ext/standard/formatted_print.c | 1 - ext/standard/string.c | 1 - ext/xsl/xsltprocessor.c | 3 --- main/php_variables.c | 2 +- main/streams/userspace.c | 4 +--- 16 files changed, 13 insertions(+), 39 deletions(-) diff --git a/Zend/zend_API.c b/Zend/zend_API.c index e9a297fd45..d72738eddb 100644 --- a/Zend/zend_API.c +++ b/Zend/zend_API.c @@ -506,7 +506,7 @@ static const char *zend_parse_arg_impl(int arg_num, zval *arg, va_list *va, cons ZVAL_DEREF(arg); while (1) { if (*spec_walk == '/') { - SEPARATE_ZVAL(arg); + SEPARATE_ZVAL_NOREF(arg); real_arg = arg; } else if (*spec_walk == '!') { check_null = 1; diff --git a/ext/hash/hash.c b/ext/hash/hash.c index abbe90c750..c1a94c2d09 100644 --- a/ext/hash/hash.c +++ b/ext/hash/hash.c @@ -849,9 +849,7 @@ PHP_FUNCTION(mhash) return; } - SEPARATE_ZVAL(z_algorithm); - convert_to_long_ex(z_algorithm); - algorithm = Z_LVAL_P(z_algorithm); + algorithm = zval_get_long(z_algorithm); /* need to convert the first parameter from int constant to string algorithm name */ if (algorithm >= 0 && algorithm < MHASH_NUM_ALGOS) { diff --git a/ext/intl/formatter/formatter_format.c b/ext/intl/formatter/formatter_format.c index 5307e426eb..369756ebdb 100644 --- a/ext/intl/formatter/formatter_format.c +++ b/ext/intl/formatter/formatter_format.c @@ -68,7 +68,6 @@ PHP_FUNCTION( numfmt_format ) } if(Z_TYPE_P(number) != IS_DOUBLE && Z_TYPE_P(number) != IS_LONG) { - SEPARATE_ZVAL_IF_NOT_REF(number); convert_scalar_to_number(number ); } diff --git a/ext/intl/grapheme/grapheme_string.c b/ext/intl/grapheme/grapheme_string.c index b5a1902025..c38d51aa78 100644 --- a/ext/intl/grapheme/grapheme_string.c +++ b/ext/intl/grapheme/grapheme_string.c @@ -810,7 +810,7 @@ PHP_FUNCTION(grapheme_extract) } else { ZVAL_DEREF(next); /* initialize next */ - SEPARATE_ZVAL(next); + SEPARATE_ZVAL_NOREF(next); zval_dtor(next); ZVAL_LONG(next, lstart); } diff --git a/ext/intl/transliterator/transliterator_methods.c b/ext/intl/transliterator/transliterator_methods.c index e7b0870891..f0e5dcd2e8 100644 --- a/ext/intl/transliterator/transliterator_methods.c +++ b/ext/intl/transliterator/transliterator_methods.c @@ -332,7 +332,6 @@ PHP_FUNCTION( transliterator_transliterate ) int res; if(Z_TYPE_P( arg1 ) != IS_STRING ) { - SEPARATE_ZVAL( arg1 ); convert_to_string( arg1 ); } object = &tmp_object; diff --git a/ext/ldap/ldap.c b/ext/ldap/ldap.c index ca37e146e7..e0faf24b16 100644 --- a/ext/ldap/ldap.c +++ b/ext/ldap/ldap.c @@ -730,7 +730,6 @@ static void php_ldap_do_search(INTERNAL_FUNCTION_PARAMETERS, int scope) goto cleanup; } - SEPARATE_ZVAL(attr); convert_to_string_ex(attr); ldap_attrs[i] = Z_STRVAL_P(attr); } diff --git a/ext/libxml/libxml.c b/ext/libxml/libxml.c index edb1d3119a..aa87dc8acc 100644 --- a/ext/libxml/libxml.c +++ b/ext/libxml/libxml.c @@ -664,7 +664,6 @@ is_string: } } else if (Z_TYPE(retval) != IS_NULL) { /* retval not string nor resource nor null; convert to string */ - SEPARATE_ZVAL(&retval); convert_to_string(&retval); goto is_string; } /* else is null; don't try anything */ diff --git a/ext/pcntl/pcntl.c b/ext/pcntl/pcntl.c index 2c2f41026d..c067d10387 100644 --- a/ext/pcntl/pcntl.c +++ b/ext/pcntl/pcntl.c @@ -1040,11 +1040,7 @@ PHP_FUNCTION(pcntl_sigprocmask) } ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(user_set), user_signo) { - if (Z_TYPE_P(user_signo) != IS_LONG) { - SEPARATE_ZVAL(user_signo); - convert_to_long_ex(user_signo); - } - signo = Z_LVAL_P(user_signo); + signo = zval_get_long(user_signo); if (sigaddset(&set, signo) != 0) { PCNTL_G(last_error) = errno; php_error_docref(NULL, E_WARNING, "%s", strerror(errno)); @@ -1105,11 +1101,7 @@ static void pcntl_sigwaitinfo(INTERNAL_FUNCTION_PARAMETERS, int timedwait) /* {{ } ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(user_set), user_signo) { - if (Z_TYPE_P(user_signo) != IS_LONG) { - SEPARATE_ZVAL(user_signo); - convert_to_long_ex(user_signo); - } - signo = Z_LVAL_P(user_signo); + signo = zval_get_long(user_signo); if (sigaddset(&set, signo) != 0) { PCNTL_G(last_error) = errno; php_error_docref(NULL, E_WARNING, "%s", strerror(errno)); diff --git a/ext/pcre/php_pcre.c b/ext/pcre/php_pcre.c index 3ec6e625a0..66ee238dc4 100644 --- a/ext/pcre/php_pcre.c +++ b/ext/pcre/php_pcre.c @@ -1446,12 +1446,10 @@ static int preg_replace_impl(zval *return_value, zval *regex, zval *replace, zva int replace_count = 0, old_replace_count; if (Z_TYPE_P(replace) != IS_ARRAY && (Z_TYPE_P(replace) != IS_OBJECT || !is_callable_replace)) { - SEPARATE_ZVAL(replace); convert_to_string_ex(replace); } if (Z_TYPE_P(regex) != IS_ARRAY) { - SEPARATE_ZVAL(regex); convert_to_string_ex(regex); } diff --git a/ext/pdo_pgsql/pgsql_statement.c b/ext/pdo_pgsql/pgsql_statement.c index 1e211733e7..de5e0928f7 100644 --- a/ext/pdo_pgsql/pgsql_statement.c +++ b/ext/pdo_pgsql/pgsql_statement.c @@ -376,10 +376,10 @@ static int pgsql_stmt_param_hook(pdo_stmt_t *stmt, struct pdo_bound_param_data * /* We need to manually convert to a pg native boolean value */ if (PDO_PARAM_TYPE(param->param_type) == PDO_PARAM_BOOL && ((param->param_type & PDO_PARAM_INPUT_OUTPUT) != PDO_PARAM_INPUT_OUTPUT)) { - SEPARATE_ZVAL(¶m->parameter); + const char *s = zend_is_true(¶m->parameter) ? "t" : "f"; param->param_type = PDO_PARAM_STR; - convert_to_boolean(¶m->parameter); - ZVAL_STRINGL(¶m->parameter, Z_TYPE_P(¶m->parameter) == IS_TRUE ? "t" : "f", 1); + zval_ptr_dtor(¶m->parameter); + ZVAL_STRINGL(¶m->parameter, s, 1); } } return 1; diff --git a/ext/standard/array.c b/ext/standard/array.c index 59e957d3cd..b9d39ea1a2 100644 --- a/ext/standard/array.c +++ b/ext/standard/array.c @@ -1455,12 +1455,9 @@ static int php_array_walk(HashTable *target_hash, zval *userdata, int recursive) zend_fcall_info orig_array_walk_fci; zend_fcall_info_cache orig_array_walk_fci_cache; - if (Z_ISREF_P(zv)) { - thash = Z_ARRVAL_P(Z_REFVAL_P(zv)); - } else { - SEPARATE_ZVAL(zv); - thash = Z_ARRVAL_P(zv); - } + ZVAL_DEREF(zv); + SEPARATE_ARRAY(zv); + thash = Z_ARRVAL_P(zv); if (thash->u.v.nApplyCount > 1) { php_error_docref(NULL, E_WARNING, "recursion detected"); if (userdata) { diff --git a/ext/standard/formatted_print.c b/ext/standard/formatted_print.c index e8bce6fa3f..081dfc4a07 100644 --- a/ext/standard/formatted_print.c +++ b/ext/standard/formatted_print.c @@ -420,7 +420,6 @@ php_formatted_print(zend_execute_data *execute_data, int use_array, int format_o z_format = &args[format_offset]; array = &args[1 + format_offset]; if (Z_TYPE_P(array) != IS_ARRAY) { - SEPARATE_ZVAL(array); convert_to_array(array); } diff --git a/ext/standard/string.c b/ext/standard/string.c index 7e1408af69..2200762dea 100644 --- a/ext/standard/string.c +++ b/ext/standard/string.c @@ -3973,7 +3973,6 @@ static zend_long php_str_replace_in_subject(zval *search, zval *replace, zval *s ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(search), search_entry) { /* Make sure we're dealing with strings. */ ZVAL_DEREF(search_entry); - SEPARATE_ZVAL_NOREF(search_entry); convert_to_string(search_entry); if (Z_STRLEN_P(search_entry) == 0) { if (Z_TYPE_P(replace) == IS_ARRAY) { diff --git a/ext/xsl/xsltprocessor.c b/ext/xsl/xsltprocessor.c index ee52336c4e..ffd0552263 100644 --- a/ext/xsl/xsltprocessor.c +++ b/ext/xsl/xsltprocessor.c @@ -153,7 +153,6 @@ static char **php_xsl_xslt_make_params(HashTable *parht, int xpath_params) return NULL; } else { if (Z_TYPE_P(value) != IS_STRING) { - SEPARATE_ZVAL(value); convert_to_string(value); } @@ -762,7 +761,6 @@ PHP_FUNCTION(xsl_xsltprocessor_set_parameter) php_error_docref(NULL, E_WARNING, "Invalid parameter array"); RETURN_FALSE; } - SEPARATE_ZVAL(entry); convert_to_string_ex(entry); if (Z_REFCOUNTED_P(entry)) { Z_ADDREF_P(entry); @@ -850,7 +848,6 @@ PHP_FUNCTION(xsl_xsltprocessor_register_php_functions) intern = Z_XSL_P(id); ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(array_value), entry) { - SEPARATE_ZVAL(entry); convert_to_string_ex(entry); ZVAL_LONG(&new_string ,1); zend_hash_update(intern->registered_phpfunctions, Z_STR_P(entry), &new_string); diff --git a/main/php_variables.c b/main/php_variables.c index 173d6b075d..2dac0ed0ea 100644 --- a/main/php_variables.c +++ b/main/php_variables.c @@ -649,7 +649,7 @@ static void php_autoglobal_merge(HashTable *dest, HashTable *src) zend_hash_index_update(dest, num_key, src_entry); } } else { - SEPARATE_ZVAL(dest_entry); + SEPARATE_ARRAY(dest_entry); php_autoglobal_merge(Z_ARRVAL_P(dest_entry), Z_ARRVAL_P(src_entry)); } } ZEND_HASH_FOREACH_END(); diff --git a/main/streams/userspace.c b/main/streams/userspace.c index b73db20d40..9bbf5b0c4e 100644 --- a/main/streams/userspace.c +++ b/main/streams/userspace.c @@ -840,9 +840,7 @@ static int statbuf_from_array(zval *array, php_stream_statbuf *ssb) #define STAT_PROP_ENTRY_EX(name, name2) \ if (NULL != (elem = zend_hash_str_find(Z_ARRVAL_P(array), #name, sizeof(#name)-1))) { \ - SEPARATE_ZVAL(elem); \ - convert_to_long(elem); \ - ssb->sb.st_##name2 = Z_LVAL_P(elem); \ + ssb->sb.st_##name2 = zval_get_long(elem); \ } #define STAT_PROP_ENTRY(name) STAT_PROP_ENTRY_EX(name,name) -- 2.40.0