Browse Source

Merge pull request #10473 from Chocobo1/warning

Fix unsafe type narrowing (MSVC C4267 warning)
adaptive-webui-19844
Mike Tzou 6 years ago committed by GitHub
parent
commit
c7f89f55d0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 4
      src/base/utils/version.h

4
src/base/utils/version.h

@ -168,12 +168,12 @@ namespace Utils
{ {
if ((static_cast<std::size_t>(versionParts.size()) > N) if ((static_cast<std::size_t>(versionParts.size()) > N)
|| (static_cast<std::size_t>(versionParts.size()) < Mandatory)) || (static_cast<std::size_t>(versionParts.size()) < Mandatory))
throw std::runtime_error ("Incorrect number of version components"); throw std::runtime_error("Incorrect number of version components");
bool ok = false; bool ok = false;
ComponentsArray res {{}}; ComponentsArray res {{}};
for (std::size_t i = 0; i < static_cast<std::size_t>(versionParts.size()); ++i) { for (std::size_t i = 0; i < static_cast<std::size_t>(versionParts.size()); ++i) {
res[i] = static_cast<T>(versionParts[i].toInt(&ok)); res[i] = static_cast<T>(versionParts[static_cast<typename StringsList::size_type>(i)].toInt(&ok));
if (!ok) if (!ok)
throw std::runtime_error("Can not parse version component"); throw std::runtime_error("Can not parse version component");
} }

Loading…
Cancel
Save