Skip to content

Commit

Permalink
Avoid incrementing the position to clarify it's unused
Browse files Browse the repository at this point in the history
Fixes two issues flagged by Clang's static analyzer.
  • Loading branch information
kcgen committed Sep 16, 2021
1 parent 86bbfd9 commit 8b31eec
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions loguru.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1284,7 +1284,14 @@ namespace loguru
}
}
if (g_preamble_pipe && pos < out_buff_size) {
/* pos += */ (void)snprintf(out_buff + pos, out_buff_size - pos, "| ");
(void)snprintf(out_buff + pos, out_buff_size - pos, "| ");

// Because this is the last if-statement, we avoid incrementing the
// position to clarify it's unused. If more cases are added, then:
// int bytes = snprintf(...)
// if (bytes > 0) {
// pos += bytes;
// }
}
}

Expand Down Expand Up @@ -1363,7 +1370,13 @@ namespace loguru
}
}
if (g_preamble_pipe && pos < out_buff_size) {
/* pos += */ (void)snprintf(out_buff + pos, out_buff_size - pos, "| ");
(void)snprintf(out_buff + pos, out_buff_size - pos, "| ");

// Avoid incrementing the position to clarify it's unused
// int bytes = snprintf(...)
// if (bytes > 0) {
// pos += bytes;
// }
}
}

Expand Down

0 comments on commit 8b31eec

Please sign in to comment.