diff options
Diffstat (limited to 'apt-pkg')
-rw-r--r-- | apt-pkg/algorithms.cc | 22 | ||||
-rw-r--r-- | apt-pkg/contrib/hashes.cc | 6 | ||||
-rw-r--r-- | apt-pkg/edsp.cc | 32 | ||||
-rw-r--r-- | apt-pkg/orderlist.cc | 6 | ||||
-rw-r--r-- | apt-pkg/policy.cc | 8 |
5 files changed, 38 insertions, 36 deletions
diff --git a/apt-pkg/algorithms.cc b/apt-pkg/algorithms.cc index 95e756c15..2c0cd1104 100644 --- a/apt-pkg/algorithms.cc +++ b/apt-pkg/algorithms.cc @@ -52,12 +52,13 @@ pkgSimulate::pkgSimulate(pkgDepCache *Cache) : pkgPackageManager(Cache), group(Sim) { Sim.Init(0); - Flags = new unsigned char[Cache->Head().PackageCount]; - memset(Flags,0,sizeof(*Flags)*Cache->Head().PackageCount); + auto PackageCount = Cache->Head().PackageCount; + Flags = new unsigned char[PackageCount]; + memset(Flags,0,sizeof(*Flags)*PackageCount); // Fake a filename so as not to activate the media swapping string Jnk = "SIMULATE"; - for (unsigned int I = 0; I != Cache->Head().PackageCount; I++) + for (decltype(PackageCount) I = 0; I != PackageCount; ++I) FileNames[I] = Jnk; } /*}}}*/ @@ -399,7 +400,7 @@ bool pkgFixBroken(pkgDepCache &Cache) pkgProblemResolver::pkgProblemResolver(pkgDepCache *pCache) : d(NULL), Cache(*pCache) { // Allocate memory - unsigned long Size = Cache.Head().PackageCount; + auto const Size = Cache.Head().PackageCount; Scores = new int[Size]; Flags = new unsigned char[Size]; memset(Flags,0,sizeof(*Flags)*Size); @@ -434,7 +435,7 @@ int pkgProblemResolver::ScoreSort(Package const *A,Package const *B) /* */ void pkgProblemResolver::MakeScores() { - unsigned long Size = Cache.Head().PackageCount; + auto const Size = Cache.Head().PackageCount; memset(Scores,0,sizeof(*Scores)*Size); // maps to pkgCache::State::VerPriority: @@ -753,7 +754,7 @@ bool pkgProblemResolver::ResolveInternal(bool const BrokenFix) MakeScores(); - unsigned long const Size = Cache.Head().PackageCount; + auto const Size = Cache.Head().PackageCount; /* We have to order the packages so that the broken fixing pass operates from highest score to lowest. This prevents problems when @@ -806,7 +807,7 @@ bool pkgProblemResolver::ResolveInternal(bool const BrokenFix) { if (Debug == true) clog << " Try to Re-Instate (" << Counter << ") " << I.FullName(false) << endl; - unsigned long OldBreaks = Cache.BrokenCount(); + auto const OldBreaks = Cache.BrokenCount(); pkgCache::Version *OldVer = Cache[I].InstallVer; Flags[I->ID] &= ReInstateTried; @@ -1006,7 +1007,7 @@ bool pkgProblemResolver::ResolveInternal(bool const BrokenFix) dangerous as it could trigger new breaks/conflicts… */ if (Debug == true) clog << " Try Installing " << APT::PrettyPkg(&Cache, Start.TargetPkg()) << " before changing " << I.FullName(false) << std::endl; - unsigned long const OldBroken = Cache.BrokenCount(); + auto const OldBroken = Cache.BrokenCount(); Cache.MarkInstall(Start.TargetPkg(), true, 1, false); // FIXME: we should undo the complete MarkInstall process here if (Cache[Start.TargetPkg()].InstBroken() == true || Cache.BrokenCount() > OldBroken) @@ -1211,14 +1212,13 @@ bool pkgProblemResolver::ResolveByKeepInternal() { pkgDepCache::ActionGroup group(Cache); - unsigned long Size = Cache.Head().PackageCount; - MakeScores(); - + /* We have to order the packages so that the broken fixing pass operates from highest score to lowest. This prevents problems when high score packages cause the removal of lower score packages that would cause the removal of even lower score packages. */ + auto Size = Cache.Head().PackageCount; pkgCache::Package **PList = new pkgCache::Package *[Size]; pkgCache::Package **PEnd = PList; for (pkgCache::PkgIterator I = Cache.PkgBegin(); I.end() == false; ++I) diff --git a/apt-pkg/contrib/hashes.cc b/apt-pkg/contrib/hashes.cc index 662c2bf8b..4727d489e 100644 --- a/apt-pkg/contrib/hashes.cc +++ b/apt-pkg/contrib/hashes.cc @@ -339,7 +339,7 @@ bool Hashes::AddFD(int const Fd,unsigned long long Size) bool const ToEOF = (Size == UntilEOF); while (Size != 0 || ToEOF) { - unsigned long long n = sizeof(Buf); + decltype(Size) n = sizeof(Buf); if (!ToEOF) n = std::min(Size, n); ssize_t const Res = read(Fd,Buf,n); if (Res < 0 || (!ToEOF && Res != (ssize_t) n)) // error, or short read @@ -363,9 +363,9 @@ bool Hashes::AddFD(FileFd &Fd,unsigned long long Size) bool const ToEOF = (Size == 0); while (Size != 0 || ToEOF) { - unsigned long long n = sizeof(Buf); + decltype(Size) n = sizeof(Buf); if (!ToEOF) n = std::min(Size, n); - unsigned long long a = 0; + decltype(Size) a = 0; if (Fd.Read(Buf, n, &a) == false) // error return false; if (ToEOF == false) diff --git a/apt-pkg/edsp.cc b/apt-pkg/edsp.cc index a2520441b..fb23c1c55 100644 --- a/apt-pkg/edsp.cc +++ b/apt-pkg/edsp.cc @@ -396,7 +396,7 @@ bool EDSP::WriteScenario(pkgDepCache &Cache, FILE* output, OpProgress *Progress) { if (Progress != NULL) Progress->SubProgress(Cache.Head().VersionCount, _("Send scenario to solver")); - unsigned long p = 0; + decltype(Cache.Head().VersionCount) p = 0; std::vector<std::string> archs = APT::Configuration::getArchitectures(); for (pkgCache::PkgIterator Pkg = Cache.PkgBegin(); Pkg.end() == false; ++Pkg) { @@ -420,7 +420,7 @@ bool EDSP::WriteScenario(pkgDepCache &Cache, FileFd &output, OpProgress *Progres { if (Progress != NULL) Progress->SubProgress(Cache.Head().VersionCount, _("Send scenario to solver")); - unsigned long p = 0; + decltype(Cache.Head().VersionCount) p = 0; bool Okay = output.Failed() == false; std::vector<std::string> archs = APT::Configuration::getArchitectures(); for (pkgCache::PkgIterator Pkg = Cache.PkgBegin(); Pkg.end() == false && likely(Okay); ++Pkg) @@ -450,7 +450,7 @@ bool EDSP::WriteLimitedScenario(pkgDepCache &Cache, FILE* output, { if (Progress != NULL) Progress->SubProgress(Cache.Head().VersionCount, _("Send scenario to solver")); - unsigned long p = 0; + decltype(Cache.Head().PackageCount) p = 0; for (APT::PackageSet::const_iterator Pkg = pkgset.begin(); Pkg != pkgset.end(); ++Pkg, ++p) for (pkgCache::VerIterator Ver = Pkg.VersionList(); Ver.end() == false; ++Ver) { @@ -472,7 +472,7 @@ bool EDSP::WriteLimitedScenario(pkgDepCache &Cache, FileFd &output, { if (Progress != NULL) Progress->SubProgress(Cache.Head().VersionCount, _("Send scenario to solver")); - unsigned long p = 0; + decltype(Cache.Head().PackageCount) p = 0; bool Okay = output.Failed() == false; for (auto Pkg = Cache.PkgBegin(); Pkg.end() == false && likely(Okay); ++Pkg, ++p) { @@ -502,7 +502,7 @@ bool EDSP::WriteRequest(pkgDepCache &Cache, FILE* output, bool const Upgrade, { if (Progress != NULL) Progress->SubProgress(Cache.Head().PackageCount, _("Send request to solver")); - unsigned long p = 0; + decltype(Cache.Head().PackageCount) p = 0; string del, inst; for (pkgCache::PkgIterator Pkg = Cache.PkgBegin(); Pkg.end() == false; ++Pkg, ++p) { @@ -556,7 +556,7 @@ bool EDSP::WriteRequest(pkgDepCache &Cache, FileFd &output, { if (Progress != NULL) Progress->SubProgress(Cache.Head().PackageCount, _("Send request to solver")); - unsigned long p = 0; + decltype(Cache.Head().PackageCount) p = 0; string del, inst; for (pkgCache::PkgIterator Pkg = Cache.PkgBegin(); Pkg.end() == false; ++Pkg, ++p) { @@ -618,8 +618,8 @@ bool EDSP::ReadResponse(int const input, pkgDepCache &Cache, OpProgress *Progres In theory we could use the offset as ID, but then VersionCount couldn't be used to create other versionmappings anymore and it would be too easy for a (buggy) solver to segfault APT… */ - unsigned long long const VersionCount = Cache.Head().VersionCount; - unsigned long VerIdx[VersionCount]; + auto VersionCount = Cache.Head().VersionCount; + decltype(VersionCount) VerIdx[VersionCount]; for (pkgCache::PkgIterator P = Cache.PkgBegin(); P.end() == false; ++P) { for (pkgCache::VerIterator V = P.VersionList(); V.end() == false; ++V) VerIdx[V->ID] = V.Index(); @@ -675,11 +675,11 @@ bool EDSP::ReadResponse(int const input, pkgDepCache &Cache, OpProgress *Progres continue; } - size_t const id = section.FindULL(type.c_str(), VersionCount); + decltype(VersionCount) const id = section.FindULL(type.c_str(), VersionCount); if (id == VersionCount) { _error->Warning("Unable to parse %s request with id value '%s'!", type.c_str(), section.FindS(type.c_str()).c_str()); continue; - } else if (id > Cache.Head().VersionCount) { + } else if (id > VersionCount) { _error->Warning("ID value '%s' in %s request stanza is to high to refer to a known version!", section.FindS(type.c_str()).c_str(), type.c_str()); continue; } @@ -1163,7 +1163,7 @@ bool EIPP::WriteRequest(pkgDepCache &Cache, FileFd &output, /*{{{*/ { if (Progress != NULL) Progress->SubProgress(Cache.Head().PackageCount, _("Send request to planner")); - unsigned long p = 0; + decltype(Cache.Head().PackageCount) p = 0; string del, inst, reinst; for (pkgCache::PkgIterator Pkg = Cache.PkgBegin(); Pkg.end() == false; ++Pkg, ++p) { @@ -1253,7 +1253,7 @@ bool EIPP::WriteScenario(pkgDepCache &Cache, FileFd &output, OpProgress * const { if (Progress != NULL) Progress->SubProgress(Cache.Head().PackageCount, _("Send scenario to planner")); - unsigned long p = 0; + decltype(Cache.Head().PackageCount) p = 0; bool Okay = output.Failed() == false; std::vector<std::string> archs = APT::Configuration::getArchitectures(); std::vector<bool> pkgset(Cache.Head().PackageCount, false); @@ -1328,8 +1328,8 @@ bool EIPP::ReadResponse(int const input, pkgPackageManager * const PM, OpProgres In theory we could use the offset as ID, but then VersionCount couldn't be used to create other versionmappings anymore and it would be too easy for a (buggy) solver to segfault APT… */ - unsigned long long const VersionCount = PM->Cache.Head().VersionCount; - unsigned long VerIdx[VersionCount]; + auto VersionCount = PM->Cache.Head().VersionCount; + decltype(VersionCount) VerIdx[VersionCount]; for (pkgCache::PkgIterator P = PM->Cache.PkgBegin(); P.end() == false; ++P) { for (pkgCache::VerIterator V = P.VersionList(); V.end() == false; ++V) VerIdx[V->ID] = V.Index(); @@ -1384,11 +1384,11 @@ bool EIPP::ReadResponse(int const input, pkgPackageManager * const PM, OpProgres if (type == nullptr) continue; - size_t const id = section.FindULL(type, VersionCount); + decltype(VersionCount) const id = section.FindULL(type, VersionCount); if (id == VersionCount) { _error->Warning("Unable to parse %s request with id value '%s'!", type, section.FindS(type).c_str()); continue; - } else if (id > PM->Cache.Head().VersionCount) { + } else if (id > VersionCount) { _error->Warning("ID value '%s' in %s request stanza is to high to refer to a known version!", section.FindS(type).c_str(), type); continue; } diff --git a/apt-pkg/orderlist.cc b/apt-pkg/orderlist.cc index 0be0cc8df..98793e6a9 100644 --- a/apt-pkg/orderlist.cc +++ b/apt-pkg/orderlist.cc @@ -93,7 +93,7 @@ pkgOrderList::pkgOrderList(pkgDepCache *pCache) : d(NULL), Cache(*pCache), /* Construct the arrays, egcs 1.0.1 bug requires the package count hack */ - unsigned long Size = Cache.Head().PackageCount; + auto const Size = Cache.Head().PackageCount; Flags = new unsigned short[Size]; End = List = new Package *[Size]; memset(Flags,0,sizeof(*Flags)*Size); @@ -1056,8 +1056,8 @@ bool pkgOrderList::AddLoop(DepIterator D) /* */ void pkgOrderList::WipeFlags(unsigned long F) { - unsigned long Size = Cache.Head().PackageCount; - for (unsigned long I = 0; I != Size; I++) + auto Size = Cache.Head().PackageCount; + for (decltype(Size) I = 0; I != Size; ++I) Flags[I] &= ~F; } /*}}}*/ diff --git a/apt-pkg/policy.cc b/apt-pkg/policy.cc index 3dd6ddac4..e87ba3ee2 100644 --- a/apt-pkg/policy.cc +++ b/apt-pkg/policy.cc @@ -50,12 +50,14 @@ pkgPolicy::pkgPolicy(pkgCache *Owner) : Pins(nullptr), VerPins(nullptr), if (Owner == 0) return; PFPriority = new signed short[Owner->Head().PackageFileCount]; - Pins = new Pin[Owner->Head().PackageCount]; + auto PackageCount = Owner->Head().PackageCount; + Pins = new Pin[PackageCount]; VerPins = new Pin[Owner->Head().VersionCount]; - for (unsigned long I = 0; I != Owner->Head().PackageCount; I++) + for (decltype(PackageCount) I = 0; I != PackageCount; ++I) Pins[I].Type = pkgVersionMatch::None; - for (unsigned long I = 0; I != Owner->Head().VersionCount; I++) + auto VersionCount = Owner->Head().VersionCount; + for (decltype(VersionCount) I = 0; I != VersionCount; ++I) VerPins[I].Type = pkgVersionMatch::None; // The config file has a master override. |