Skip to content

Commit 3d9c480

Browse files
committed
Avoid uninitialized variable warnings in gmp
1 parent 733c61a commit 3d9c480

File tree

1 file changed

+6
-9
lines changed

1 file changed

+6
-9
lines changed

ext/gmp/gmp.c

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -828,21 +828,20 @@ static void gmp_cmp(zval *return_value, zval *a_arg, zval *b_arg) /* {{{ */
828828
static inline void gmp_zval_binary_ui_op(zval *return_value, zval *a_arg, zval *b_arg, gmp_binary_op_t gmp_op, gmp_binary_ui_op_t gmp_ui_op, int check_b_zero)
829829
{
830830
mpz_ptr gmpnum_a, gmpnum_b, gmpnum_result;
831-
int use_ui = 0;
832831
gmp_temp_t temp_a, temp_b;
833832

834833
FETCH_GMP_ZVAL(gmpnum_a, a_arg, temp_a);
835834

836835
if (gmp_ui_op && Z_TYPE_P(b_arg) == IS_LONG && Z_LVAL_P(b_arg) >= 0) {
837-
use_ui = 1;
836+
gmpnum_b = NULL;
838837
temp_b.is_used = 0;
839838
} else {
840839
FETCH_GMP_ZVAL_DEP(gmpnum_b, b_arg, temp_b, temp_a);
841840
}
842841

843842
if (check_b_zero) {
844843
int b_is_zero = 0;
845-
if (use_ui) {
844+
if (!gmpnum_b) {
846845
b_is_zero = (Z_LVAL_P(b_arg) == 0);
847846
} else {
848847
b_is_zero = !mpz_cmp_ui(gmpnum_b, 0);
@@ -858,7 +857,7 @@ static inline void gmp_zval_binary_ui_op(zval *return_value, zval *a_arg, zval *
858857

859858
INIT_GMP_RETVAL(gmpnum_result);
860859

861-
if (use_ui) {
860+
if (!gmpnum_b) {
862861
gmp_ui_op(gmpnum_result, gmpnum_a, (gmp_ulong) Z_LVAL_P(b_arg));
863862
} else {
864863
gmp_op(gmpnum_result, gmpnum_a, gmpnum_b);
@@ -875,23 +874,21 @@ static inline void gmp_zval_binary_ui_op(zval *return_value, zval *a_arg, zval *
875874
static inline void gmp_zval_binary_ui_op2(zval *return_value, zval *a_arg, zval *b_arg, gmp_binary_op2_t gmp_op, gmp_binary_ui_op2_t gmp_ui_op, int check_b_zero)
876875
{
877876
mpz_ptr gmpnum_a, gmpnum_b, gmpnum_result1, gmpnum_result2;
878-
int use_ui = 0;
879877
gmp_temp_t temp_a, temp_b;
880878
zval result1, result2;
881879

882880
FETCH_GMP_ZVAL(gmpnum_a, a_arg, temp_a);
883881

884882
if (gmp_ui_op && Z_TYPE_P(b_arg) == IS_LONG && Z_LVAL_P(b_arg) >= 0) {
885-
/* use _ui function */
886-
use_ui = 1;
883+
gmpnum_b = NULL;
887884
temp_b.is_used = 0;
888885
} else {
889886
FETCH_GMP_ZVAL_DEP(gmpnum_b, b_arg, temp_b, temp_a);
890887
}
891888

892889
if (check_b_zero) {
893890
int b_is_zero = 0;
894-
if (use_ui) {
891+
if (!gmpnum_b) {
895892
b_is_zero = (Z_LVAL_P(b_arg) == 0);
896893
} else {
897894
b_is_zero = !mpz_cmp_ui(gmpnum_b, 0);
@@ -912,7 +909,7 @@ static inline void gmp_zval_binary_ui_op2(zval *return_value, zval *a_arg, zval
912909
add_next_index_zval(return_value, &result1);
913910
add_next_index_zval(return_value, &result2);
914911

915-
if (use_ui) {
912+
if (!gmpnum_b) {
916913
gmp_ui_op(gmpnum_result1, gmpnum_result2, gmpnum_a, (gmp_ulong) Z_LVAL_P(b_arg));
917914
} else {
918915
gmp_op(gmpnum_result1, gmpnum_result2, gmpnum_a, gmpnum_b);

0 commit comments

Comments
 (0)