From 3f450d26808f916ae740e7a480f0f376b92fce9d Mon Sep 17 00:00:00 2001 From: Matthew Woehlke Date: Tue, 3 Dec 2024 17:19:39 -0500 Subject: [PATCH] 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. --- Source/cmFindPackageCommand.cxx | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/Source/cmFindPackageCommand.cxx b/Source/cmFindPackageCommand.cxx index 12bf160b9f..afaa166877 100644 --- a/Source/cmFindPackageCommand.cxx +++ b/Source/cmFindPackageCommand.cxx @@ -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(std::sscanf( + version.c_str(), "%u.%u.%u.%u", &major, &minor, &patch, &tweak)); } } // anonymous namespace