[php-src] master: Remove rscale in bc_raisemod
| From: | Saki Takamachi | Date: | Thu, 11 Apr 2024 00:00:12 +0000 |
| Subject: | [php-src] master: Remove rscale in bc_raisemod | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-128067@lists.php.net to get a copy of this message | ||
Author: Saki Takamachi (SakiTakamachi)
Date: 2024-04-11T08:59:48+09:00
Commit: https://github.com/php/php-src/commit/5d91f8761ba93985891cd6c3181090d56b022f35
Raw diff: https://github.com/php/php-src/commit/5d91f8761ba93985891cd6c3181090d56b022f35.diff
Remove rscale in bc_raisemod
power is a copy of base and returns early if base->n_scale is non-zero. Since
scale is size_t, it is always greater than or equal to 0, so rscale is always
the value of scale.
Changed paths:
M ext/bcmath/libbcmath/src/raisemod.c
Diff:
diff --git a/ext/bcmath/libbcmath/src/raisemod.c b/ext/bcmath/libbcmath/src/raisemod.c
index 93bd4193da45c..d4a2d01f3edb9 100644
--- a/ext/bcmath/libbcmath/src/raisemod.c
+++ b/ext/bcmath/libbcmath/src/raisemod.c
@@ -36,7 +36,6 @@
raise_mod_status bc_raisemod(bc_num base, bc_num expo, bc_num mod, bc_num *result, size_t scale)
{
bc_num power, exponent, modulus, parity, temp;
- size_t rscale;
/* Check the base for scale digits. */
if (base->n_scale != 0) {
@@ -66,7 +65,6 @@ raise_mod_status bc_raisemod(bc_num base, bc_num expo, bc_num mod, bc_num *resul
bc_init_num(&parity);
/* Do the calculation. */
- rscale = MAX(scale, power->n_scale);
if (!bc_compare(modulus, BCG(_one_))) {
bc_free_num (&temp);
temp = bc_new_num (1, scale);
@@ -74,10 +72,10 @@ raise_mod_status bc_raisemod(bc_num base, bc_num expo, bc_num mod, bc_num *resul
while (!bc_is_zero(exponent)) {
(void) bc_divmod(exponent, BCG(_two_), &exponent, &parity, 0);
if (!bc_is_zero(parity)) {
- bc_multiply(temp, power, &temp, rscale);
+ bc_multiply(temp, power, &temp, scale);
(void) bc_modulo(temp, modulus, &temp, scale);
}
- bc_multiply(power, power, &power, rscale);
+ bc_multiply(power, power, &power, scale);
(void) bc_modulo(power, modulus, &power, scale);
}
}