[php-src] master: Slightly clean up error_reporting() implementation
| From: | Nikita Popov | Date: | Fri, 23 Apr 2021 15:11:33 +0000 |
| Subject: | [php-src] master: Slightly clean up error_reporting() implementation | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-115793@lists.php.net to get a copy of this message | ||
Author: Nikita Popov (nikic)
Date: 2021-04-23T17:11:35+02:00
Commit: https://github.com/php/php-src/commit/0c3f70730bc7f2ede35f59394f6f4f79c3d5b0f7
Raw diff: https://github.com/php/php-src/commit/0c3f70730bc7f2ede35f59394f6f4f79c3d5b0f7.diff
Slightly clean up error_reporting() implementation
zend_long_to_str() cannot throw, and we don't really need the
do/while block either.
Changed paths:
M Zend/zend_builtin_functions.c
Diff:
diff --git a/Zend/zend_builtin_functions.c b/Zend/zend_builtin_functions.c
index 55a1357e2bba..53f64b3470bc 100644
--- a/Zend/zend_builtin_functions.c
+++ b/Zend/zend_builtin_functions.c
@@ -379,42 +379,36 @@ ZEND_FUNCTION(error_reporting)
old_error_reporting = EG(error_reporting);
if (!err_is_null && err != old_error_reporting) {
- zend_string *new_val = zend_long_to_str(err);
- if (UNEXPECTED(!new_val)) {
- RETURN_THROWS();
- }
+ zend_ini_entry *p = EG(error_reporting_ini_entry);
- do {
- zend_ini_entry *p = EG(error_reporting_ini_entry);
+ if (!p) {
+ zval *zv = zend_hash_find_ex(EG(ini_directives), ZSTR_KNOWN(ZEND_STR_ERROR_REPORTING), 1);
+ if (!zv) {
+ /* Ini setting does not exist -- can this happen? */
+ RETURN_LONG(old_error_reporting);
+ }
- if (!p) {
- zval *zv = zend_hash_find_ex(EG(ini_directives), ZSTR_KNOWN(ZEND_STR_ERROR_REPORTING), 1);
- if (zv) {
- p = EG(error_reporting_ini_entry) = (zend_ini_entry*)Z_PTR_P(zv);
- } else {
- break;
- }
+ p = EG(error_reporting_ini_entry) = (zend_ini_entry*)Z_PTR_P(zv);
+ }
+ if (!p->modified) {
+ if (!EG(modified_ini_directives)) {
+ ALLOC_HASHTABLE(EG(modified_ini_directives));
+ zend_hash_init(EG(modified_ini_directives), 8, NULL, NULL, 0);
}
- if (!p->modified) {
- if (!EG(modified_ini_directives)) {
- ALLOC_HASHTABLE(EG(modified_ini_directives));
- zend_hash_init(EG(modified_ini_directives), 8, NULL, NULL, 0);
- }
- if (EXPECTED(zend_hash_add_ptr(EG(modified_ini_directives),
ZSTR_KNOWN(ZEND_STR_ERROR_REPORTING), p) != NULL)) {
- p->orig_value = p->value;
- p->orig_modifiable = p->modifiable;
- p->modified = 1;
- }
- } else if (p->orig_value != p->value) {
- zend_string_release_ex(p->value, 0);
+ if (EXPECTED(zend_hash_add_ptr(EG(modified_ini_directives),
ZSTR_KNOWN(ZEND_STR_ERROR_REPORTING), p) != NULL)) {
+ p->orig_value = p->value;
+ p->orig_modifiable = p->modifiable;
+ p->modified = 1;
}
+ } else if (p->orig_value != p->value) {
+ zend_string_release_ex(p->value, 0);
+ }
- p->value = new_val;
- EG(error_reporting) = err;
- } while (0);
+ p->value = zend_long_to_str(err);
+ EG(error_reporting) = err;
}
- RETVAL_LONG(old_error_reporting);
+ RETURN_LONG(old_error_reporting);
}
/* }}} */