Skip to content

Commit

Permalink
Regards mpaland#77: MISRA-C:2012 Rule 13.3: No increment/decrement wi…
Browse files Browse the repository at this point in the history
…th other side effects.
  • Loading branch information
sander.hagendoorn authored and eyalroz committed Feb 21, 2022
1 parent 12ef29f commit f0366b7
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/printf/printf.c
Original file line number Diff line number Diff line change
Expand Up @@ -589,8 +589,9 @@ static size_t print_broken_up_decimal(
}
}
// add extra 0s
while ((len < PRINTF_FTOA_BUFFER_SIZE) && (count-- > 0U)) {
while ((len < PRINTF_FTOA_BUFFER_SIZE) && (count > 0U)) {
buf[len++] = '0';
--count;
}
if (len < PRINTF_FTOA_BUFFER_SIZE) {
buf[len++] = '.';
Expand Down Expand Up @@ -1055,8 +1056,9 @@ static int _vsnprintf(out_fct_type out, char* buffer, const size_t maxlen, const
}
}
// string output
while ((*p != 0) && (!(flags & FLAGS_PRECISION) || precision--)) {
while ((*p != 0) && (!(flags & FLAGS_PRECISION) || precision)) {
out(*(p++), buffer, idx++, maxlen);
--precision;
}
// post padding
if (flags & FLAGS_LEFT) {
Expand Down

0 comments on commit f0366b7

Please sign in to comment.