From: Tomas Mraz Date: Wed, 7 Jun 2023 11:47:59 +0000 (+0200) Subject: Coverity 1528494 and 1528493: Remove unused assignment of wvalue X-Git-Tag: openssl-3.2.0-alpha1~670 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=f9a4e2b663ab97de718e016b29644d0c2bd9b7c3;p=thirdparty%2Fopenssl.git Coverity 1528494 and 1528493: Remove unused assignment of wvalue wvalue is always initialized at the beginning of each cycle and used only within the cycle --- diff --git a/crypto/bn/bn_exp.c b/crypto/bn/bn_exp.c index 22cbffa723b..2f4594120c8 100644 --- a/crypto/bn/bn_exp.c +++ b/crypto/bn/bn_exp.c @@ -169,7 +169,7 @@ int BN_mod_exp(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, const BIGNUM *m, int BN_mod_exp_recp(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, const BIGNUM *m, BN_CTX *ctx) { - int i, j, bits, ret = 0, wstart, wend, window, wvalue; + int i, j, bits, ret = 0, wstart, wend, window; int start = 1; BIGNUM *aa; /* Table of variables obtained from 'ctx' */ @@ -239,7 +239,6 @@ int BN_mod_exp_recp(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, start = 1; /* This is used to avoid multiplication etc * when there is only the value '1' in the * buffer. */ - wvalue = 0; /* The 'value' of the window */ wstart = bits - 1; /* The top bit of the window */ wend = 0; /* The bottom bit of the window */ @@ -247,6 +246,8 @@ int BN_mod_exp_recp(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, goto err; for (;;) { + int wvalue; /* The 'value' of the window */ + if (BN_is_bit_set(p, wstart) == 0) { if (!start) if (!BN_mod_mul_reciprocal(r, r, r, &recp, ctx)) @@ -288,7 +289,6 @@ int BN_mod_exp_recp(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, /* move the 'window' down further */ wstart -= wend + 1; - wvalue = 0; start = 0; if (wstart < 0) break; @@ -1303,7 +1303,7 @@ int BN_mod_exp_mont_word(BIGNUM *rr, BN_ULONG a, const BIGNUM *p, int BN_mod_exp_simple(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, const BIGNUM *m, BN_CTX *ctx) { - int i, j, bits, ret = 0, wstart, wend, window, wvalue; + int i, j, bits, ret = 0, wstart, wend, window; int start = 1; BIGNUM *d; /* Table of variables obtained from 'ctx' */ @@ -1358,7 +1358,6 @@ int BN_mod_exp_simple(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, start = 1; /* This is used to avoid multiplication etc * when there is only the value '1' in the * buffer. */ - wvalue = 0; /* The 'value' of the window */ wstart = bits - 1; /* The top bit of the window */ wend = 0; /* The bottom bit of the window */ @@ -1366,6 +1365,8 @@ int BN_mod_exp_simple(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, goto err; for (;;) { + int wvalue; /* The 'value' of the window */ + if (BN_is_bit_set(p, wstart) == 0) { if (!start) if (!BN_mod_mul(r, r, r, m, ctx)) @@ -1407,7 +1408,6 @@ int BN_mod_exp_simple(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, /* move the 'window' down further */ wstart -= wend + 1; - wvalue = 0; start = 0; if (wstart < 0) break;