Skip to content
Snippets Groups Projects
Commit fccdeb7e authored by Florian Schmaus's avatar Florian Schmaus
Browse files

[LinuxVersion] Do not log a warning if there are non-digits chars found

A Linux version including non-digits, like 5.15.23-gentoo-dist, is
very common and nothing we should warn about.
parent 08fb2c51
No related branches found
No related tags found
1 merge request!342Improve LinuxVersion
...@@ -8,7 +8,6 @@ ...@@ -8,7 +8,6 @@
#include <cstdlib> #include <cstdlib>
#include "Common.hpp" #include "Common.hpp"
#include "Debug.hpp"
static auto checked_strtol(const std::string& s) -> long { static auto checked_strtol(const std::string& s) -> long {
static const int DECIMAL = 10; static const int DECIMAL = 10;
...@@ -25,9 +24,11 @@ static auto checked_strtol(const std::string& s) -> long { ...@@ -25,9 +24,11 @@ static auto checked_strtol(const std::string& s) -> long {
DIE_MSG("strtol found no digits in " << s); DIE_MSG("strtol found no digits in " << s);
} }
if (endptr != startptr + s.size()) { // TODO: We could report remaining bytes of the string by returning
LOGW("LinuxVersion compare ignored non digits in " << s) // std::string(endptr) together with 'res' (potentially using
} // std::pair). Not sure if we even need to check if "endptr !=
// startptr + s.size()", or if we could always cosntruct
// std::string(endptr), potentially constructing the empty string.
return res; return res;
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment