Skip to content

Commit 9c0fa41

Browse files
committed
Make error paths to be UNEXPECTED
1 parent 2c8ac3a commit 9c0fa41

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

Zend/zend_execute.c

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -667,17 +667,17 @@ static inline void zend_assign_to_object(zval *retval, zval *object_ptr, zval *p
667667
zval *object = object_ptr;
668668

669669
ZVAL_DEREF(object);
670-
if (Z_TYPE_P(object) != IS_OBJECT) {
671-
if (object == &EG(error_zval)) {
670+
if (UNEXPECTED(Z_TYPE_P(object) != IS_OBJECT)) {
671+
if (UNEXPECTED(object == &EG(error_zval))) {
672672
if (retval) {
673673
ZVAL_NULL(retval);
674674
}
675675
FREE_OP(free_value);
676676
return;
677677
}
678-
if (Z_TYPE_P(object) == IS_NULL ||
678+
if (EXPECTED(Z_TYPE_P(object) == IS_NULL ||
679679
Z_TYPE_P(object) == IS_FALSE ||
680-
(Z_TYPE_P(object) == IS_STRING && Z_STRLEN_P(object) == 0)) {
680+
(Z_TYPE_P(object) == IS_STRING && Z_STRLEN_P(object) == 0))) {
681681
zend_object *obj;
682682

683683
zval_ptr_dtor(object);
@@ -1021,7 +1021,7 @@ static zend_always_inline zval *zend_fetch_dimension_address(zval *result, zval
10211021
fetch_from_array:
10221022
if (dim == NULL) {
10231023
retval = zend_hash_next_index_insert(Z_ARRVAL_P(container), &EG(uninitialized_zval));
1024-
if (retval == NULL) {
1024+
if (UNEXPECTED(retval == NULL)) {
10251025
zend_error(E_WARNING, "Cannot add element to the array as the next element is already occupied");
10261026
retval = &EG(error_zval);
10271027
}
@@ -1100,7 +1100,7 @@ static zend_always_inline zval *zend_fetch_dimension_address(zval *result, zval
11001100

11011101
ZVAL_NULL(result);
11021102
zend_error(E_NOTICE, "Indirect modification of overloaded element of %s has no effect", ce->name->val);
1103-
} else if (retval && Z_TYPE_P(retval) != IS_UNDEF) {
1103+
} else if (EXPECTED(retval && Z_TYPE_P(retval) != IS_UNDEF)) {
11041104
if (!Z_ISREF_P(retval)) {
11051105
if (Z_REFCOUNTED_P(retval) &&
11061106
Z_REFCOUNT_P(retval) > 1) {
@@ -1132,7 +1132,7 @@ static zend_always_inline zval *zend_fetch_dimension_address(zval *result, zval
11321132
}
11331133
}
11341134
} else if (EXPECTED(Z_TYPE_P(container) == IS_NULL)) {
1135-
if (container == &EG(error_zval)) {
1135+
if (UNEXPECTED(container == &EG(error_zval))) {
11361136
ZVAL_INDIRECT(result, &EG(error_zval));
11371137
} else if (type != BP_VAR_UNSET) {
11381138
goto convert_to_array;
@@ -1276,15 +1276,15 @@ static void zend_fetch_property_address(zval *result, zval *container_ptr, zval
12761276
zval *container = container_ptr;
12771277

12781278
ZVAL_DEREF(container);
1279-
if (Z_TYPE_P(container) != IS_OBJECT) {
1280-
if (container == &EG(error_zval)) {
1279+
if (UNEXPECTED(Z_TYPE_P(container) != IS_OBJECT)) {
1280+
if (UNEXPECTED(container == &EG(error_zval))) {
12811281
ZVAL_INDIRECT(result, &EG(error_zval));
12821282
return;
12831283
}
12841284

12851285
/* this should modify object only if it's empty */
12861286
if (type != BP_VAR_UNSET &&
1287-
((Z_TYPE_P(container) == IS_NULL ||
1287+
EXPECTED((Z_TYPE_P(container) == IS_NULL ||
12881288
Z_TYPE_P(container) == IS_FALSE ||
12891289
(Z_TYPE_P(container) == IS_STRING && Z_STRLEN_P(container)==0)))) {
12901290
zval_ptr_dtor_nogc(container);
@@ -1296,7 +1296,7 @@ static void zend_fetch_property_address(zval *result, zval *container_ptr, zval
12961296
}
12971297
}
12981298

1299-
if (Z_OBJ_HT_P(container)->get_property_ptr_ptr) {
1299+
if (EXPECTED(Z_OBJ_HT_P(container)->get_property_ptr_ptr)) {
13001300
zval *ptr = Z_OBJ_HT_P(container)->get_property_ptr_ptr(container, prop_ptr, type, cache_slot TSRMLS_CC);
13011301
if (NULL == ptr) {
13021302
if (Z_OBJ_HT_P(container)->read_property &&
@@ -1322,7 +1322,7 @@ static void zend_fetch_property_address(zval *result, zval *container_ptr, zval
13221322
ZVAL_INDIRECT(result, ptr);
13231323
}
13241324
}
1325-
} else if (Z_OBJ_HT_P(container)->read_property) {
1325+
} else if (EXPECTED(Z_OBJ_HT_P(container)->read_property)) {
13261326
zval *ptr = Z_OBJ_HT_P(container)->read_property(container, prop_ptr, type, cache_slot, result TSRMLS_CC);
13271327
if (ptr != result) {
13281328
if (is_ref && ptr != &EG(uninitialized_zval)) {

0 commit comments

Comments
 (0)