find_package: Fix sign-cast warning

Tweak a helper function to avoid an implicit cast from unsigned to
signed. This is hardly the only -Wsign-conversion we are tripping, but
cmFindPackage is now free of such.
This commit is contained in:
Matthew Woehlke
2024-12-03 17:19:39 -05:00
parent 14ed8464c8
commit 3f450d2680

View File

@@ -424,11 +424,12 @@ bool TryGeneratedPaths(CallbackFn&& filesCollector,
// Parse the version number and store the results that were
// successfully parsed.
int parseVersion(const std::string& version, unsigned int& major,
unsigned int& minor, unsigned int& patch, unsigned int& tweak)
unsigned int parseVersion(std::string const& version, unsigned int& major,
unsigned int& minor, unsigned int& patch,
unsigned int& tweak)
{
return std::sscanf(version.c_str(), "%u.%u.%u.%u", &major, &minor, &patch,
&tweak);
return static_cast<unsigned int>(std::sscanf(
version.c_str(), "%u.%u.%u.%u", &major, &minor, &patch, &tweak));
}
} // anonymous namespace