loguru
loguru copied to clipboard
typo in sprintf
loguru.cpp, line1206:
snprintf(level_buff, sizeof(level_buff) - 1, "% 4d", verbosity);
Note the space between % and 4d
That may or may not be a typo. I believe the space prepends a space for positive numbers (and negative values will have the negative sign, as usual).
However, I think the snprintf statement is wrong anyway:
char level_buff[6];
snprintf(level_buff, sizeof(level_buff) - 1, "%s", custom_level_name);
It is idiomatic to do snprintf(buff, sizeof(buff), ...). Not sure why that -1 is there.
And indeed clang says:
warning: 'snprintf' will always be truncated; specified size is 5, but format string expands to at least 6 [-Wformat-truncation]
1199 | snprintf(level_buff, sizeof(level_buff) - 1, "% 4d", verbosity);
| ^
Patch: https://github.com/emilk/loguru/pull/278