From bbeec4c20f1b692084048051a8b96e066518f354 Mon Sep 17 00:00:00 2001 From: Nikita Popov Date: Fri, 12 Apr 2019 14:32:29 +0200 Subject: [PATCH] Avoid uninitialized variable warnings in gmp --- ext/gmp/gmp.c | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/ext/gmp/gmp.c b/ext/gmp/gmp.c index 73462b8313..52bb962db2 100644 --- a/ext/gmp/gmp.c +++ b/ext/gmp/gmp.c @@ -821,13 +821,12 @@ static void gmp_cmp(zval *return_value, zval *a_arg, zval *b_arg) /* {{{ */ 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) { mpz_ptr gmpnum_a, gmpnum_b, gmpnum_result; - int use_ui = 0; gmp_temp_t temp_a, temp_b; FETCH_GMP_ZVAL(gmpnum_a, a_arg, temp_a); if (gmp_ui_op && Z_TYPE_P(b_arg) == IS_LONG && Z_LVAL_P(b_arg) >= 0) { - use_ui = 1; + gmpnum_b = NULL; temp_b.is_used = 0; } else { FETCH_GMP_ZVAL_DEP(gmpnum_b, b_arg, temp_b, temp_a); @@ -835,7 +834,7 @@ static inline void gmp_zval_binary_ui_op(zval *return_value, zval *a_arg, zval * if (check_b_zero) { int b_is_zero = 0; - if (use_ui) { + if (!gmpnum_b) { b_is_zero = (Z_LVAL_P(b_arg) == 0); } else { b_is_zero = !mpz_cmp_ui(gmpnum_b, 0); @@ -851,7 +850,7 @@ static inline void gmp_zval_binary_ui_op(zval *return_value, zval *a_arg, zval * INIT_GMP_RETVAL(gmpnum_result); - if (use_ui) { + if (!gmpnum_b) { gmp_ui_op(gmpnum_result, gmpnum_a, (gmp_ulong) Z_LVAL_P(b_arg)); } else { gmp_op(gmpnum_result, gmpnum_a, gmpnum_b); @@ -868,15 +867,13 @@ static inline void gmp_zval_binary_ui_op(zval *return_value, zval *a_arg, zval * 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) { mpz_ptr gmpnum_a, gmpnum_b, gmpnum_result1, gmpnum_result2; - int use_ui = 0; gmp_temp_t temp_a, temp_b; zval result1, result2; FETCH_GMP_ZVAL(gmpnum_a, a_arg, temp_a); if (gmp_ui_op && Z_TYPE_P(b_arg) == IS_LONG && Z_LVAL_P(b_arg) >= 0) { - /* use _ui function */ - use_ui = 1; + gmpnum_b = NULL; temp_b.is_used = 0; } else { FETCH_GMP_ZVAL_DEP(gmpnum_b, b_arg, temp_b, temp_a); @@ -884,7 +881,7 @@ static inline void gmp_zval_binary_ui_op2(zval *return_value, zval *a_arg, zval if (check_b_zero) { int b_is_zero = 0; - if (use_ui) { + if (!gmpnum_b) { b_is_zero = (Z_LVAL_P(b_arg) == 0); } else { b_is_zero = !mpz_cmp_ui(gmpnum_b, 0); @@ -905,7 +902,7 @@ static inline void gmp_zval_binary_ui_op2(zval *return_value, zval *a_arg, zval add_next_index_zval(return_value, &result1); add_next_index_zval(return_value, &result2); - if (use_ui) { + if (!gmpnum_b) { gmp_ui_op(gmpnum_result1, gmpnum_result2, gmpnum_a, (gmp_ulong) Z_LVAL_P(b_arg)); } else { gmp_op(gmpnum_result1, gmpnum_result2, gmpnum_a, gmpnum_b); -- 2.40.0