1
0
Fork 0
mirror of https://git.rwth-aachen.de/acs/public/villas/node/ synced 2025-03-09 00:00:00 +01:00

spdlog: fix handling of too long logger names

`whitespace` overflows because the result implicitly is an unsigned
value.
This commit is contained in:
daniel-k 2018-01-23 10:09:06 +01:00
parent df93004720
commit 28a7f2a3ee

View file

@ -19,6 +19,7 @@
#include <utility>
#include <vector>
#include <array>
#include <algorithm>
namespace spdlog
{
@ -40,7 +41,7 @@ namespace
class name_formatter:public flag_formatter
{
std::string center(std::string input, int width) {
const auto whitespace = width - input.length();
const int whitespace = std::max(int(width - input.length()), 0);
return std::string(whitespace / 2, ' ')
+ input
+ std::string(whitespace / 2, ' ')