From ce0050378cedf332ca64836a28bea7fcb1ef4df3 Mon Sep 17 00:00:00 2001 From: Yurun Date: Fri, 17 Jun 2022 21:30:49 +0800 Subject: [PATCH 1/2] Replace the use of ZVAL_BOOL() with ZVAL_TRUE() or ZVAL_FALSE() where the value is fixed --- build/gen_stub.php | 3 ++- ext/dba/dba.c | 2 +- ext/dom/php_dom_arginfo.h | 2 +- ext/oci8/oci8_statement.c | 4 ++-- ext/soap/soap_arginfo.h | 8 ++++---- 5 files changed, 10 insertions(+), 9 deletions(-) diff --git a/build/gen_stub.php b/build/gen_stub.php index 4fbda773d5a3d..7841cdb861c15 100755 --- a/build/gen_stub.php +++ b/build/gen_stub.php @@ -1640,7 +1640,8 @@ public function initializeZval(string $zvalName, iterable $allConstInfos): strin if ($this->type->isNull()) { $code .= "\tZVAL_NULL(&$zvalName);\n"; } elseif ($this->type->isBool()) { - $code .= "\tZVAL_BOOL(&$zvalName, " . ($cConstValue ?: ($this->value ? "true" : "false")) . ");\n"; + $boolType = $this->value ? 'TRUE' : 'FALSE'; + $code .= "\tZVAL_$boolType(&$zvalName);\n"; } elseif ($this->type->isInt()) { $code .= "\tZVAL_LONG(&$zvalName, " . ($cConstValue ?: $this->value) . ");\n"; } elseif ($this->type->isFloat()) { diff --git a/ext/dba/dba.c b/ext/dba/dba.c index 842f85d73dcdb..c8dec94501542 100644 --- a/ext/dba/dba.c +++ b/ext/dba/dba.c @@ -1000,7 +1000,7 @@ PHP_FUNCTION(dba_key_split) } if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS(), "z", &zkey) == SUCCESS) { if (Z_TYPE_P(zkey) == IS_NULL || (Z_TYPE_P(zkey) == IS_FALSE)) { - RETURN_BOOL(0); + RETURN_FALSE; } } if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &key, &key_len) == FAILURE) { diff --git a/ext/dom/php_dom_arginfo.h b/ext/dom/php_dom_arginfo.h index 3842c59fea8da..f1af18e8f6050 100644 --- a/ext/dom/php_dom_arginfo.h +++ b/ext/dom/php_dom_arginfo.h @@ -1312,7 +1312,7 @@ static zend_class_entry *register_class_DOMAttr(zend_class_entry *class_entry_DO zend_string_release(property_name_name); zval property_specified_default_value; - ZVAL_BOOL(&property_specified_default_value, true); + ZVAL_TRUE(&property_specified_default_value); zend_string *property_specified_name = zend_string_init("specified", sizeof("specified") - 1, 1); zend_declare_typed_property(class_entry, property_specified_name, &property_specified_default_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_BOOL)); zend_string_release(property_specified_name); diff --git a/ext/oci8/oci8_statement.c b/ext/oci8/oci8_statement.c index ca7ef1c8cd50f..91bba23127b12 100644 --- a/ext/oci8/oci8_statement.c +++ b/ext/oci8/oci8_statement.c @@ -1105,9 +1105,9 @@ int php_oci_bind_post_exec(zval *data) } else if ((Z_TYPE_P(zv) == IS_TRUE) || (Z_TYPE_P(zv) == IS_FALSE)) { /* This convetrsion is done on purpose (ext/oci8 uses LVAL as a temporary value) */ if (Z_LVAL_P(zv) == 0) - ZVAL_BOOL(zv, FALSE); + ZVAL_FALSE(zv); else if (Z_LVAL_P(zv) == 1) - ZVAL_BOOL(zv, TRUE); + ZVAL_TRUE(zv); } return 0; diff --git a/ext/soap/soap_arginfo.h b/ext/soap/soap_arginfo.h index d5ebdcfeac1de..eed9247072cd5 100644 --- a/ext/soap/soap_arginfo.h +++ b/ext/soap/soap_arginfo.h @@ -442,7 +442,7 @@ static zend_class_entry *register_class_SoapClient(void) zend_string_release(property_location_name); zval property_trace_default_value; - ZVAL_BOOL(&property_trace_default_value, false); + ZVAL_FALSE(&property_trace_default_value); zend_string *property_trace_name = zend_string_init("trace", sizeof("trace") - 1, 1); zend_declare_typed_property(class_entry, property_trace_name, &property_trace_default_value, ZEND_ACC_PRIVATE, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_BOOL)); zend_string_release(property_trace_name); @@ -490,7 +490,7 @@ static zend_class_entry *register_class_SoapClient(void) zend_string_release(property__password_name); zval property__use_digest_default_value; - ZVAL_BOOL(&property__use_digest_default_value, false); + ZVAL_FALSE(&property__use_digest_default_value); zend_string *property__use_digest_name = zend_string_init("_use_digest", sizeof("_use_digest") - 1, 1); zend_declare_typed_property(class_entry, property__use_digest_name, &property__use_digest_default_value, ZEND_ACC_PRIVATE, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_BOOL)); zend_string_release(property__use_digest_name); @@ -526,7 +526,7 @@ static zend_class_entry *register_class_SoapClient(void) zend_string_release(property__proxy_password_name); zval property__exceptions_default_value; - ZVAL_BOOL(&property__exceptions_default_value, true); + ZVAL_TRUE(&property__exceptions_default_value); zend_string *property__exceptions_name = zend_string_init("_exceptions", sizeof("_exceptions") - 1, 1); zend_declare_typed_property(class_entry, property__exceptions_name, &property__exceptions_default_value, ZEND_ACC_PRIVATE, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_BOOL)); zend_string_release(property__exceptions_name); @@ -568,7 +568,7 @@ static zend_class_entry *register_class_SoapClient(void) zend_string_release(property__user_agent_name); zval property__keep_alive_default_value; - ZVAL_BOOL(&property__keep_alive_default_value, true); + ZVAL_TRUE(&property__keep_alive_default_value); zend_string *property__keep_alive_name = zend_string_init("_keep_alive", sizeof("_keep_alive") - 1, 1); zend_declare_typed_property(class_entry, property__keep_alive_name, &property__keep_alive_default_value, ZEND_ACC_PRIVATE, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_BOOL)); zend_string_release(property__keep_alive_name); From 848b9bd2917eabfa8af9e73a8dcede681dd25f03 Mon Sep 17 00:00:00 2001 From: Yurun Date: Mon, 20 Jun 2022 09:38:01 +0800 Subject: [PATCH 2/2] Update --- build/gen_stub.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/build/gen_stub.php b/build/gen_stub.php index 7841cdb861c15..0b0ca4113ca44 100755 --- a/build/gen_stub.php +++ b/build/gen_stub.php @@ -1640,8 +1640,7 @@ public function initializeZval(string $zvalName, iterable $allConstInfos): strin if ($this->type->isNull()) { $code .= "\tZVAL_NULL(&$zvalName);\n"; } elseif ($this->type->isBool()) { - $boolType = $this->value ? 'TRUE' : 'FALSE'; - $code .= "\tZVAL_$boolType(&$zvalName);\n"; + $code .= "\t" . ($this->value ? 'ZVAL_TRUE' : 'ZVAL_FALSE') . "(&$zvalName);\n"; } elseif ($this->type->isInt()) { $code .= "\tZVAL_LONG(&$zvalName, " . ($cConstValue ?: $this->value) . ");\n"; } elseif ($this->type->isFloat()) {