fix integer overflow

This commit is contained in:
Jonas Zeunert
2022-02-25 22:11:19 +01:00
parent 95ca5b4901
commit 7c56b1d6c7
6 changed files with 6 additions and 6 deletions

View File

@@ -23,7 +23,7 @@ class Display : public virtual items::Item
public: public:
virtual ~Display() = default; virtual ~Display() = default;
virtual void write_score(unsigned int score) = 0; virtual void write_score(uint64_t score) = 0;
}; };
} }

View File

@@ -254,7 +254,7 @@ boost::optional<Poco::JSON::Object> OutputRequestHandler::parseDisplay(const std
{ {
try try
{ {
unsigned int numerical_score = std::stoi(score); uint64_t numerical_score = std::stoi(score);
display->write_score(numerical_score); display->write_score(numerical_score);
} }
catch(std::invalid_argument &e) catch(std::invalid_argument &e)

View File

@@ -30,7 +30,7 @@ std::string Display::get_name() const
return this->name; return this->name;
} }
void Display::write_score(const unsigned int & score, const unsigned int & length) void Display::write_score(const uint64_t & score, const unsigned int & length)
{ {
auto score_string = std::to_string(score); auto score_string = std::to_string(score);

View File

@@ -27,7 +27,7 @@ public:
Display(const uint8_t & address, const std::string & name); Display(const uint8_t & address, const std::string & name);
virtual ~Display() = default; virtual ~Display() = default;
void write_score(const unsigned int & score, const unsigned int & length); void write_score(const uint64_t & score, const unsigned int & length);
void write_content(std::string & content, const unsigned int & length); void write_content(std::string & content, const unsigned int & length);
std::string get_content() const override; std::string get_content() const override;

View File

@@ -31,7 +31,7 @@ public:
~EightDigitDisplay() override = default; ~EightDigitDisplay() override = default;
void write_score(unsigned int score) override void write_score(uint64_t score) override
{ {
detail::Display::write_score(score, 8); detail::Display::write_score(score, 8);
} }

View File

@@ -27,7 +27,7 @@ public:
CLOG(DEBUG, OUTPUT_LOGGER) << "Created SevenDigitDisplay " << name << " with address " << int{this->address}; CLOG(DEBUG, OUTPUT_LOGGER) << "Created SevenDigitDisplay " << name << " with address " << int{this->address};
} }
void write_score(unsigned int score) override void write_score(uint64_t score) override
{ {
detail::Display::write_score(score, 7); detail::Display::write_score(score, 7);
} }