fix integer overflow
This commit is contained in:
@@ -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;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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)
|
||||||
|
|||||||
@@ -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);
|
||||||
|
|
||||||
|
|||||||
@@ -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;
|
||||||
|
|||||||
@@ -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);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user