From 13ce92cc1fbacb8503cf672f3f31628c59d2fa85 Mon Sep 17 00:00:00 2001 From: Sean Parkinson Date: Mon, 6 Jan 2025 10:04:14 +1000 Subject: [PATCH] SP int: stop CodeSonar complaining about i being negatve n is checked for negative and fail out in that case. i is n devided by a positive constant and can never be negative. --- wolfcrypt/src/sp_int.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/wolfcrypt/src/sp_int.c b/wolfcrypt/src/sp_int.c index 00b3607e36..e84d5dfb81 100644 --- a/wolfcrypt/src/sp_int.c +++ b/wolfcrypt/src/sp_int.c @@ -8527,13 +8527,13 @@ int sp_rshb(const sp_int* a, int n, sp_int* r) { int err = MP_OKAY; /* Number of digits to shift down. */ - sp_size_t i = (sp_size_t)(n >> SP_WORD_SHIFT); + sp_size_t i; if ((a == NULL) || (n < 0)) { err = MP_VAL; } /* Handle case where shifting out all digits. */ - if ((err == MP_OKAY) && (i >= a->used)) { + else if ((i = (sp_size_t)(n >> SP_WORD_SHIFT)) >= a->used) { _sp_zero(r); } /* Change callers when more error cases returned. */