From: Tomas Mraz Date: Wed, 7 Jun 2023 12:33:22 +0000 (+0200) Subject: Coverity 1528485: Remove unused assignment of wvalue X-Git-Tag: openssl-3.2.0-alpha1~664 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=ade969e27b71a57e4d44ebada093929cc8f4193c;p=thirdparty%2Fopenssl.git Coverity 1528485: Remove unused assignment of wvalue wvalue is always initialized at the beginning of each cycle and used only within the cycle Reviewed-by: Matt Caswell Reviewed-by: Paul Dale Reviewed-by: Todd Short (Merged from https://github.com/openssl/openssl/pull/21145) --- diff --git a/crypto/bn/bn_exp.c b/crypto/bn/bn_exp.c index 2f4594120c..0d68bd0f3f 100644 --- a/crypto/bn/bn_exp.c +++ b/crypto/bn/bn_exp.c @@ -304,7 +304,7 @@ int BN_mod_exp_recp(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, int BN_mod_exp_mont(BIGNUM *rr, const BIGNUM *a, const BIGNUM *p, const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *in_mont) { - int i, j, bits, ret = 0, wstart, wend, window, wvalue; + int i, j, bits, ret = 0, wstart, wend, window; int start = 1; BIGNUM *d, *r; const BIGNUM *aa; @@ -384,7 +384,6 @@ int BN_mod_exp_mont(BIGNUM *rr, 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 */ @@ -404,6 +403,8 @@ int BN_mod_exp_mont(BIGNUM *rr, const BIGNUM *a, const BIGNUM *p, if (!bn_to_mont_fixed_top(r, BN_value_one(), mont, ctx)) goto err; for (;;) { + int wvalue; /* The 'value' of the window */ + if (BN_is_bit_set(p, wstart) == 0) { if (!start) { if (!bn_mul_mont_fixed_top(r, r, r, mont, ctx)) @@ -446,7 +447,6 @@ int BN_mod_exp_mont(BIGNUM *rr, const BIGNUM *a, const BIGNUM *p, /* move the 'window' down further */ wstart -= wend + 1; - wvalue = 0; start = 0; if (wstart < 0) break;