Skip to content

Commit

Permalink
SP int: stop CodeSonar complaining about i being negatve
Browse files Browse the repository at this point in the history
n is checked for negative and fail out in that case.
i is n devided by a positive constant and can never be negative.
  • Loading branch information
SparkiDev committed Jan 6, 2025
1 parent 71b7d0c commit 13ce92c
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions wolfcrypt/src/sp_int.c
Original file line number Diff line number Diff line change
Expand Up @@ -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. */
Expand Down

0 comments on commit 13ce92c

Please sign in to comment.