From fd2e438b24f4ce153ee35a691ae5bcb7eb28cc98 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Mon, 25 Apr 2016 16:30:43 +0200 Subject: restore pinning to min/max value of short Broken in the previous commit (69cea1ef2cfda3c4da79fd756a8edaf2be26998e). Adding a test and a comment to avoid future embarrassment. Git-Dch: Ignore Reported-By: Julian Andres Klode on IRC --- apt-pkg/policy.cc | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'apt-pkg/policy.cc') diff --git a/apt-pkg/policy.cc b/apt-pkg/policy.cc index 7c57f9dea..7059b0a79 100644 --- a/apt-pkg/policy.cc +++ b/apt-pkg/policy.cc @@ -374,7 +374,8 @@ APT_PURE signed short pkgPolicy::GetPriority(pkgCache::VerIterator const &Ver, b if (!ConsiderFiles) return 0; - signed short priority = std::numeric_limits::min(); + // priorities are short ints, but we want to pick a value outside the valid range here + auto priority = std::numeric_limits::min(); for (pkgCache::VerFileIterator file = Ver.FileList(); file.end() == false; file++) { /* If this is the status file, and the current version is not the @@ -385,7 +386,7 @@ APT_PURE signed short pkgPolicy::GetPriority(pkgCache::VerIterator const &Ver, b if (file.File().Flagged(pkgCache::Flag::NotSource) && Ver.ParentPkg().CurrentVer() != Ver) priority = std::max(priority, static_cast(-1)); else - priority = std::max(priority, GetPriority(file.File())); + priority = std::max(priority, static_cast(GetPriority(file.File()))); } return priority == std::numeric_limits::min() ? 0 : priority; -- cgit v1.2.3