Skip to content

Commit

Permalink
Avoid uninitialized variable warnings in gmp
Browse files Browse the repository at this point in the history
  • Loading branch information
nikic committed Apr 12, 2019
1 parent 733c61a commit 3d9c480
Showing 1 changed file with 6 additions and 9 deletions.
15 changes: 6 additions & 9 deletions ext/gmp/gmp.c
Expand Up @@ -828,21 +828,20 @@ 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);
}

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);
Expand All @@ -858,7 +857,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);
Expand All @@ -875,23 +874,21 @@ 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);
}

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);
Expand All @@ -912,7 +909,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);
Expand Down

0 comments on commit 3d9c480

Please sign in to comment.