Skip to content

Commit f1b4e12

Browse files
committed
Simplify bcmath_check_scale()
The scale is default-initialized to 0, so we can simplify the code a bit.
1 parent 94ecc1f commit f1b4e12

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

ext/bcmath/bcmath.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1305,9 +1305,9 @@ static zend_always_inline zend_result bc_num_from_obj_or_str_or_long_with_err(
13051305
return SUCCESS;
13061306
}
13071307

1308-
static zend_always_inline zend_result bcmath_check_scale(zend_long scale, bool scale_is_null, uint32_t arg_num)
1308+
static zend_always_inline zend_result bcmath_check_scale(zend_long scale, uint32_t arg_num)
13091309
{
1310-
if (UNEXPECTED(!scale_is_null && (scale < 0 || scale > INT_MAX))) {
1310+
if (UNEXPECTED(scale < 0 || scale > INT_MAX)) {
13111311
zend_argument_value_error(arg_num, "must be between 0 and %d", INT_MAX);
13121312
return FAILURE;
13131313
}
@@ -1359,7 +1359,7 @@ static void bcmath_number_calc_method(INTERNAL_FUNCTION_PARAMETERS, uint8_t opco
13591359
if (bc_num_from_obj_or_str_or_long_with_err(&num, &num_full_scale, num_obj, num_str, num_lval, 1) == FAILURE) {
13601360
goto fail;
13611361
}
1362-
if (bcmath_check_scale(scale_lval, scale_is_null, 2) == FAILURE) {
1362+
if (bcmath_check_scale(scale_lval, 2) == FAILURE) {
13631363
goto fail;
13641364
}
13651365

@@ -1469,7 +1469,7 @@ PHP_METHOD(BcMath_Number, powmod)
14691469
if (bc_num_from_obj_or_str_or_long_with_err(&modulus_num, NULL, modulus_obj, modulus_str, modulus_lval, 2) == FAILURE) {
14701470
goto cleanup;
14711471
}
1472-
if (bcmath_check_scale(scale_lval, scale_is_null, 3) == FAILURE) {
1472+
if (bcmath_check_scale(scale_lval, 3) == FAILURE) {
14731473
goto cleanup;
14741474
}
14751475

@@ -1530,7 +1530,7 @@ PHP_METHOD(BcMath_Number, sqrt)
15301530
Z_PARAM_LONG_OR_NULL(scale_lval, scale_is_null);
15311531
ZEND_PARSE_PARAMETERS_END();
15321532

1533-
if (bcmath_check_scale(scale_lval, scale_is_null, 1) == FAILURE) {
1533+
if (bcmath_check_scale(scale_lval, 1) == FAILURE) {
15341534
RETURN_THROWS();
15351535
}
15361536

@@ -1584,7 +1584,7 @@ PHP_METHOD(BcMath_Number, compare)
15841584
if (bc_num_from_obj_or_str_or_long_with_err(&num, &num_full_scale, num_obj, num_str, num_lval, 1) == FAILURE) {
15851585
goto fail;
15861586
}
1587-
if (bcmath_check_scale(scale_lval, scale_is_null, 2) == FAILURE) {
1587+
if (bcmath_check_scale(scale_lval, 2) == FAILURE) {
15881588
goto fail;
15891589
}
15901590

0 commit comments

Comments
 (0)