Skip to content

Commit 8b31eec

Browse files
committed
Avoid incrementing the position to clarify it's unused
Fixes two issues flagged by Clang's static analyzer.
1 parent 86bbfd9 commit 8b31eec

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

loguru.cpp

+15-2
Original file line numberDiff line numberDiff line change
@@ -1284,7 +1284,14 @@ namespace loguru
12841284
}
12851285
}
12861286
if (g_preamble_pipe && pos < out_buff_size) {
1287-
/* pos += */ (void)snprintf(out_buff + pos, out_buff_size - pos, "| ");
1287+
(void)snprintf(out_buff + pos, out_buff_size - pos, "| ");
1288+
1289+
// Because this is the last if-statement, we avoid incrementing the
1290+
// position to clarify it's unused. If more cases are added, then:
1291+
// int bytes = snprintf(...)
1292+
// if (bytes > 0) {
1293+
// pos += bytes;
1294+
// }
12881295
}
12891296
}
12901297

@@ -1363,7 +1370,13 @@ namespace loguru
13631370
}
13641371
}
13651372
if (g_preamble_pipe && pos < out_buff_size) {
1366-
/* pos += */ (void)snprintf(out_buff + pos, out_buff_size - pos, "| ");
1373+
(void)snprintf(out_buff + pos, out_buff_size - pos, "| ");
1374+
1375+
// Avoid incrementing the position to clarify it's unused
1376+
// int bytes = snprintf(...)
1377+
// if (bytes > 0) {
1378+
// pos += bytes;
1379+
// }
13671380
}
13681381
}
13691382

0 commit comments

Comments
 (0)