1
0
mirror of https://github.com/php/php-src.git synced 2026-04-30 03:33:17 +02:00

Remove Z_PARAM separate params where they don't make sense

Separation can only possibly make sense for array parameters
(or something that can contain arrays, like zval parameters). It
never makes sense to separate a bool.

The deref parameters are also of dubious utility, but leaving them
for now.
This commit is contained in:
Nikita Popov
2021-01-14 11:58:08 +01:00
parent ec58a6f1b0
commit 1b2aba285d
7 changed files with 39 additions and 81 deletions
+30 -72
View File
@@ -1415,17 +1415,14 @@ ZEND_API ZEND_COLD void zend_argument_value_error(uint32_t arg_num, const char *
Z_PARAM_ITERABLE_EX(dest, 1)
/* old "b" */
#define Z_PARAM_BOOL_EX2(dest, is_null, check_null, deref, separate) \
Z_PARAM_PROLOGUE(deref, separate); \
#define Z_PARAM_BOOL_EX(dest, is_null, check_null, deref) \
Z_PARAM_PROLOGUE(deref, 0); \
if (UNEXPECTED(!zend_parse_arg_bool(_arg, &dest, &is_null, check_null))) { \
_expected_type = check_null ? Z_EXPECTED_BOOL_OR_NULL : Z_EXPECTED_BOOL; \
_error_code = ZPP_ERROR_WRONG_ARG; \
break; \
}
#define Z_PARAM_BOOL_EX(dest, is_null, check_null, separate) \
Z_PARAM_BOOL_EX2(dest, is_null, check_null, separate, separate)
#define Z_PARAM_BOOL(dest) \
Z_PARAM_BOOL_EX(dest, _dummy, 0, 0)
@@ -1433,16 +1430,13 @@ ZEND_API ZEND_COLD void zend_argument_value_error(uint32_t arg_num, const char *
Z_PARAM_BOOL_EX(dest, is_null, 1, 0)
/* old "C" */
#define Z_PARAM_CLASS_EX2(dest, check_null, deref, separate) \
Z_PARAM_PROLOGUE(deref, separate); \
#define Z_PARAM_CLASS_EX(dest, check_null, deref) \
Z_PARAM_PROLOGUE(deref, 0); \
if (UNEXPECTED(!zend_parse_arg_class(_arg, &dest, _i, check_null))) { \
_error_code = ZPP_ERROR_FAILURE; \
break; \
}
#define Z_PARAM_CLASS_EX(dest, check_null, separate) \
Z_PARAM_CLASS_EX2(dest, check_null, separate, separate)
#define Z_PARAM_CLASS(dest) \
Z_PARAM_CLASS_EX(dest, 0, 0)
@@ -1498,17 +1492,14 @@ ZEND_API ZEND_COLD void zend_argument_value_error(uint32_t arg_num, const char *
Z_PARAM_OBJ_OF_CLASS_OR_STR_EX(destination_object, base_ce, destination_string, 1);
/* old "d" */
#define Z_PARAM_DOUBLE_EX2(dest, is_null, check_null, deref, separate) \
Z_PARAM_PROLOGUE(deref, separate); \
#define Z_PARAM_DOUBLE_EX(dest, is_null, check_null, deref) \
Z_PARAM_PROLOGUE(deref, 0); \
if (UNEXPECTED(!zend_parse_arg_double(_arg, &dest, &is_null, check_null))) { \
_expected_type = check_null ? Z_EXPECTED_DOUBLE_OR_NULL : Z_EXPECTED_DOUBLE; \
_error_code = ZPP_ERROR_WRONG_ARG; \
break; \
}
#define Z_PARAM_DOUBLE_EX(dest, is_null, check_null, separate) \
Z_PARAM_DOUBLE_EX2(dest, is_null, check_null, separate, separate)
#define Z_PARAM_DOUBLE(dest) \
Z_PARAM_DOUBLE_EX(dest, _dummy, 0, 0)
@@ -1516,8 +1507,8 @@ ZEND_API ZEND_COLD void zend_argument_value_error(uint32_t arg_num, const char *
Z_PARAM_DOUBLE_EX(dest, is_null, 1, 0)
/* old "f" */
#define Z_PARAM_FUNC_EX2(dest_fci, dest_fcc, check_null, deref, separate) \
Z_PARAM_PROLOGUE(deref, separate); \
#define Z_PARAM_FUNC_EX(dest_fci, dest_fcc, check_null, deref) \
Z_PARAM_PROLOGUE(deref, 0); \
if (UNEXPECTED(!zend_parse_arg_func(_arg, &dest_fci, &dest_fcc, check_null, &_error))) { \
if (!_error) { \
_expected_type = check_null ? Z_EXPECTED_FUNC_OR_NULL : Z_EXPECTED_FUNC; \
@@ -1528,9 +1519,6 @@ ZEND_API ZEND_COLD void zend_argument_value_error(uint32_t arg_num, const char *
break; \
} \
#define Z_PARAM_FUNC_EX(dest_fci, dest_fcc, check_null, separate) \
Z_PARAM_FUNC_EX2(dest_fci, dest_fcc, check_null, separate, separate)
#define Z_PARAM_FUNC(dest_fci, dest_fcc) \
Z_PARAM_FUNC_EX(dest_fci, dest_fcc, 0, 0)
@@ -1585,17 +1573,14 @@ ZEND_API ZEND_COLD void zend_argument_value_error(uint32_t arg_num, const char *
Z_PARAM_ARRAY_OR_OBJECT_HT_EX(dest, 0, 0)
/* old "l" */
#define Z_PARAM_LONG_EX2(dest, is_null, check_null, deref, separate) \
Z_PARAM_PROLOGUE(deref, separate); \
#define Z_PARAM_LONG_EX(dest, is_null, check_null, deref) \
Z_PARAM_PROLOGUE(deref, 0); \
if (UNEXPECTED(!zend_parse_arg_long(_arg, &dest, &is_null, check_null))) { \
_expected_type = check_null ? Z_EXPECTED_LONG_OR_NULL : Z_EXPECTED_LONG; \
_error_code = ZPP_ERROR_WRONG_ARG; \
break; \
}
#define Z_PARAM_LONG_EX(dest, is_null, check_null, separate) \
Z_PARAM_LONG_EX2(dest, is_null, check_null, separate, separate)
#define Z_PARAM_LONG(dest) \
Z_PARAM_LONG_EX(dest, _dummy, 0, 0)
@@ -1618,35 +1603,29 @@ ZEND_API ZEND_COLD void zend_argument_value_error(uint32_t arg_num, const char *
Z_PARAM_NUMBER_EX(dest, 0)
/* old "o" */
#define Z_PARAM_OBJECT_EX2(dest, check_null, deref, separate) \
Z_PARAM_PROLOGUE(deref, separate); \
#define Z_PARAM_OBJECT_EX(dest, check_null, deref) \
Z_PARAM_PROLOGUE(deref, 0); \
if (UNEXPECTED(!zend_parse_arg_object(_arg, &dest, NULL, check_null))) { \
_expected_type = check_null ? Z_EXPECTED_OBJECT_OR_NULL : Z_EXPECTED_OBJECT; \
_error_code = ZPP_ERROR_WRONG_ARG; \
break; \
}
#define Z_PARAM_OBJECT_EX(dest, check_null, separate) \
Z_PARAM_OBJECT_EX2(dest, check_null, separate, separate)
#define Z_PARAM_OBJECT(dest) \
Z_PARAM_OBJECT_EX(dest, 0, 0)
#define Z_PARAM_OBJECT_OR_NULL(dest) \
Z_PARAM_OBJECT_EX(dest, 1, 0)
/* The same as Z_PARAM_OBJECT_EX2 except that dest is a zend_object rather than a zval */
#define Z_PARAM_OBJ_EX2(dest, check_null, deref, separate) \
Z_PARAM_PROLOGUE(deref, separate); \
/* The same as Z_PARAM_OBJECT_EX except that dest is a zend_object rather than a zval */
#define Z_PARAM_OBJ_EX(dest, check_null, deref) \
Z_PARAM_PROLOGUE(deref, 0); \
if (UNEXPECTED(!zend_parse_arg_obj(_arg, &dest, NULL, check_null))) { \
_expected_type = check_null ? Z_EXPECTED_OBJECT_OR_NULL : Z_EXPECTED_OBJECT; \
_error_code = ZPP_ERROR_WRONG_ARG; \
break; \
}
#define Z_PARAM_OBJ_EX(dest, check_null, separate) \
Z_PARAM_OBJ_EX2(dest, check_null, separate, separate)
#define Z_PARAM_OBJ(dest) \
Z_PARAM_OBJ_EX(dest, 0, 0)
@@ -1654,8 +1633,8 @@ ZEND_API ZEND_COLD void zend_argument_value_error(uint32_t arg_num, const char *
Z_PARAM_OBJ_EX(dest, 1, 0)
/* old "O" */
#define Z_PARAM_OBJECT_OF_CLASS_EX2(dest, _ce, check_null, deref, separate) \
Z_PARAM_PROLOGUE(deref, separate); \
#define Z_PARAM_OBJECT_OF_CLASS_EX(dest, _ce, check_null, deref) \
Z_PARAM_PROLOGUE(deref, 0); \
if (UNEXPECTED(!zend_parse_arg_object(_arg, &dest, _ce, check_null))) { \
if (_ce) { \
_error = ZSTR_VAL((_ce)->name); \
@@ -1668,18 +1647,15 @@ ZEND_API ZEND_COLD void zend_argument_value_error(uint32_t arg_num, const char *
} \
}
#define Z_PARAM_OBJECT_OF_CLASS_EX(dest, _ce, check_null, separate) \
Z_PARAM_OBJECT_OF_CLASS_EX2(dest, _ce, check_null, separate, separate)
#define Z_PARAM_OBJECT_OF_CLASS(dest, _ce) \
Z_PARAM_OBJECT_OF_CLASS_EX(dest, _ce, 0, 0)
#define Z_PARAM_OBJECT_OF_CLASS_OR_NULL(dest, _ce) \
Z_PARAM_OBJECT_OF_CLASS_EX(dest, _ce, 1, 0)
/* The same as Z_PARAM_OBJECT_OF_CLASS_EX2 except that dest is a zend_object rather than a zval */
#define Z_PARAM_OBJ_OF_CLASS_EX2(dest, _ce, check_null, deref, separate) \
Z_PARAM_PROLOGUE(deref, separate); \
/* The same as Z_PARAM_OBJECT_OF_CLASS_EX except that dest is a zend_object rather than a zval */
#define Z_PARAM_OBJ_OF_CLASS_EX(dest, _ce, check_null, deref) \
Z_PARAM_PROLOGUE(deref, 0); \
if (UNEXPECTED(!zend_parse_arg_obj(_arg, &dest, _ce, check_null))) { \
if (_ce) { \
_error = ZSTR_VAL((_ce)->name); \
@@ -1692,9 +1668,6 @@ ZEND_API ZEND_COLD void zend_argument_value_error(uint32_t arg_num, const char *
} \
}
#define Z_PARAM_OBJ_OF_CLASS_EX(dest, _ce, check_null, separate) \
Z_PARAM_OBJ_OF_CLASS_EX2(dest, _ce, check_null, separate, separate)
#define Z_PARAM_OBJ_OF_CLASS(dest, _ce) \
Z_PARAM_OBJ_OF_CLASS_EX(dest, _ce, 0, 0)
@@ -1716,17 +1689,14 @@ ZEND_API ZEND_COLD void zend_argument_value_error(uint32_t arg_num, const char *
Z_PARAM_OBJ_OF_CLASS_OR_LONG_EX(dest_obj, _ce, dest_long, is_null, 1)
/* old "p" */
#define Z_PARAM_PATH_EX2(dest, dest_len, check_null, deref, separate) \
Z_PARAM_PROLOGUE(deref, separate); \
#define Z_PARAM_PATH_EX(dest, dest_len, check_null, deref) \
Z_PARAM_PROLOGUE(deref, 0); \
if (UNEXPECTED(!zend_parse_arg_path(_arg, &dest, &dest_len, check_null))) { \
_expected_type = check_null ? Z_EXPECTED_PATH_OR_NULL : Z_EXPECTED_PATH; \
_error_code = ZPP_ERROR_WRONG_ARG; \
break; \
}
#define Z_PARAM_PATH_EX(dest, dest_len, check_null, separate) \
Z_PARAM_PATH_EX2(dest, dest_len, check_null, separate, separate)
#define Z_PARAM_PATH(dest, dest_len) \
Z_PARAM_PATH_EX(dest, dest_len, 0, 0)
@@ -1734,17 +1704,14 @@ ZEND_API ZEND_COLD void zend_argument_value_error(uint32_t arg_num, const char *
Z_PARAM_PATH_EX(dest, dest_len, 1, 0)
/* old "P" */
#define Z_PARAM_PATH_STR_EX2(dest, check_null, deref, separate) \
Z_PARAM_PROLOGUE(deref, separate); \
#define Z_PARAM_PATH_STR_EX(dest, check_null, deref) \
Z_PARAM_PROLOGUE(deref, 0); \
if (UNEXPECTED(!zend_parse_arg_path_str(_arg, &dest, check_null))) { \
_expected_type = check_null ? Z_EXPECTED_PATH_OR_NULL : Z_EXPECTED_PATH; \
_error_code = ZPP_ERROR_WRONG_ARG; \
break; \
}
#define Z_PARAM_PATH_STR_EX(dest, check_null, separate) \
Z_PARAM_PATH_STR_EX2(dest, check_null, separate, separate)
#define Z_PARAM_PATH_STR(dest) \
Z_PARAM_PATH_STR_EX(dest, 0, 0)
@@ -1752,17 +1719,14 @@ ZEND_API ZEND_COLD void zend_argument_value_error(uint32_t arg_num, const char *
Z_PARAM_PATH_STR_EX(dest, 1, 0)
/* old "r" */
#define Z_PARAM_RESOURCE_EX2(dest, check_null, deref, separate) \
Z_PARAM_PROLOGUE(deref, separate); \
#define Z_PARAM_RESOURCE_EX(dest, check_null, deref) \
Z_PARAM_PROLOGUE(deref, 0); \
if (UNEXPECTED(!zend_parse_arg_resource(_arg, &dest, check_null))) { \
_expected_type = check_null ? Z_EXPECTED_RESOURCE_OR_NULL : Z_EXPECTED_RESOURCE; \
_error_code = ZPP_ERROR_WRONG_ARG; \
break; \
}
#define Z_PARAM_RESOURCE_EX(dest, check_null, separate) \
Z_PARAM_RESOURCE_EX2(dest, check_null, separate, separate)
#define Z_PARAM_RESOURCE(dest) \
Z_PARAM_RESOURCE_EX(dest, 0, 0)
@@ -1770,17 +1734,14 @@ ZEND_API ZEND_COLD void zend_argument_value_error(uint32_t arg_num, const char *
Z_PARAM_RESOURCE_EX(dest, 1, 0)
/* old "s" */
#define Z_PARAM_STRING_EX2(dest, dest_len, check_null, deref, separate) \
Z_PARAM_PROLOGUE(deref, separate); \
#define Z_PARAM_STRING_EX(dest, dest_len, check_null, deref) \
Z_PARAM_PROLOGUE(deref, 0); \
if (UNEXPECTED(!zend_parse_arg_string(_arg, &dest, &dest_len, check_null))) { \
_expected_type = check_null ? Z_EXPECTED_STRING_OR_NULL : Z_EXPECTED_STRING; \
_error_code = ZPP_ERROR_WRONG_ARG; \
break; \
}
#define Z_PARAM_STRING_EX(dest, dest_len, check_null, separate) \
Z_PARAM_STRING_EX2(dest, dest_len, check_null, separate, separate)
#define Z_PARAM_STRING(dest, dest_len) \
Z_PARAM_STRING_EX(dest, dest_len, 0, 0)
@@ -1788,17 +1749,14 @@ ZEND_API ZEND_COLD void zend_argument_value_error(uint32_t arg_num, const char *
Z_PARAM_STRING_EX(dest, dest_len, 1, 0)
/* old "S" */
#define Z_PARAM_STR_EX2(dest, check_null, deref, separate) \
Z_PARAM_PROLOGUE(deref, separate); \
#define Z_PARAM_STR_EX(dest, check_null, deref) \
Z_PARAM_PROLOGUE(deref, 0); \
if (UNEXPECTED(!zend_parse_arg_str(_arg, &dest, check_null))) { \
_expected_type = check_null ? Z_EXPECTED_STRING_OR_NULL : Z_EXPECTED_STRING; \
_error_code = ZPP_ERROR_WRONG_ARG; \
break; \
}
#define Z_PARAM_STR_EX(dest, check_null, separate) \
Z_PARAM_STR_EX2(dest, check_null, separate, separate)
#define Z_PARAM_STR(dest) \
Z_PARAM_STR_EX(dest, 0, 0)
+1 -1
View File
@@ -4489,7 +4489,7 @@ PHP_FUNCTION(exif_read_data)
ZEND_PARSE_PARAMETERS_START(1, 4)
Z_PARAM_ZVAL(stream)
Z_PARAM_OPTIONAL
Z_PARAM_STR_EX(z_sections_needed, 1, 0)
Z_PARAM_STR_OR_NULL(z_sections_needed)
Z_PARAM_BOOL(sub_arrays)
Z_PARAM_BOOL(read_thumbnail)
ZEND_PARSE_PARAMETERS_END();
+4 -4
View File
@@ -3717,7 +3717,7 @@ ZEND_METHOD(FFI, free) /* {{{ */
ZEND_FFI_VALIDATE_API_RESTRICTION();
ZEND_PARSE_PARAMETERS_START(1, 1)
Z_PARAM_OBJECT_OF_CLASS_EX2(zv, zend_ffi_cdata_ce, 0, 1, 0);
Z_PARAM_OBJECT_OF_CLASS_EX(zv, zend_ffi_cdata_ce, 0, 1);
ZEND_PARSE_PARAMETERS_END();
cdata = (zend_ffi_cdata*)Z_OBJ_P(zv);
@@ -4208,7 +4208,7 @@ ZEND_METHOD(FFI, memcpy) /* {{{ */
ZEND_FFI_VALIDATE_API_RESTRICTION();
ZEND_PARSE_PARAMETERS_START(3, 3)
Z_PARAM_OBJECT_OF_CLASS_EX2(zv1, zend_ffi_cdata_ce, 0, 1, 0);
Z_PARAM_OBJECT_OF_CLASS_EX(zv1, zend_ffi_cdata_ce, 0, 1);
Z_PARAM_ZVAL(zv2)
Z_PARAM_LONG(size)
ZEND_PARSE_PARAMETERS_END();
@@ -4338,7 +4338,7 @@ ZEND_METHOD(FFI, memset) /* {{{ */
ZEND_FFI_VALIDATE_API_RESTRICTION();
ZEND_PARSE_PARAMETERS_START(3, 3)
Z_PARAM_OBJECT_OF_CLASS_EX2(zv, zend_ffi_cdata_ce, 0, 1, 0);
Z_PARAM_OBJECT_OF_CLASS_EX(zv, zend_ffi_cdata_ce, 0, 1);
Z_PARAM_LONG(ch)
Z_PARAM_LONG(size)
ZEND_PARSE_PARAMETERS_END();
@@ -4370,7 +4370,7 @@ ZEND_METHOD(FFI, string) /* {{{ */
ZEND_FFI_VALIDATE_API_RESTRICTION();
ZEND_PARSE_PARAMETERS_START(1, 2)
Z_PARAM_OBJECT_OF_CLASS_EX2(zv, zend_ffi_cdata_ce, 0, 1, 0);
Z_PARAM_OBJECT_OF_CLASS_EX(zv, zend_ffi_cdata_ce, 0, 1);
Z_PARAM_OPTIONAL
Z_PARAM_LONG_OR_NULL(size, size_is_null)
ZEND_PARSE_PARAMETERS_END();
+1 -1
View File
@@ -273,7 +273,7 @@ PHP_FUNCTION(json_decode)
ZEND_PARSE_PARAMETERS_START(1, 4)
Z_PARAM_STRING(str, str_len)
Z_PARAM_OPTIONAL
Z_PARAM_BOOL_EX(assoc, assoc_null, 1, 0)
Z_PARAM_BOOL_OR_NULL(assoc, assoc_null)
Z_PARAM_LONG(depth)
Z_PARAM_LONG(options)
ZEND_PARSE_PARAMETERS_END();
+1 -1
View File
@@ -2728,7 +2728,7 @@ PHP_FUNCTION(preg_quote)
ZEND_PARSE_PARAMETERS_START(1, 2)
Z_PARAM_STR(str)
Z_PARAM_OPTIONAL
Z_PARAM_STR_EX(delim, 1, 0)
Z_PARAM_STR_OR_NULL(delim)
ZEND_PARSE_PARAMETERS_END();
/* Nothing to do if we got an empty string */
+1 -1
View File
@@ -686,7 +686,7 @@ PHP_FUNCTION(get_browser)
ZEND_PARSE_PARAMETERS_START(0, 2)
Z_PARAM_OPTIONAL
Z_PARAM_STR_EX(agent_name, 1, 0)
Z_PARAM_STR_OR_NULL(agent_name)
Z_PARAM_BOOL(return_array)
ZEND_PARSE_PARAMETERS_END();
+1 -1
View File
@@ -1324,7 +1324,7 @@ static void php_html_entities(INTERNAL_FUNCTION_PARAMETERS, int all)
Z_PARAM_STR(str)
Z_PARAM_OPTIONAL
Z_PARAM_LONG(flags)
Z_PARAM_STR_EX(hint_charset, 1, 0)
Z_PARAM_STR_OR_NULL(hint_charset)
Z_PARAM_BOOL(double_encode);
ZEND_PARSE_PARAMETERS_END();