From 3568a640bd363409cdeb1cb69eaa3261c79f2ff2 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Fri, 5 Aug 2011 12:26:35 +0200 Subject: * apt-pkg/acquire-item.cc: - if no Release.gpg file is found, still load the hashes for verification (closes: #636314) and add test --- apt-pkg/acquire-item.cc | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'apt-pkg') diff --git a/apt-pkg/acquire-item.cc b/apt-pkg/acquire-item.cc index 215615bdd..ebd8d5a12 100644 --- a/apt-pkg/acquire-item.cc +++ b/apt-pkg/acquire-item.cc @@ -1258,8 +1258,9 @@ void pkgAcqMetaIndex::Done(string Message,unsigned long Size,string Hash, /*{{{* if (SigFile == "") { // There was no signature file, so we are finished. Download - // the indexes without verification. - QueueIndexes(false); + // the indexes and do hashsum verification + MetaIndexParser->Load(DestFile); + QueueIndexes(true); } else { -- cgit v1.2.3 From 96d14a91ce56150040d9c21cdce381cedc4c2518 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Mon, 8 Aug 2011 16:14:13 +0200 Subject: apt-pkg/pkgcachegen.cc: fix incorrect test for modification time --- apt-pkg/pkgcachegen.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'apt-pkg') diff --git a/apt-pkg/pkgcachegen.cc b/apt-pkg/pkgcachegen.cc index 2bfb77609..7539e1b94 100644 --- a/apt-pkg/pkgcachegen.cc +++ b/apt-pkg/pkgcachegen.cc @@ -935,7 +935,7 @@ static bool CheckValidity(const string &CacheFile, return false; } - if (List.GetLastModifiedTime() < GetModificationTime(CacheFile)) + if (List.GetLastModifiedTime() > GetModificationTime(CacheFile)) { if (Debug == true) std::clog << "sources.list is newer than the cache" << std::endl; -- cgit v1.2.3 From 02734b011499cebc763b6700072a4df2abb5afb4 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Mon, 8 Aug 2011 16:14:54 +0200 Subject: apt-pkg/acquire-item.cc: add more debug output --- apt-pkg/acquire-item.cc | 1 + 1 file changed, 1 insertion(+) (limited to 'apt-pkg') diff --git a/apt-pkg/acquire-item.cc b/apt-pkg/acquire-item.cc index ebd8d5a12..9313c4b47 100644 --- a/apt-pkg/acquire-item.cc +++ b/apt-pkg/acquire-item.cc @@ -1397,6 +1397,7 @@ void pkgAcqMetaIndex::QueueIndexes(bool verify) /*{{{*/ { std::cerr << "Queueing: " << (*Target)->URI << std::endl; std::cerr << "Expected Hash: " << ExpectedIndexHash.toStr() << std::endl; + std::cerr << "For: " << Record->MetaKeyFilename << std::endl; } if (ExpectedIndexHash.empty() == true && (*Target)->IsOptional() == false) { -- cgit v1.2.3 From b40b7c380acbdcd84338bdcd253df32f1ef79ed8 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Thu, 11 Aug 2011 18:42:19 +0200 Subject: cppcheck is right that the check for preventing null deference of Query is redundant in Redirect() as we can't reach the code with null anyway [apt-pkg/acquire-method.cc:433]: (error) Possible null pointer dereference: Queue - otherwise it is redundant to check if Queue is null at line 425 --- apt-pkg/acquire-method.cc | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) (limited to 'apt-pkg') diff --git a/apt-pkg/acquire-method.cc b/apt-pkg/acquire-method.cc index e9e102488..79a7519a8 100644 --- a/apt-pkg/acquire-method.cc +++ b/apt-pkg/acquire-method.cc @@ -421,12 +421,8 @@ void pkgAcqMethod::Status(const char *Format,...) to keep the pipeline synchronized. */ void pkgAcqMethod::Redirect(const string &NewURI) { - std::cout << "103 Redirect\nURI: "; - if (Queue != 0) - std::cout << Queue->Uri << "\n"; - else - std::cout << "\n"; - std::cout << "New-URI: " << NewURI << "\n" + std::cout << "103 Redirect\nURI: " << Queue->Uri << "\n" + << "New-URI: " << NewURI << "\n" << "\n" << std::flush; // Change the URI for the request. -- cgit v1.2.3 From dd6882853b4555a6113740afca417acbaa060043 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Thu, 11 Aug 2011 19:20:53 +0200 Subject: fix some cppcheck: (warning) Member variable is not initialized in the constructor. --- apt-pkg/aptconfiguration.h | 3 ++- apt-pkg/indexfile.cc | 3 ++- apt-pkg/tagfile.h | 2 +- 3 files changed, 5 insertions(+), 3 deletions(-) (limited to 'apt-pkg') diff --git a/apt-pkg/aptconfiguration.h b/apt-pkg/aptconfiguration.h index 1f0399dd2..e098d0fd6 100644 --- a/apt-pkg/aptconfiguration.h +++ b/apt-pkg/aptconfiguration.h @@ -13,6 +13,7 @@ // Include Files /*{{{*/ #include #include +#include /*}}}*/ namespace APT { class Configuration { /*{{{*/ @@ -94,7 +95,7 @@ public: /*{{{*/ Compressor(char const *name, char const *extension, char const *binary, char const *compressArg, char const *uncompressArg, unsigned short const cost); - Compressor() {}; + Compressor() : Cost(std::numeric_limits::max()) {}; }; /** \brief Return a vector of Compressors supported for data.tar's diff --git a/apt-pkg/indexfile.cc b/apt-pkg/indexfile.cc index 37be87055..f18ddbfaa 100644 --- a/apt-pkg/indexfile.cc +++ b/apt-pkg/indexfile.cc @@ -27,7 +27,8 @@ unsigned long pkgIndexFile::Type::GlobalListLen = 0; pkgIndexFile::Type::Type() { ItmList[GlobalListLen] = this; - GlobalListLen++; + GlobalListLen++; + Label = NULL; } /*}}}*/ // Type::GetType - Locate the type by name /*{{{*/ diff --git a/apt-pkg/tagfile.h b/apt-pkg/tagfile.h index 61491aa04..a101d7b1e 100644 --- a/apt-pkg/tagfile.h +++ b/apt-pkg/tagfile.h @@ -79,7 +79,7 @@ class pkgTagSection Stop = this->Stop; }; - pkgTagSection() : Section(0), Stop(0) {}; + pkgTagSection() : Section(0), TagCount(0), Stop(0) {}; }; class pkgTagFile -- cgit v1.2.3 From f7f0d6c7560a8f71707e7852a512469147aa9f84 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Thu, 11 Aug 2011 20:53:28 +0200 Subject: cppcheck complains about some possible speed improvements which could be done on the mirco-optimazation level, so lets fix them: (performance) Possible inefficient checking for emptiness. (performance) Prefer prefix ++/-- operators for non-primitive types. --- apt-pkg/acquire-item.cc | 22 +++++++------- apt-pkg/acquire-method.cc | 2 +- apt-pkg/acquire.cc | 20 ++++++------- apt-pkg/algorithms.cc | 62 ++++++++++++++++++++-------------------- apt-pkg/aptconfiguration.cc | 4 +-- apt-pkg/cdrom.cc | 26 ++++++++--------- apt-pkg/clean.cc | 4 +-- apt-pkg/contrib/configuration.cc | 6 ++-- apt-pkg/contrib/error.cc | 6 ++-- apt-pkg/contrib/strutl.cc | 30 +++++++++---------- apt-pkg/deb/debindexfile.cc | 6 ++-- apt-pkg/deb/deblistparser.cc | 2 +- apt-pkg/deb/debmetaindex.cc | 12 ++++---- apt-pkg/deb/debrecords.cc | 2 +- apt-pkg/deb/dpkgpm.cc | 20 ++++++------- apt-pkg/depcache.cc | 28 +++++++++--------- apt-pkg/indexcopy.cc | 18 ++++++------ apt-pkg/orderlist.cc | 16 +++++------ apt-pkg/packagemanager.cc | 20 ++++++------- apt-pkg/pkgcache.cc | 26 ++++++++--------- apt-pkg/pkgcachegen.cc | 28 +++++++++--------- apt-pkg/pkgrecords.cc | 2 +- apt-pkg/policy.cc | 14 ++++----- apt-pkg/sourcelist.cc | 14 ++++----- apt-pkg/srcrecords.cc | 10 +++---- apt-pkg/vendorlist.cc | 6 ++-- apt-pkg/versionmatch.cc | 6 ++-- 27 files changed, 206 insertions(+), 206 deletions(-) (limited to 'apt-pkg') diff --git a/apt-pkg/acquire-item.cc b/apt-pkg/acquire-item.cc index 7eb5920e0..2a514b088 100644 --- a/apt-pkg/acquire-item.cc +++ b/apt-pkg/acquire-item.cc @@ -681,17 +681,17 @@ bool pkgAcqIndexDiffs::QueueNextDiff() /*{{{*/ // remove all patches until the next matching patch is found // this requires the Index file to be ordered for(vector::iterator I=available_patches.begin(); - available_patches.size() > 0 && + available_patches.empty() == false && I != available_patches.end() && - (*I).sha1 != local_sha1; - I++) + I->sha1 != local_sha1; + ++I) { available_patches.erase(I); } // error checking and falling back if no patch was found - if(available_patches.size() == 0) - { + if(available_patches.empty() == true) + { Failed("", NULL); return false; } @@ -756,7 +756,7 @@ void pkgAcqIndexDiffs::Done(string Message,unsigned long Size,string Md5Hash, /* chmod(FinalFile.c_str(),0644); // see if there is more to download - if(available_patches.size() > 0) { + if(available_patches.empty() == false) { new pkgAcqIndexDiffs(Owner, RealURI, Description, Desc.ShortDesc, ExpectedHash, ServerSha1, available_patches); return Finish(); @@ -1375,7 +1375,7 @@ void pkgAcqMetaIndex::QueueIndexes(bool verify) /*{{{*/ #endif for (vector ::const_iterator Target = IndexTargets->begin(); Target != IndexTargets->end(); - Target++) + ++Target) { HashString ExpectedIndexHash; if (verify) @@ -1672,7 +1672,7 @@ pkgAcqArchive::pkgAcqArchive(pkgAcquire *Owner,pkgSourceList *Sources, // check if we have one trusted source for the package. if so, switch // to "TrustedOnly" mode - for (pkgCache::VerFileIterator i = Version.FileList(); i.end() == false; i++) + for (pkgCache::VerFileIterator i = Version.FileList(); i.end() == false; ++i) { pkgIndexFile *Index; if (Sources->FindIndex(i.File(),Index) == false) @@ -1709,7 +1709,7 @@ pkgAcqArchive::pkgAcqArchive(pkgAcquire *Owner,pkgSourceList *Sources, bool pkgAcqArchive::QueueNext() { string const ForceHash = _config->Find("Acquire::ForceHash"); - for (; Vf.end() == false; Vf++) + for (; Vf.end() == false; ++Vf) { // Ignore not source sources if ((Vf.File()->Flags & pkgCache::Flag::NotSource) != 0) @@ -1820,7 +1820,7 @@ bool pkgAcqArchive::QueueNext() Desc.ShortDesc = Version.ParentPkg().Name(); QueueURI(Desc); - Vf++; + ++Vf; return true; } return false; @@ -1894,7 +1894,7 @@ void pkgAcqArchive::Failed(string Message,pkgAcquire::MethodConfig *Cnf) StringToBool(LookupTag(Message,"Transient-Failure"),false) == true) { // Vf = Version.FileList(); - while (Vf.end() == false) Vf++; + while (Vf.end() == false) ++Vf; StoreFilename = string(); Item::Failed(Message,Cnf); return; diff --git a/apt-pkg/acquire-method.cc b/apt-pkg/acquire-method.cc index 79a7519a8..7e9061e56 100644 --- a/apt-pkg/acquire-method.cc +++ b/apt-pkg/acquire-method.cc @@ -81,7 +81,7 @@ void pkgAcqMethod::Fail(bool Transient) void pkgAcqMethod::Fail(string Err,bool Transient) { // Strip out junk from the error messages - for (string::iterator I = Err.begin(); I != Err.end(); I++) + for (string::iterator I = Err.begin(); I != Err.end(); ++I) { if (*I == '\r') *I = ' '; diff --git a/apt-pkg/acquire.cc b/apt-pkg/acquire.cc index 9478cdfb4..a2da196be 100644 --- a/apt-pkg/acquire.cc +++ b/apt-pkg/acquire.cc @@ -116,7 +116,7 @@ pkgAcquire::~pkgAcquire() /* */ void pkgAcquire::Shutdown() { - while (Items.size() != 0) + while (Items.empty() == false) { if (Items[0]->Status == Item::StatFetching) Items[0]->Status = Item::StatError; @@ -155,7 +155,7 @@ void pkgAcquire::Remove(Item *Itm) I = Items.begin(); } else - I++; + ++I; } } /*}}}*/ @@ -411,7 +411,7 @@ pkgAcquire::RunResult pkgAcquire::Run(int PulseIntervall) I->Shutdown(false); // Shut down the items - for (ItemIterator I = Items.begin(); I != Items.end(); I++) + for (ItemIterator I = Items.begin(); I != Items.end(); ++I) (*I)->Finished(); if (_error->PendingError()) @@ -467,7 +467,7 @@ bool pkgAcquire::Clean(string Dir) // Look in the get list ItemCIterator I = Items.begin(); - for (; I != Items.end(); I++) + for (; I != Items.end(); ++I) if (flNotDir((*I)->DestFile) == Dir->d_name) break; @@ -488,7 +488,7 @@ bool pkgAcquire::Clean(string Dir) unsigned long long pkgAcquire::TotalNeeded() { unsigned long long Total = 0; - for (ItemCIterator I = ItemsBegin(); I != ItemsEnd(); I++) + for (ItemCIterator I = ItemsBegin(); I != ItemsEnd(); ++I) Total += (*I)->FileSize; return Total; } @@ -499,7 +499,7 @@ unsigned long long pkgAcquire::TotalNeeded() unsigned long long pkgAcquire::FetchNeeded() { unsigned long long Total = 0; - for (ItemCIterator I = ItemsBegin(); I != ItemsEnd(); I++) + for (ItemCIterator I = ItemsBegin(); I != ItemsEnd(); ++I) if ((*I)->Local == false) Total += (*I)->FileSize; return Total; @@ -511,7 +511,7 @@ unsigned long long pkgAcquire::FetchNeeded() unsigned long long pkgAcquire::PartialPresent() { unsigned long long Total = 0; - for (ItemCIterator I = ItemsBegin(); I != ItemsEnd(); I++) + for (ItemCIterator I = ItemsBegin(); I != ItemsEnd(); ++I) if ((*I)->Local == false) Total += (*I)->PartialSize; return Total; @@ -781,11 +781,11 @@ bool pkgAcquireStatus::Pulse(pkgAcquire *Owner) unsigned int Unknown = 0; unsigned int Count = 0; for (pkgAcquire::ItemCIterator I = Owner->ItemsBegin(); I != Owner->ItemsEnd(); - I++, Count++) + ++I, ++Count) { TotalItems++; if ((*I)->Status == pkgAcquire::Item::StatDone) - CurrentItems++; + ++CurrentItems; // Totally ignore local items if ((*I)->Local == true) @@ -795,7 +795,7 @@ bool pkgAcquireStatus::Pulse(pkgAcquire *Owner) if ((*I)->Complete == true) CurrentBytes += (*I)->FileSize; if ((*I)->FileSize == 0 && (*I)->Complete == false) - Unknown++; + ++Unknown; } // Compute the current completion diff --git a/apt-pkg/algorithms.cc b/apt-pkg/algorithms.cc index 7c911b865..5fbcb47be 100644 --- a/apt-pkg/algorithms.cc +++ b/apt-pkg/algorithms.cc @@ -91,7 +91,7 @@ bool pkgSimulate::Install(PkgIterator iPkg,string /*File*/) Sim.MarkInstall(Pkg,false); // Look for broken conflicts+predepends. - for (PkgIterator I = Sim.PkgBegin(); I.end() == false; I++) + for (PkgIterator I = Sim.PkgBegin(); I.end() == false; ++I) { if (Sim[I].InstallVer == 0) continue; @@ -140,7 +140,7 @@ bool pkgSimulate::Configure(PkgIterator iPkg) Sim.Update(); // Print out each package and the failed dependencies - for (pkgCache::DepIterator D = Sim[Pkg].InstVerIter(Sim).DependsList(); D.end() == false; D++) + for (pkgCache::DepIterator D = Sim[Pkg].InstVerIter(Sim).DependsList(); D.end() == false; ++D) { if (Sim.IsImportantDep(D) == false || (Sim[D] & pkgDepCache::DepInstall) != 0) @@ -204,7 +204,7 @@ bool pkgSimulate::Remove(PkgIterator iPkg,bool Purge) void pkgSimulate::ShortBreaks() { cout << " ["; - for (PkgIterator I = Sim.PkgBegin(); I.end() == false; I++) + for (PkgIterator I = Sim.PkgBegin(); I.end() == false; ++I) { if (Sim[I].InstBroken() == true) { @@ -226,7 +226,7 @@ bool pkgApplyStatus(pkgDepCache &Cache) { pkgDepCache::ActionGroup group(Cache); - for (pkgCache::PkgIterator I = Cache.PkgBegin(); I.end() == false; I++) + for (pkgCache::PkgIterator I = Cache.PkgBegin(); I.end() == false; ++I) { if (I->VersionList == 0) continue; @@ -295,13 +295,13 @@ bool pkgFixBroken(pkgDepCache &Cache) pkgDepCache::ActionGroup group(Cache); // Auto upgrade all broken packages - for (pkgCache::PkgIterator I = Cache.PkgBegin(); I.end() == false; I++) + for (pkgCache::PkgIterator I = Cache.PkgBegin(); I.end() == false; ++I) if (Cache[I].NowBroken() == true) Cache.MarkInstall(I, true, 0, false); /* Fix packages that are in a NeedArchive state but don't have a downloadable install version */ - for (pkgCache::PkgIterator I = Cache.PkgBegin(); I.end() == false; I++) + for (pkgCache::PkgIterator I = Cache.PkgBegin(); I.end() == false; ++I) { if (I.State() != pkgCache::PkgIterator::NeedsUnpack || Cache[I].Delete() == true) @@ -338,19 +338,19 @@ bool pkgDistUpgrade(pkgDepCache &Cache) /* Auto upgrade all installed packages, this provides the basis for the installation */ - for (pkgCache::PkgIterator I = Cache.PkgBegin(); I.end() == false; I++) + for (pkgCache::PkgIterator I = Cache.PkgBegin(); I.end() == false; ++I) if (I->CurrentVer != 0) Cache.MarkInstall(I, true, 0, false); /* Now, auto upgrade all essential packages - this ensures that the essential packages are present and working */ - for (pkgCache::PkgIterator I = Cache.PkgBegin(); I.end() == false; I++) + for (pkgCache::PkgIterator I = Cache.PkgBegin(); I.end() == false; ++I) if ((I->Flags & pkgCache::Flag::Essential) == pkgCache::Flag::Essential) Cache.MarkInstall(I, true, 0, false); /* We do it again over all previously installed packages to force conflict resolution on them all. */ - for (pkgCache::PkgIterator I = Cache.PkgBegin(); I.end() == false; I++) + for (pkgCache::PkgIterator I = Cache.PkgBegin(); I.end() == false; ++I) if (I->CurrentVer != 0) Cache.MarkInstall(I, false, 0, false); @@ -359,7 +359,7 @@ bool pkgDistUpgrade(pkgDepCache &Cache) // Hold back held packages. if (_config->FindB("APT::Ignore-Hold",false) == false) { - for (pkgCache::PkgIterator I = Cache.PkgBegin(); I.end() == false; I++) + for (pkgCache::PkgIterator I = Cache.PkgBegin(); I.end() == false; ++I) { if (I->SelectedState == pkgCache::State::Hold) { @@ -387,7 +387,7 @@ bool pkgAllUpgrade(pkgDepCache &Cache) return false; // Upgrade all installed packages - for (pkgCache::PkgIterator I = Cache.PkgBegin(); I.end() == false; I++) + for (pkgCache::PkgIterator I = Cache.PkgBegin(); I.end() == false; ++I) { if (Cache[I].Install() == true) Fix.Protect(I); @@ -421,7 +421,7 @@ bool pkgMinimizeUpgrade(pkgDepCache &Cache) do { Change = false; - for (pkgCache::PkgIterator I = Cache.PkgBegin(); I.end() == false; I++) + for (pkgCache::PkgIterator I = Cache.PkgBegin(); I.end() == false; ++I) { // Not interesting if (Cache[I].Upgrade() == false || Cache[I].NewInstall() == true) @@ -438,7 +438,7 @@ bool pkgMinimizeUpgrade(pkgDepCache &Cache) Change = true; } } - Count++; + ++Count; } while (Change == true && Count < 10); @@ -525,7 +525,7 @@ void pkgProblemResolver::MakeScores() << " AddEssential => " << AddEssential << endl; // Generate the base scores for a package based on its properties - for (pkgCache::PkgIterator I = Cache.PkgBegin(); I.end() == false; I++) + for (pkgCache::PkgIterator I = Cache.PkgBegin(); I.end() == false; ++I) { if (Cache[I].InstallVer == 0) continue; @@ -552,12 +552,12 @@ void pkgProblemResolver::MakeScores() } // Now that we have the base scores we go and propogate dependencies - for (pkgCache::PkgIterator I = Cache.PkgBegin(); I.end() == false; I++) + for (pkgCache::PkgIterator I = Cache.PkgBegin(); I.end() == false; ++I) { if (Cache[I].InstallVer == 0) continue; - for (pkgCache::DepIterator D = Cache[I].InstVerIter(Cache).DependsList(); D.end() == false; D++) + for (pkgCache::DepIterator D = Cache[I].InstVerIter(Cache).DependsList(); D.end() == false; ++D) { if (D->Type == pkgCache::Dep::Depends || D->Type == pkgCache::Dep::PreDepends) @@ -574,12 +574,12 @@ void pkgProblemResolver::MakeScores() /* Now we cause 1 level of dependency inheritance, that is we add the score of the packages that depend on the target Package. This fortifies high scoring packages */ - for (pkgCache::PkgIterator I = Cache.PkgBegin(); I.end() == false; I++) + for (pkgCache::PkgIterator I = Cache.PkgBegin(); I.end() == false; ++I) { if (Cache[I].InstallVer == 0) continue; - for (pkgCache::DepIterator D = I.RevDependsList(); D.end() == false; D++) + for (pkgCache::DepIterator D = I.RevDependsList(); D.end() == false; ++D) { // Only do it for the install version if ((pkgCache::Version *)D.ParentVer() != Cache[D.ParentPkg()].InstallVer || @@ -594,9 +594,9 @@ void pkgProblemResolver::MakeScores() /* Now we propogate along provides. This makes the packages that provide important packages extremely important */ - for (pkgCache::PkgIterator I = Cache.PkgBegin(); I.end() == false; I++) + for (pkgCache::PkgIterator I = Cache.PkgBegin(); I.end() == false; ++I) { - for (pkgCache::PrvIterator P = I.ProvidesList(); P.end() == false; P++) + for (pkgCache::PrvIterator P = I.ProvidesList(); P.end() == false; ++P) { // Only do it once per package if ((pkgCache::Version *)P.OwnerVer() != Cache[P.OwnerPkg()].InstallVer) @@ -607,7 +607,7 @@ void pkgProblemResolver::MakeScores() /* Protected things are pushed really high up. This number should put them ahead of everything */ - for (pkgCache::PkgIterator I = Cache.PkgBegin(); I.end() == false; I++) + for (pkgCache::PkgIterator I = Cache.PkgBegin(); I.end() == false; ++I) { if ((Flags[I->ID] & Protected) != 0) Scores[I->ID] += AddProtected; @@ -704,7 +704,7 @@ bool pkgProblemResolver::DoUpgrade(pkgCache::PkgIterator Pkg) if (Start == End) break; - Start++; + ++Start; } if (Fail == true) break; @@ -750,7 +750,7 @@ bool pkgProblemResolver::Resolve(bool BrokenFix) do { Again = false; - for (pkgCache::PkgIterator I = Cache.PkgBegin(); I.end() == false; I++) + for (pkgCache::PkgIterator I = Cache.PkgBegin(); I.end() == false; ++I) { if (Cache[I].Install() == true) Flags[I->ID] |= PreInstalled; @@ -781,7 +781,7 @@ bool pkgProblemResolver::Resolve(bool BrokenFix) would cause the removal of even lower score packages. */ SPtrArray PList = new pkgCache::Package *[Size]; pkgCache::Package **PEnd = PList; - for (pkgCache::PkgIterator I = Cache.PkgBegin(); I.end() == false; I++) + for (pkgCache::PkgIterator I = Cache.PkgBegin(); I.end() == false; ++I) *PEnd++ = I; This = this; qsort(PList,PEnd - PList,sizeof(*PList),&ScoreSort); @@ -901,7 +901,7 @@ bool pkgProblemResolver::Resolve(bool BrokenFix) } else { - Start++; + ++Start; // We only worry about critical deps. if (Start.IsCritical() != true) continue; @@ -1150,7 +1150,7 @@ bool pkgProblemResolver::Resolve(bool BrokenFix) { // See if this is the result of a hold pkgCache::PkgIterator I = Cache.PkgBegin(); - for (;I.end() != true; I++) + for (;I.end() != true; ++I) { if (Cache[I].InstBroken() == false) continue; @@ -1162,7 +1162,7 @@ bool pkgProblemResolver::Resolve(bool BrokenFix) // set the auto-flags (mvo: I'm not sure if we _really_ need this) pkgCache::PkgIterator I = Cache.PkgBegin(); - for (;I.end() != true; I++) { + for (;I.end() != true; ++I) { if (Cache[I].NewInstall() && !(Flags[I->ID] & PreInstalled)) { if(_config->FindI("Debug::pkgAutoRemove",false)) { std::clog << "Resolve installed new pkg: " << I.FullName(false) @@ -1220,7 +1220,7 @@ bool pkgProblemResolver::ResolveByKeep() would cause the removal of even lower score packages. */ pkgCache::Package **PList = new pkgCache::Package *[Size]; pkgCache::Package **PEnd = PList; - for (pkgCache::PkgIterator I = Cache.PkgBegin(); I.end() == false; I++) + for (pkgCache::PkgIterator I = Cache.PkgBegin(); I.end() == false; ++I) *PEnd++ = I; This = this; qsort(PList,PEnd - PList,sizeof(*PList),&ScoreSort); @@ -1317,7 +1317,7 @@ bool pkgProblemResolver::ResolveByKeep() if (Start == End) break; - Start++; + ++Start; } if (InstOrNewPolicyBroken(I) == false) @@ -1344,7 +1344,7 @@ void pkgProblemResolver::InstallProtect() { pkgDepCache::ActionGroup group(Cache); - for (pkgCache::PkgIterator I = Cache.PkgBegin(); I.end() == false; I++) + for (pkgCache::PkgIterator I = Cache.PkgBegin(); I.end() == false; ++I) { if ((Flags[I->ID] & Protected) == Protected) { @@ -1424,7 +1424,7 @@ bool ListUpdate(pkgAcquireStatus &Stat, bool Failed = false; bool TransientNetworkFailure = false; for (pkgAcquire::ItemIterator I = Fetcher.ItemsBegin(); - I != Fetcher.ItemsEnd(); I++) + I != Fetcher.ItemsEnd(); ++I) { if ((*I)->Status == pkgAcquire::Item::StatDone) continue; diff --git a/apt-pkg/aptconfiguration.cc b/apt-pkg/aptconfiguration.cc index 9ccbeecf1..6ec5fa03a 100644 --- a/apt-pkg/aptconfiguration.cc +++ b/apt-pkg/aptconfiguration.cc @@ -53,7 +53,7 @@ const Configuration::getCompressionTypes(bool const &Cached) { // load the order setting into our vector std::vector const order = _config->FindVector("Acquire::CompressionTypes::Order"); for (std::vector::const_iterator o = order.begin(); - o != order.end(); o++) { + o != order.end(); ++o) { if ((*o).empty() == true) continue; // ignore types we have no method ready to use @@ -274,7 +274,7 @@ std::vector const Configuration::getLanguages(bool const &All, // then needed and ensure the codes are not listed twice. bool noneSeen = false; for (std::vector::const_iterator l = lang.begin(); - l != lang.end(); l++) { + l != lang.end(); ++l) { if (*l == "environment") { for (std::vector::const_iterator e = environment.begin(); e != environment.end(); ++e) { diff --git a/apt-pkg/cdrom.cc b/apt-pkg/cdrom.cc index 2a914c665..b8acf0cbe 100644 --- a/apt-pkg/cdrom.cc +++ b/apt-pkg/cdrom.cc @@ -310,7 +310,7 @@ void pkgCdrom::ReduceSourcelist(string CD,vector &List) sort(List.begin(),List.end()); // Collect similar entries - for (vector::iterator I = List.begin(); I != List.end(); I++) + for (vector::iterator I = List.begin(); I != List.end(); ++I) { // Find a space.. string::size_type Space = (*I).find(' '); @@ -322,7 +322,7 @@ void pkgCdrom::ReduceSourcelist(string CD,vector &List) string Word1 = string(*I,Space,SSpace-Space); string Prefix = string(*I,0,Space); - for (vector::iterator J = List.begin(); J != I; J++) + for (vector::iterator J = List.begin(); J != I; ++J) { // Find a space.. string::size_type Space2 = (*J).find(' '); @@ -405,7 +405,7 @@ bool pkgCdrom::WriteDatabase(Configuration &Cnf) that were the same. */ bool pkgCdrom::WriteSourceList(string Name,vector &List,bool Source) { - if (List.size() == 0) + if (List.empty() == true) return true; string File = _config->FindFile("Dir::Etc::sourcelist"); @@ -455,7 +455,7 @@ bool pkgCdrom::WriteSourceList(string Name,vector &List,bool Source) if (First == true) { - for (vector::iterator I = List.begin(); I != List.end(); I++) + for (vector::iterator I = List.begin(); I != List.end(); ++I) { string::size_type Space = (*I).find(' '); if (Space == string::npos) @@ -489,7 +489,7 @@ bool pkgCdrom::WriteSourceList(string Name,vector &List,bool Source) // Just in case the file was empty if (First == true) { - for (vector::iterator I = List.begin(); I != List.end(); I++) + for (vector::iterator I = List.begin(); I != List.end(); ++I) { string::size_type Space = (*I).find(' '); if (Space == string::npos) @@ -661,13 +661,13 @@ bool pkgCdrom::Add(pkgCdromStatus *log) /*{{{*/ if (_config->FindB("Debug::aptcdrom",false) == true) { cout << "I found (binary):" << endl; - for (vector::iterator I = List.begin(); I != List.end(); I++) + for (vector::iterator I = List.begin(); I != List.end(); ++I) cout << *I << endl; cout << "I found (source):" << endl; - for (vector::iterator I = SourceList.begin(); I != SourceList.end(); I++) + for (vector::iterator I = SourceList.begin(); I != SourceList.end(); ++I) cout << *I << endl; cout << "I found (Signatures):" << endl; - for (vector::iterator I = SigList.begin(); I != SigList.end(); I++) + for (vector::iterator I = SigList.begin(); I != SigList.end(); ++I) cout << *I << endl; } @@ -688,7 +688,7 @@ bool pkgCdrom::Add(pkgCdromStatus *log) /*{{{*/ log->Update(msg.str(), STEP_SCAN); } - if (List.size() == 0 && SourceList.size() == 0) + if (List.empty() == true && SourceList.empty() == true) { if (_config->FindB("APT::CDROM::NoMount",false) == false) UnmountCdrom(CDROM); @@ -712,7 +712,7 @@ bool pkgCdrom::Add(pkgCdromStatus *log) /*{{{*/ { // Escape special characters string::iterator J = Name.begin(); - for (; J != Name.end(); J++) + for (; J != Name.end(); ++J) if (*J == '"' || *J == ']' || *J == '[') *J = '_'; @@ -757,7 +757,7 @@ bool pkgCdrom::Add(pkgCdromStatus *log) /*{{{*/ // Escape special characters string::iterator J = Name.begin(); - for (; J != Name.end(); J++) + for (; J != Name.end(); ++J) if (*J == '"' || *J == ']' || *J == '[') *J = '_'; @@ -804,7 +804,7 @@ bool pkgCdrom::Add(pkgCdromStatus *log) /*{{{*/ if(log != NULL) log->Update(_("Source list entries for this disc are:\n")); - for (vector::iterator I = List.begin(); I != List.end(); I++) + for (vector::iterator I = List.begin(); I != List.end(); ++I) { string::size_type Space = (*I).find(' '); if (Space == string::npos) @@ -823,7 +823,7 @@ bool pkgCdrom::Add(pkgCdromStatus *log) /*{{{*/ } } - for (vector::iterator I = SourceList.begin(); I != SourceList.end(); I++) + for (vector::iterator I = SourceList.begin(); I != SourceList.end(); ++I) { string::size_type Space = (*I).find(' '); if (Space == string::npos) diff --git a/apt-pkg/clean.cc b/apt-pkg/clean.cc index 629afd7cf..9850b93b4 100644 --- a/apt-pkg/clean.cc +++ b/apt-pkg/clean.cc @@ -85,12 +85,12 @@ bool pkgArchiveCleaner::Go(string Dir,pkgCache &Cache) if (P.end() != true) { pkgCache::VerIterator V = P.VersionList(); - for (; V.end() == false; V++) + for (; V.end() == false; ++V) { // See if we can fetch this version at all bool IsFetchable = false; for (pkgCache::VerFileIterator J = V.FileList(); - J.end() == false; J++) + J.end() == false; ++J) { if (CleanInstalled == true && (J.File()->Flags & pkgCache::Flag::NotSource) != 0) diff --git a/apt-pkg/contrib/configuration.cc b/apt-pkg/contrib/configuration.cc index 942ea9fbc..ece05e8f6 100644 --- a/apt-pkg/contrib/configuration.cc +++ b/apt-pkg/contrib/configuration.cc @@ -672,9 +672,9 @@ bool ReadConfigFile(Configuration &Conf,const string &FName,bool const &AsSectio // Put the last fragment into the buffer std::string::const_iterator NonWhitespaceStart = Start; std::string::const_iterator NonWhitespaceStop = I; - for (; NonWhitespaceStart != I && isspace(*NonWhitespaceStart) != 0; NonWhitespaceStart++) + for (; NonWhitespaceStart != I && isspace(*NonWhitespaceStart) != 0; ++NonWhitespaceStart) ; - for (; NonWhitespaceStop != NonWhitespaceStart && isspace(NonWhitespaceStop[-1]) != 0; NonWhitespaceStop--) + for (; NonWhitespaceStop != NonWhitespaceStart && isspace(NonWhitespaceStop[-1]) != 0; --NonWhitespaceStop) ; if (LineBuffer.empty() == false && NonWhitespaceStop - NonWhitespaceStart != 0) LineBuffer += ' '; @@ -850,7 +850,7 @@ bool ReadConfigDir(Configuration &Conf,const string &Dir, vector const List = GetListOfFilesInDir(Dir, "conf", true, true); // Read the files - for (vector::const_iterator I = List.begin(); I != List.end(); I++) + for (vector::const_iterator I = List.begin(); I != List.end(); ++I) if (ReadConfigFile(Conf,*I,AsSectional,Depth) == false) return false; return true; diff --git a/apt-pkg/contrib/error.cc b/apt-pkg/contrib/error.cc index 18810d2a4..edb290f34 100644 --- a/apt-pkg/contrib/error.cc +++ b/apt-pkg/contrib/error.cc @@ -193,7 +193,7 @@ bool GlobalError::PopMessage(std::string &Text) { // check if another error message is pending for (std::list::const_iterator m = Messages.begin(); - m != Messages.end(); m++) + m != Messages.end(); ++m) if (m->Type == ERROR || m->Type == FATAL) return Ret; @@ -210,7 +210,7 @@ void GlobalError::DumpErrors(std::ostream &out, MsgType const &threshold, Messages.insert(Messages.begin(), s->Messages.begin(), s->Messages.end()); for (std::list::const_iterator m = Messages.begin(); - m != Messages.end(); m++) + m != Messages.end(); ++m) if (m->Type >= threshold) out << (*m) << std::endl; Discard(); @@ -231,7 +231,7 @@ bool GlobalError::empty(MsgType const &trashhold) const { return true; for (std::list::const_iterator m = Messages.begin(); - m != Messages.end(); m++) + m != Messages.end(); ++m) if (m->Type >= trashhold) return false; diff --git a/apt-pkg/contrib/strutl.cc b/apt-pkg/contrib/strutl.cc index ab2da2d9a..867bb313b 100644 --- a/apt-pkg/contrib/strutl.cc +++ b/apt-pkg/contrib/strutl.cc @@ -271,7 +271,7 @@ bool ParseCWord(const char *&String,string &Res) string QuoteString(const string &Str, const char *Bad) { string Res; - for (string::const_iterator I = Str.begin(); I != Str.end(); I++) + for (string::const_iterator I = Str.begin(); I != Str.end(); ++I) { if (strchr(Bad,*I) != 0 || isprint(*I) == 0 || *I == 0x25 || // percent '%' char @@ -298,7 +298,7 @@ string DeQuoteString(string::const_iterator const &begin, string::const_iterator const &end) { string Res; - for (string::const_iterator I = begin; I != end; I++) + for (string::const_iterator I = begin; I != end; ++I) { if (*I == '%' && I + 2 < end && isxdigit(I[1]) && isxdigit(I[2])) @@ -632,7 +632,7 @@ string LookupTag(const string &Message,const char *Tag,const char *Default) { // Look for a matching tag. int Length = strlen(Tag); - for (string::const_iterator I = Message.begin(); I + Length < Message.end(); I++) + for (string::const_iterator I = Message.begin(); I + Length < Message.end(); ++I) { // Found the tag if (I[Length] == ':' && stringcasecmp(I,I+Length,Tag) == 0) @@ -640,14 +640,14 @@ string LookupTag(const string &Message,const char *Tag,const char *Default) // Find the end of line and strip the leading/trailing spaces string::const_iterator J; I += Length + 1; - for (; isspace(*I) != 0 && I < Message.end(); I++); - for (J = I; *J != '\n' && J < Message.end(); J++); - for (; J > I && isspace(J[-1]) != 0; J--); + for (; isspace(*I) != 0 && I < Message.end(); ++I); + for (J = I; *J != '\n' && J < Message.end(); ++J); + for (; J > I && isspace(J[-1]) != 0; --J); return string(I,J); } - for (; *I != '\n' && I < Message.end(); I++); + for (; *I != '\n' && I < Message.end(); ++I); } // Failed to find a match @@ -1224,7 +1224,7 @@ int tolower_ascii(int const c) bool CheckDomainList(const string &Host,const string &List) { string::const_iterator Start = List.begin(); - for (string::const_iterator Cur = List.begin(); Cur <= List.end(); Cur++) + for (string::const_iterator Cur = List.begin(); Cur <= List.end(); ++Cur) { if (Cur < List.end() && *Cur != ',') continue; @@ -1248,7 +1248,7 @@ string DeEscapeString(const string &input) char tmp[3]; string::const_iterator it, escape_start; string output, octal, hex; - for (it = input.begin(); it != input.end(); it++) + for (it = input.begin(); it != input.end(); ++it) { // just copy non-escape chars if (*it != '\\') @@ -1264,7 +1264,7 @@ string DeEscapeString(const string &input) // copy output += *it; // advance iterator one step further - it += 1; + ++it; continue; } @@ -1273,7 +1273,7 @@ string DeEscapeString(const string &input) continue; // read it - it++; + ++it; switch (*it) { case '0': @@ -1310,7 +1310,7 @@ void URI::CopyFrom(const string &U) string::const_iterator I = U.begin(); // Locate the first colon, this separates the scheme - for (; I < U.end() && *I != ':' ; I++); + for (; I < U.end() && *I != ':' ; ++I); string::const_iterator FirstColon = I; /* Determine if this is a host type URI with a leading double // @@ -1322,7 +1322,7 @@ void URI::CopyFrom(const string &U) /* Find the / indicating the end of the hostname, ignoring /'s in the square brackets */ bool InBracket = false; - for (; SingleSlash < U.end() && (*SingleSlash != '/' || InBracket == true); SingleSlash++) + for (; SingleSlash < U.end() && (*SingleSlash != '/' || InBracket == true); ++SingleSlash) { if (*SingleSlash == '[') InBracket = true; @@ -1355,11 +1355,11 @@ void URI::CopyFrom(const string &U) I = FirstColon + 1; if (I > SingleSlash) I = SingleSlash; - for (; I < SingleSlash && *I != ':'; I++); + for (; I < SingleSlash && *I != ':'; ++I); string::const_iterator SecondColon = I; // Search for the @ after the colon - for (; I < SingleSlash && *I != '@'; I++); + for (; I < SingleSlash && *I != '@'; ++I); string::const_iterator At = I; // Now write the host and user/pass diff --git a/apt-pkg/deb/debindexfile.cc b/apt-pkg/deb/debindexfile.cc index c9e7f1176..e3d4063dc 100644 --- a/apt-pkg/deb/debindexfile.cc +++ b/apt-pkg/deb/debindexfile.cc @@ -352,7 +352,7 @@ pkgCache::PkgFileIterator debPackagesIndex::FindInCache(pkgCache &Cache) const { string FileName = IndexFile("Packages"); pkgCache::PkgFileIterator File = Cache.FileBegin(); - for (; File.end() == false; File++) + for (; File.end() == false; ++File) { if (File.FileName() == NULL || FileName != File.FileName()) continue; @@ -540,7 +540,7 @@ pkgCache::PkgFileIterator debTranslationsIndex::FindInCache(pkgCache &Cache) con string FileName = IndexFile(Language); pkgCache::PkgFileIterator File = Cache.FileBegin(); - for (; File.end() == false; File++) + for (; File.end() == false; ++File) { if (FileName != File.FileName()) continue; @@ -620,7 +620,7 @@ bool debStatusIndex::Merge(pkgCacheGenerator &Gen,OpProgress *Prog) const pkgCache::PkgFileIterator debStatusIndex::FindInCache(pkgCache &Cache) const { pkgCache::PkgFileIterator File = Cache.FileBegin(); - for (; File.end() == false; File++) + for (; File.end() == false; ++File) { if (this->File != File.FileName()) continue; diff --git a/apt-pkg/deb/deblistparser.cc b/apt-pkg/deb/deblistparser.cc index 73628c741..8d3f6f0ba 100644 --- a/apt-pkg/deb/deblistparser.cc +++ b/apt-pkg/deb/deblistparser.cc @@ -203,7 +203,7 @@ string debListParser::DescriptionLanguage() std::vector const lang = APT::Configuration::getLanguages(true); for (std::vector::const_iterator l = lang.begin(); - l != lang.end(); l++) + l != lang.end(); ++l) if (Section.FindS(string("Description-").append(*l).c_str()).empty() == false) return *l; diff --git a/apt-pkg/deb/debmetaindex.cc b/apt-pkg/deb/debmetaindex.cc index a91cc34e9..f6c50742e 100644 --- a/apt-pkg/deb/debmetaindex.cc +++ b/apt-pkg/deb/debmetaindex.cc @@ -206,7 +206,7 @@ vector * debReleaseIndex::ComputeIndexTargets() const { for (std::set::const_iterator s = sections.begin(); s != sections.end(); ++s) { for (std::vector::const_iterator l = lang.begin(); - l != lang.end(); l++) { + l != lang.end(); ++l) { if (*l == "none") continue; IndexTarget * Target = new OptionalIndexTarget(); Target->ShortDesc = "Translation-" + *l; @@ -236,7 +236,7 @@ bool debReleaseIndex::GetIndexes(pkgAcquire *Owner, bool const &GetAll) const // special case for --print-uris if (GetAll) { vector *targets = ComputeIndexTargets(); - for (vector ::const_iterator Target = targets->begin(); Target != targets->end(); Target++) { + for (vector ::const_iterator Target = targets->begin(); Target != targets->end(); ++Target) { new pkgAcqIndex(Owner, (*Target)->URI, (*Target)->Description, (*Target)->ShortDesc, HashString()); } @@ -279,7 +279,7 @@ vector *debReleaseIndex::GetIndexFiles() { if (src != ArchEntries.end()) { vector const SectionEntries = src->second; for (vector::const_iterator I = SectionEntries.begin(); - I != SectionEntries.end(); I++) + I != SectionEntries.end(); ++I) Indexes->push_back(new debSourcesIndex (URI, Dist, (*I)->Section, IsTrusted())); } @@ -294,7 +294,7 @@ vector *debReleaseIndex::GetIndexFiles() { if (a->first == "source") continue; for (vector::const_iterator I = a->second.begin(); - I != a->second.end(); I++) { + I != a->second.end(); ++I) { Indexes->push_back(new debPackagesIndex (URI, Dist, (*I)->Section, IsTrusted(), a->first)); sections[(*I)->Section].insert(lang.begin(), lang.end()); } @@ -303,7 +303,7 @@ vector *debReleaseIndex::GetIndexFiles() { for (map >::const_iterator s = sections.begin(); s != sections.end(); ++s) for (set::const_iterator l = s->second.begin(); - l != s->second.end(); l++) { + l != s->second.end(); ++l) { if (*l == "none") continue; Indexes->push_back(new debTranslationsIndex(URI,Dist,s->first,(*l).c_str())); } @@ -351,7 +351,7 @@ class debSLTypeDebian : public pkgSourceList::Type APT::Configuration::getArchitectures(); for (vector::const_iterator I = List.begin(); - I != List.end(); I++) + I != List.end(); ++I) { // We only worry about debian entries here if (strcmp((*I)->GetType(), "deb") != 0) diff --git a/apt-pkg/deb/debrecords.cc b/apt-pkg/deb/debrecords.cc index ec9e395ef..7f596ab0d 100644 --- a/apt-pkg/deb/debrecords.cc +++ b/apt-pkg/deb/debrecords.cc @@ -118,7 +118,7 @@ string debRecordParser::LongDesc() { vector const lang = APT::Configuration::getLanguages(); for (vector::const_iterator l = lang.begin(); - orig.empty() && l != lang.end(); l++) + orig.empty() && l != lang.end(); ++l) orig = Section.FindS(string("Description-").append(*l).c_str()); } diff --git a/apt-pkg/deb/dpkgpm.cc b/apt-pkg/deb/dpkgpm.cc index 5fbd1801a..46f48777c 100644 --- a/apt-pkg/deb/dpkgpm.cc +++ b/apt-pkg/deb/dpkgpm.cc @@ -213,7 +213,7 @@ bool pkgDPkgPM::SendV2Pkgs(FILE *F) fprintf(F,"\n"); // Write out the package actions in order. - for (vector::iterator I = List.begin(); I != List.end(); I++) + for (vector::iterator I = List.begin(); I != List.end(); ++I) { if(I->Pkg.end() == true) continue; @@ -335,7 +335,7 @@ bool pkgDPkgPM::RunScriptsWithPkgs(const char *Cnf) // Feed it the filenames. if (Version <= 1) { - for (vector::iterator I = List.begin(); I != List.end(); I++) + for (vector::iterator I = List.begin(); I != List.end(); ++I) { // Only deal with packages to be installed from .deb if (I->Op != Item::Install) @@ -690,7 +690,7 @@ bool pkgDPkgPM::OpenLog() chmod(history_name.c_str(), 0644); fprintf(history_out, "\nStart-Date: %s\n", timestr); string remove, purge, install, reinstall, upgrade, downgrade; - for (pkgCache::PkgIterator I = Cache.PkgBegin(); I.end() == false; I++) + for (pkgCache::PkgIterator I = Cache.PkgBegin(); I.end() == false; ++I) { enum { CANDIDATE, CANDIDATE_AUTO, CURRENT_CANDIDATE, CURRENT } infostring; string *line = NULL; @@ -868,14 +868,14 @@ bool pkgDPkgPM::Go(int OutStatusFd) // that will be [installed|configured|removed|purged] and add // them to the PackageOps map (the dpkg states it goes through) // and the PackageOpsTranslations (human readable strings) - for (vector::const_iterator I = List.begin(); I != List.end();I++) + for (vector::const_iterator I = List.begin(); I != List.end(); ++I) { if((*I).Pkg.end() == true) continue; string const name = (*I).Pkg.Name(); PackageOpsDone[name] = 0; - for(int i=0; (DpkgStatesOpMap[(*I).Op][i]).state != NULL; i++) + for(int i=0; (DpkgStatesOpMap[(*I).Op][i]).state != NULL; ++i) { PackageOps[name].push_back(DpkgStatesOpMap[(*I).Op][i]); PackagesTotal++; @@ -893,7 +893,7 @@ bool pkgDPkgPM::Go(int OutStatusFd) // Do all actions with the same Op in one run vector::const_iterator J = I; if (TriggersPending == true) - for (; J != List.end(); J++) + for (; J != List.end(); ++J) { if (J->Op == I->Op) continue; @@ -905,7 +905,7 @@ bool pkgDPkgPM::Go(int OutStatusFd) break; } else - for (; J != List.end() && J->Op == I->Op; J++) + for (; J != List.end() && J->Op == I->Op; ++J) /* nothing */; // Generate the argument list @@ -1011,7 +1011,7 @@ bool pkgDPkgPM::Go(int OutStatusFd) // Write in the file or package names if (I->Op == Item::Install) { - for (;I != J && Size < MaxArgBytes; I++) + for (;I != J && Size < MaxArgBytes; ++I) { if (I->File[0] != '/') return _error->Error("Internal Error, Pathname to install is not absolute '%s'",I->File.c_str()); @@ -1023,7 +1023,7 @@ bool pkgDPkgPM::Go(int OutStatusFd) { string const nativeArch = _config->Find("APT::Architecture"); unsigned long const oldSize = I->Op == Item::Configure ? Size : 0; - for (;I != J && Size < MaxArgBytes; I++) + for (;I != J && Size < MaxArgBytes; ++I) { if((*I).Pkg.end() == true) continue; @@ -1461,7 +1461,7 @@ void pkgDPkgPM::WriteApportReport(const char *pkgpath, const char *errormsg) // log the ordering const char *ops_str[] = {"Install", "Configure","Remove","Purge"}; fprintf(report, "AptOrdering:\n"); - for (vector::iterator I = List.begin(); I != List.end(); I++) + for (vector::iterator I = List.begin(); I != List.end(); ++I) fprintf(report, " %s: %s\n", (*I).Pkg.Name(), ops_str[(*I).Op]); // attach dmesg log (to learn about segfaults) diff --git a/apt-pkg/depcache.cc b/apt-pkg/depcache.cc index eb3f4e598..580056687 100644 --- a/apt-pkg/depcache.cc +++ b/apt-pkg/depcache.cc @@ -129,7 +129,7 @@ bool pkgDepCache::Init(OpProgress *Prog) /* Set the current state of everything. In this state all of the packages are kept exactly as is. See AllUpgrade */ int Done = 0; - for (PkgIterator I = PkgBegin(); I.end() != true; I++,Done++) + for (PkgIterator I = PkgBegin(); I.end() != true; ++I, ++Done) { if (Prog != 0 && Done%20 == 0) Prog->Progress(Done); @@ -292,7 +292,7 @@ bool pkgDepCache::writeStateFile(OpProgress *prog, bool InstalledOnly) /*{{{*/ // then write the ones we have not seen yet std::ostringstream ostr; - for(pkgCache::PkgIterator pkg=Cache->PkgBegin(); !pkg.end(); pkg++) { + for(pkgCache::PkgIterator pkg=Cache->PkgBegin(); !pkg.end(); ++pkg) { StateCache const &P = PkgState[pkg->ID]; if(P.Flags & Flag::Auto) { if (pkgs_seen.find(pkg.FullName()) != pkgs_seen.end()) { @@ -365,7 +365,7 @@ bool pkgDepCache::CheckDep(DepIterator Dep,int Type,PkgIterator &Res) // Check the providing packages PrvIterator P = Dep.TargetPkg().ProvidesList(); PkgIterator Pkg = Dep.ParentPkg(); - for (; P.end() != true; P++) + for (; P.end() != true; ++P) { /* Provides may never be applied against the same package (or group) if it is a conflicts. See the comment above. */ @@ -585,7 +585,7 @@ void pkgDepCache::BuildGroupOrs(VerIterator const &V) { unsigned char Group = 0; - for (DepIterator D = V.DependsList(); D.end() != true; D++) + for (DepIterator D = V.DependsList(); D.end() != true; ++D) { // Build the dependency state. unsigned char &State = DepState[D->ID]; @@ -625,7 +625,7 @@ unsigned char pkgDepCache::VersionState(DepIterator D,unsigned char Check, // Compute a single dependency element (glob or) DepIterator Start = D; unsigned char State = 0; - for (bool LastOR = true; D.end() == false && LastOR == true; D++) + for (bool LastOR = true; D.end() == false && LastOR == true; ++D) { State |= DepState[D->ID]; LastOR = (D->CompareOp & Dep::Or) == Dep::Or; @@ -715,15 +715,15 @@ void pkgDepCache::Update(OpProgress *Prog) // Perform the depends pass int Done = 0; - for (PkgIterator I = PkgBegin(); I.end() != true; I++,Done++) + for (PkgIterator I = PkgBegin(); I.end() != true; ++I, ++Done) { if (Prog != 0 && Done%20 == 0) Prog->Progress(Done); - for (VerIterator V = I.VersionList(); V.end() != true; V++) + for (VerIterator V = I.VersionList(); V.end() != true; ++V) { unsigned char Group = 0; - for (DepIterator D = V.DependsList(); D.end() != true; D++) + for (DepIterator D = V.DependsList(); D.end() != true; ++D) { // Build the dependency state. unsigned char &State = DepState[D->ID]; @@ -760,7 +760,7 @@ void pkgDepCache::Update(OpProgress *Prog) void pkgDepCache::Update(DepIterator D) { // Update the reverse deps - for (;D.end() != true; D++) + for (;D.end() != true; ++D) { unsigned char &State = DepState[D->ID]; State = DependencyState(D); @@ -793,13 +793,13 @@ void pkgDepCache::Update(PkgIterator const &Pkg) // Update the provides map for the current ver if (Pkg->CurrentVer != 0) for (PrvIterator P = Pkg.CurrentVer().ProvidesList(); - P.end() != true; P++) + P.end() != true; ++P) Update(P.ParentPkg().RevDependsList()); // Update the provides map for the candidate ver if (PkgState[Pkg->ID].CandidateVer != 0) for (PrvIterator P = PkgState[Pkg->ID].CandidateVerIter(*this).ProvidesList(); - P.end() != true; P++) + P.end() != true; ++P) Update(P.ParentPkg().RevDependsList()); } /*}}}*/ @@ -1059,7 +1059,7 @@ void pkgDepCache::MarkInstall(PkgIterator const &Pkg,bool AutoInst, DepIterator Start = Dep; bool Result = true; unsigned Ors = 0; - for (bool LastOR = true; Dep.end() == false && LastOR == true; Dep++,Ors++) + for (bool LastOR = true; Dep.end() == false && LastOR == true; ++Dep, ++Ors) { LastOR = (Dep->CompareOp & Dep::Or) == Dep::Or; @@ -1522,12 +1522,12 @@ pkgCache::VerIterator pkgDepCache::Policy::GetCandidateVer(PkgIterator const &Pk unless they are already installed */ VerIterator Last(*(pkgCache *)this,0); - for (VerIterator I = Pkg.VersionList(); I.end() == false; I++) + for (VerIterator I = Pkg.VersionList(); I.end() == false; ++I) { if (Pkg.CurrentVer() == I) return I; - for (VerFileIterator J = I.FileList(); J.end() == false; J++) + for (VerFileIterator J = I.FileList(); J.end() == false; ++J) { if ((J.File()->Flags & Flag::NotSource) != 0) continue; diff --git a/apt-pkg/indexcopy.cc b/apt-pkg/indexcopy.cc index 31c577705..b262e21c4 100644 --- a/apt-pkg/indexcopy.cc +++ b/apt-pkg/indexcopy.cc @@ -43,7 +43,7 @@ bool IndexCopy::CopyPackages(string CDROM,string Name,vector &List, pkgCdromStatus *log) { OpProgress *Progress = NULL; - if (List.size() == 0) + if (List.empty() == true) return true; if(log) @@ -54,7 +54,7 @@ bool IndexCopy::CopyPackages(string CDROM,string Name,vector &List, // Prepare the progress indicator unsigned long TotalSize = 0; - for (vector::iterator I = List.begin(); I != List.end(); I++) + for (vector::iterator I = List.begin(); I != List.end(); ++I) { struct stat Buf; if (stat(string(*I + GetFileName()).c_str(),&Buf) != 0 && @@ -68,7 +68,7 @@ bool IndexCopy::CopyPackages(string CDROM,string Name,vector &List, unsigned int NotFound = 0; unsigned int WrongSize = 0; unsigned int Packages = 0; - for (vector::iterator I = List.begin(); I != List.end(); I++) + for (vector::iterator I = List.begin(); I != List.end(); ++I) { string OrigPath = string(*I,CDROM.length()); unsigned long FileSize = 0; @@ -583,13 +583,13 @@ bool SigVerify::CopyMetaIndex(string CDROM, string CDName, /*{{{*/ bool SigVerify::CopyAndVerify(string CDROM,string Name,vector &SigList, /*{{{*/ vector PkgList,vector SrcList) { - if (SigList.size() == 0) + if (SigList.empty() == true) return true; bool Debug = _config->FindB("Debug::aptcdrom",false); // Read all Release files - for (vector::iterator I = SigList.begin(); I != SigList.end(); I++) + for (vector::iterator I = SigList.begin(); I != SigList.end(); ++I) { if(Debug) cout << "Signature verify for: " << *I << endl; @@ -633,7 +633,7 @@ bool SigVerify::CopyAndVerify(string CDROM,string Name,vector &SigList, // go over the Indexfiles and see if they verify // if so, remove them from our copy of the lists vector keys = MetaIndex->MetaKeys(); - for (vector::iterator I = keys.begin(); I != keys.end(); I++) + for (vector::iterator I = keys.begin(); I != keys.end(); ++I) { if(!Verify(prefix,*I, MetaIndex)) { // something went wrong, don't copy the Release.gpg @@ -776,7 +776,7 @@ bool TranslationsCopy::CopyTranslations(string CDROM,string Name, /*{{{*/ vector &List, pkgCdromStatus *log) { OpProgress *Progress = NULL; - if (List.size() == 0) + if (List.empty() == true) return true; if(log) @@ -786,7 +786,7 @@ bool TranslationsCopy::CopyTranslations(string CDROM,string Name, /*{{{*/ // Prepare the progress indicator unsigned long TotalSize = 0; - for (vector::iterator I = List.begin(); I != List.end(); I++) + for (vector::iterator I = List.begin(); I != List.end(); ++I) { struct stat Buf; if (stat(string(*I).c_str(),&Buf) != 0 && @@ -800,7 +800,7 @@ bool TranslationsCopy::CopyTranslations(string CDROM,string Name, /*{{{*/ unsigned int NotFound = 0; unsigned int WrongSize = 0; unsigned int Packages = 0; - for (vector::iterator I = List.begin(); I != List.end(); I++) + for (vector::iterator I = List.begin(); I != List.end(); ++I) { string OrigPath = string(*I,CDROM.length()); unsigned long FileSize = 0; diff --git a/apt-pkg/orderlist.cc b/apt-pkg/orderlist.cc index 19661fc2d..6034138cf 100644 --- a/apt-pkg/orderlist.cc +++ b/apt-pkg/orderlist.cc @@ -323,7 +323,7 @@ int pkgOrderList::Score(PkgIterator Pkg) Score += ScoreImmediate; for (DepIterator D = Cache[Pkg].InstVerIter(Cache).DependsList(); - D.end() == false; D++) + D.end() == false; ++D) if (D->Type == pkgCache::Dep::PreDepends) { Score += ScorePreDepends; @@ -488,7 +488,7 @@ bool pkgOrderList::VisitRProvides(DepFunc F,VerIterator Ver) return true; bool Res = true; - for (PrvIterator P = Ver.ProvidesList(); P.end() == false; P++) + for (PrvIterator P = Ver.ProvidesList(); P.end() == false; ++P) Res &= (this->*F)(P.ParentPkg().RevDependsList()); return Res; } @@ -615,7 +615,7 @@ bool pkgOrderList::VisitNode(PkgIterator Pkg) Loops are preprocessed and logged. */ bool pkgOrderList::DepUnPackCrit(DepIterator D) { - for (; D.end() == false; D++) + for (; D.end() == false; ++D) { if (D.Reverse() == true) { @@ -693,7 +693,7 @@ bool pkgOrderList::DepUnPackPreD(DepIterator D) if (D.Reverse() == true) return DepUnPackCrit(D); - for (; D.end() == false; D++) + for (; D.end() == false; ++D) { if (D.IsCritical() == false) continue; @@ -736,7 +736,7 @@ bool pkgOrderList::DepUnPackPre(DepIterator D) if (D.Reverse() == true) return true; - for (; D.end() == false; D++) + for (; D.end() == false; ++D) { /* Only consider the PreDepends or Depends. Depends are only considered at the lowest depth or in the case of immediate @@ -791,7 +791,7 @@ bool pkgOrderList::DepUnPackPre(DepIterator D) bool pkgOrderList::DepUnPackDep(DepIterator D) { - for (; D.end() == false; D++) + for (; D.end() == false; ++D) if (D.IsCritical() == true) { if (D.Reverse() == true) @@ -846,7 +846,7 @@ bool pkgOrderList::DepConfigure(DepIterator D) if (D.Reverse() == true) return true; - for (; D.end() == false; D++) + for (; D.end() == false; ++D) if (D->Type == pkgCache::Dep::Depends) if (VisitProvides(D,false) == false) return false; @@ -868,7 +868,7 @@ bool pkgOrderList::DepRemove(DepIterator D) { if (D.Reverse() == false) return true; - for (; D.end() == false; D++) + for (; D.end() == false; ++D) if (D->Type == pkgCache::Dep::Depends || D->Type == pkgCache::Dep::PreDepends) { // Duplication elimination, consider the current version only diff --git a/apt-pkg/packagemanager.cc b/apt-pkg/packagemanager.cc index fe9f6eb68..999a7b0a0 100644 --- a/apt-pkg/packagemanager.cc +++ b/apt-pkg/packagemanager.cc @@ -99,7 +99,7 @@ bool pkgPackageManager::FixMissing() List->SetFileList(FileNames); bool Bad = false; - for (PkgIterator I = Cache.PkgBegin(); I.end() == false; I++) + for (PkgIterator I = Cache.PkgBegin(); I.end() == false; ++I) { if (List->IsMissing(I) == false) continue; @@ -140,7 +140,7 @@ void pkgPackageManager::ImmediateAdd(PkgIterator I, bool UseInstallVer, unsigned D = I.CurrentVer().DependsList(); } - for ( /* nothing */ ; D.end() == false; D++) + for ( /* nothing */ ; D.end() == false; ++D) if (D->Type == pkgCache::Dep::Depends || D->Type == pkgCache::Dep::PreDepends) { if(!List->IsFlag(D.TargetPkg(), pkgOrderList::Immediate)) @@ -169,7 +169,7 @@ bool pkgPackageManager::CreateOrderList() static bool const NoImmConfigure = !_config->FindB("APT::Immediate-Configure",true); // Generate the list of affected packages and sort it - for (PkgIterator I = Cache.PkgBegin(); I.end() == false; I++) + for (PkgIterator I = Cache.PkgBegin(); I.end() == false; ++I) { // Ignore no-version packages if (I->VersionList == 0) @@ -229,7 +229,7 @@ bool pkgPackageManager::DepAlwaysTrue(DepIterator D) bool pkgPackageManager::CheckRConflicts(PkgIterator Pkg,DepIterator D, const char *Ver) { - for (;D.end() == false; D++) + for (;D.end() == false; ++D) { if (D->Type != pkgCache::Dep::Conflicts && D->Type != pkgCache::Dep::Obsoletes) @@ -364,13 +364,13 @@ bool pkgPackageManager::DepAdd(pkgOrderList &OList,PkgIterator Pkg,int Depth) { if (D->Type != pkgCache::Dep::Depends && D->Type != pkgCache::Dep::PreDepends) { - D++; + ++D; continue; } // Grok or groups Bad = true; - for (bool LastOR = true; D.end() == false && LastOR == true; D++) + for (bool LastOR = true; D.end() == false && LastOR == true; ++D) { LastOR = (D->CompareOp & pkgCache::Dep::Or) == pkgCache::Dep::Or; @@ -378,7 +378,7 @@ bool pkgPackageManager::DepAdd(pkgOrderList &OList,PkgIterator Pkg,int Depth) continue; SPtrArray VList = D.AllTargets(); - for (Version **I = VList; *I != 0 && Bad == true; I++) + for (Version **I = VList; *I != 0 && Bad == true; ++I) { VerIterator Ver(Cache,*I); PkgIterator Pkg = Ver.ParentPkg(); @@ -444,7 +444,7 @@ bool pkgPackageManager::EarlyRemove(PkgIterator Pkg) if (Pkg->CurrentVer != 0) { for (DepIterator D = Pkg.RevDependsList(); D.end() == false && - IsEssential == false; D++) + IsEssential == false; ++D) if (D->Type == pkgCache::Dep::Depends || D->Type == pkgCache::Dep::PreDepends) if ((D.ParentPkg()->Flags & pkgCache::Flag::Essential) != 0) IsEssential = true; @@ -564,7 +564,7 @@ bool pkgPackageManager::SmartUnPack(PkgIterator Pkg, bool const Immediate) return _error->Error("Couldn't configure pre-depend %s for %s, " "probably a dependency cycle.", End.TargetPkg().Name(),Pkg.Name()); - Start++; + ++Start; } else break; @@ -597,7 +597,7 @@ bool pkgPackageManager::SmartUnPack(PkgIterator Pkg, bool const Immediate) return false; for (PrvIterator P = instVer.ProvidesList(); - P.end() == false; P++) + P.end() == false; ++P) CheckRConflicts(Pkg,P.ParentPkg().RevDependsList(),P.ProvideVersion()); List->Flag(Pkg,pkgOrderList::UnPacked,pkgOrderList::States); diff --git a/apt-pkg/pkgcache.cc b/apt-pkg/pkgcache.cc index 38e4e904e..ed24d9ea8 100644 --- a/apt-pkg/pkgcache.cc +++ b/apt-pkg/pkgcache.cc @@ -175,7 +175,7 @@ bool pkgCache::ReMap(bool const &Errorchecks) unsigned long pkgCache::sHash(const string &Str) const { unsigned long Hash = 0; - for (string::const_iterator I = Str.begin(); I != Str.end(); I++) + for (string::const_iterator I = Str.begin(); I != Str.end(); ++I) Hash = 5*Hash + tolower_ascii(*I); return Hash % _count(HeaderP->PkgHashTable); } @@ -183,7 +183,7 @@ unsigned long pkgCache::sHash(const string &Str) const unsigned long pkgCache::sHash(const char *Str) const { unsigned long Hash = 0; - for (const char *I = Str; *I != 0; I++) + for (const char *I = Str; *I != 0; ++I) Hash = 5*Hash + tolower_ascii(*I); return Hash % _count(HeaderP->PkgHashTable); } @@ -569,7 +569,7 @@ bool pkgCache::DepIterator::SmartTargetPkg(PkgIterator &Result) const virtual package libc-dev which is provided by libc5-dev and libc6-dev we must ignore libc5-dev when considering the provides list. */ PrvIterator PStart = Result.ProvidesList(); - for (; PStart.end() != true && PStart.OwnerPkg() == ParentPkg(); PStart++); + for (; PStart.end() != true && PStart.OwnerPkg() == ParentPkg(); ++PStart); // Nothing but indirect self provides if (PStart.end() == true) @@ -577,7 +577,7 @@ bool pkgCache::DepIterator::SmartTargetPkg(PkgIterator &Result) const // Check for single packages in the provides list PrvIterator P = PStart; - for (; P.end() != true; P++) + for (; P.end() != true; ++P) { // Skip over self provides if (P.OwnerPkg() == ParentPkg()) @@ -611,7 +611,7 @@ pkgCache::Version **pkgCache::DepIterator::AllTargets() const PkgIterator DPkg = TargetPkg(); // Walk along the actual package providing versions - for (VerIterator I = DPkg.VersionList(); I.end() == false; I++) + for (VerIterator I = DPkg.VersionList(); I.end() == false; ++I) { if (Owner->VS->CheckDep(I.VerStr(),S->CompareOp,TargetVer()) == false) continue; @@ -626,7 +626,7 @@ pkgCache::Version **pkgCache::DepIterator::AllTargets() const } // Follow all provides - for (PrvIterator I = DPkg.ProvidesList(); I.end() == false; I++) + for (PrvIterator I = DPkg.ProvidesList(); I.end() == false; ++I) { if (Owner->VS->CheckDep(I.ProvideVersion(),S->CompareOp,TargetVer()) == false) continue; @@ -717,7 +717,7 @@ int pkgCache::VerIterator::CompareVer(const VerIterator &B) const /* Start at A and look for B. If B is found then A > B otherwise B was before A so A < B */ VerIterator I = *this; - for (;I.end() == false; I++) + for (;I.end() == false; ++I) if (I == B) return 1; return -1; @@ -729,7 +729,7 @@ int pkgCache::VerIterator::CompareVer(const VerIterator &B) const bool pkgCache::VerIterator::Downloadable() const { VerFileIterator Files = FileList(); - for (; Files.end() == false; Files++) + for (; Files.end() == false; ++Files) if ((Files.File()->Flags & pkgCache::Flag::NotSource) != pkgCache::Flag::NotSource) return true; return false; @@ -742,7 +742,7 @@ bool pkgCache::VerIterator::Downloadable() const bool pkgCache::VerIterator::Automatic() const { VerFileIterator Files = FileList(); - for (; Files.end() == false; Files++) + for (; Files.end() == false; ++Files) // Do not check ButAutomaticUpgrades here as it is kind of automatic… if ((Files.File()->Flags & pkgCache::Flag::NotAutomatic) != pkgCache::Flag::NotAutomatic) return true; @@ -760,7 +760,7 @@ pkgCache::VerFileIterator pkgCache::VerIterator::NewestFile() const { VerFileIterator Files = FileList(); VerFileIterator Highest = Files; - for (; Files.end() == false; Files++) + for (; Files.end() == false; ++Files) { if (Owner->VS->CmpReleaseVer(Files.File().Version(),Highest.File().Version()) > 0) Highest = Files; @@ -777,7 +777,7 @@ string pkgCache::VerIterator::RelStr() const { bool First = true; string Res; - for (pkgCache::VerFileIterator I = this->FileList(); I.end() == false; I++) + for (pkgCache::VerFileIterator I = this->FileList(); I.end() == false; ++I) { // Do not print 'not source' entries' pkgCache::PkgFileIterator File = I.File(); @@ -786,7 +786,7 @@ string pkgCache::VerIterator::RelStr() const // See if we have already printed this out.. bool Seen = false; - for (pkgCache::VerFileIterator J = this->FileList(); I != J; J++) + for (pkgCache::VerFileIterator J = this->FileList(); I != J; ++J) { pkgCache::PkgFileIterator File2 = J.File(); if (File2->Label == 0 || File->Label == 0) @@ -887,7 +887,7 @@ pkgCache::DescIterator pkgCache::VerIterator::TranslatedDescription() const { std::vector const lang = APT::Configuration::getLanguages(); for (std::vector::const_iterator l = lang.begin(); - l != lang.end(); l++) + l != lang.end(); ++l) { pkgCache::DescIterator Desc = DescriptionList(); for (; Desc.end() == false; ++Desc) diff --git a/apt-pkg/pkgcachegen.cc b/apt-pkg/pkgcachegen.cc index 2bfb77609..8a7c1e979 100644 --- a/apt-pkg/pkgcachegen.cc +++ b/apt-pkg/pkgcachegen.cc @@ -220,7 +220,7 @@ bool pkgCacheGenerator::MergeList(ListParser &List, // don't add a new description if we have one for the given // md5 && language - for ( ; Desc.end() == false; Desc++) + for ( ; Desc.end() == false; ++Desc) if (MD5SumValue(Desc.md5()) == CurMd5 && Desc.LanguageCode() == List.DescriptionLanguage()) duplicate=true; @@ -229,7 +229,7 @@ bool pkgCacheGenerator::MergeList(ListParser &List, for (Desc = Ver.DescriptionList(); Desc.end() == false; - LastDesc = &Desc->NextDesc, Desc++) + LastDesc = &Desc->NextDesc, ++Desc) { if (MD5SumValue(Desc.md5()) == CurMd5) { @@ -395,7 +395,7 @@ bool pkgCacheGenerator::MergeFileProvides(ListParser &List) unsigned long Hash = List.VersionHash(); pkgCache::VerIterator Ver = Pkg.VersionList(); Dynamic DynVer(Ver); - for (; Ver.end() == false; Ver++) + for (; Ver.end() == false; ++Ver) { if (Ver->Hash == Hash && Version.c_str() == Ver.VerStr()) { @@ -511,7 +511,7 @@ bool pkgCacheGenerator::NewFileVer(pkgCache::VerIterator &Ver, // Link it to the end of the list map_ptrloc *Last = &Ver->FileList; - for (pkgCache::VerFileIterator V = Ver.FileList(); V.end() == false; V++) + for (pkgCache::VerFileIterator V = Ver.FileList(); V.end() == false; ++V) Last = &V->NextFile; VF->NextFile = *Last; *Last = VF.Index(); @@ -568,7 +568,7 @@ bool pkgCacheGenerator::NewFileDesc(pkgCache::DescIterator &Desc, // Link it to the end of the list map_ptrloc *Last = &Desc->FileList; - for (pkgCache::DescFileIterator D = Desc.FileList(); D.end() == false; D++) + for (pkgCache::DescFileIterator D = Desc.FileList(); D.end() == false; ++D) Last = &D->NextFile; DF->NextFile = *Last; @@ -623,7 +623,7 @@ bool pkgCacheGenerator::FinishCache(OpProgress *Progress) // Create Conflicts in between the group pkgCache::GrpIterator G = GetCache().GrpBegin(); Dynamic DynG(G); - for (; G.end() != true; G++) + for (; G.end() != true; ++G) { string const PkgName = G.Name(); pkgCache::PkgIterator P = G.PackageList(); @@ -634,7 +634,7 @@ bool pkgCacheGenerator::FinishCache(OpProgress *Progress) Dynamic DynallPkg(allPkg); pkgCache::VerIterator V = P.VersionList(); Dynamic DynV(V); - for (; V.end() != true; V++) + for (; V.end() != true; ++V) { // copy P.Arch() into a string here as a cache remap // in NewDepends() later may alter the pointer location @@ -728,7 +728,7 @@ bool pkgCacheGenerator::NewDepends(pkgCache::PkgIterator &Pkg, if (OldDepLast == NULL) { OldDepLast = &Ver->DependsList; - for (pkgCache::DepIterator D = Ver.DependsList(); D.end() == false; D++) + for (pkgCache::DepIterator D = Ver.DependsList(); D.end() == false; ++D) OldDepLast = &D->NextDepends; } else if (oldMap != Map.Data()) OldDepLast += (map_ptrloc*) Map.Data() - (map_ptrloc*) oldMap; @@ -958,7 +958,7 @@ static bool CheckValidity(const string &CacheFile, verify the IMS data and check that it is on the disk too.. */ SPtrArray Visited = new bool[Cache.HeaderP->PackageFileCount]; memset(Visited,0,sizeof(*Visited)*Cache.HeaderP->PackageFileCount); - for (; Start != End; Start++) + for (; Start != End; ++Start) { if (Debug == true) std::clog << "Checking PkgFile " << (*Start)->Describe() << ": "; @@ -1025,7 +1025,7 @@ static bool CheckValidity(const string &CacheFile, static unsigned long ComputeSize(FileIterator Start,FileIterator End) { unsigned long TotalSize = 0; - for (; Start != End; Start++) + for (; Start != End; ++Start) { if ((*Start)->HasPackages() == false) continue; @@ -1043,7 +1043,7 @@ static bool BuildCache(pkgCacheGenerator &Gen, FileIterator Start, FileIterator End) { FileIterator I; - for (I = Start; I != End; I++) + for (I = Start; I != End; ++I) { if ((*I)->HasPackages() == false) continue; @@ -1073,7 +1073,7 @@ static bool BuildCache(pkgCacheGenerator &Gen, Progress->Done(); TotalSize = ComputeSize(Start, End); CurrentSize = 0; - for (I = Start; I != End; I++) + for (I = Start; I != End; ++I) { unsigned long Size = (*I)->Size(); if (Progress != NULL) @@ -1120,12 +1120,12 @@ bool pkgCacheGenerator::MakeStatusCache(pkgSourceList &List,OpProgress *Progress vector Files; for (vector::const_iterator i = List.begin(); i != List.end(); - i++) + ++i) { vector *Indexes = (*i)->GetIndexFiles(); for (vector::const_iterator j = Indexes->begin(); j != Indexes->end(); - j++) + ++j) Files.push_back (*j); } diff --git a/apt-pkg/pkgrecords.cc b/apt-pkg/pkgrecords.cc index e506de73a..1a7585d8f 100644 --- a/apt-pkg/pkgrecords.cc +++ b/apt-pkg/pkgrecords.cc @@ -24,7 +24,7 @@ pkgRecords::pkgRecords(pkgCache &Cache) : Cache(Cache), Files(Cache.HeaderP->PackageFileCount) { for (pkgCache::PkgFileIterator I = Cache.FileBegin(); - I.end() == false; I++) + I.end() == false; ++I) { const pkgIndexFile::Type *Type = pkgIndexFile::Type::GetType(I.IndexType()); if (Type == 0) diff --git a/apt-pkg/policy.cc b/apt-pkg/policy.cc index c5028d822..6a5130d48 100644 --- a/apt-pkg/policy.cc +++ b/apt-pkg/policy.cc @@ -81,7 +81,7 @@ pkgPolicy::pkgPolicy(pkgCache *Owner) : Pins(0), PFPriority(0), Cache(Owner) bool pkgPolicy::InitDefaults() { // Initialize the priorities based on the status of the package file - for (pkgCache::PkgFileIterator I = Cache->FileBegin(); I != Cache->FileEnd(); I++) + for (pkgCache::PkgFileIterator I = Cache->FileBegin(); I != Cache->FileEnd(); ++I) { PFPriority[I->ID] = 500; if ((I->Flags & pkgCache::Flag::NotSource) == pkgCache::Flag::NotSource) @@ -98,10 +98,10 @@ bool pkgPolicy::InitDefaults() signed Cur = 989; StatusOverride = false; for (vector::const_iterator I = Defaults.begin(); I != Defaults.end(); - I++, Cur--) + ++I, --Cur) { pkgVersionMatch Match(I->Data,I->Type); - for (pkgCache::PkgFileIterator F = Cache->FileBegin(); F != Cache->FileEnd(); F++) + for (pkgCache::PkgFileIterator F = Cache->FileBegin(); F != Cache->FileEnd(); ++F) { if (Match.FileMatch(F) == true && Fixed[F->ID] == false) { @@ -122,7 +122,7 @@ bool pkgPolicy::InitDefaults() } if (_config->FindB("Debug::pkgPolicy",false) == true) - for (pkgCache::PkgFileIterator F = Cache->FileBegin(); F != Cache->FileEnd(); F++) + for (pkgCache::PkgFileIterator F = Cache->FileBegin(); F != Cache->FileEnd(); ++F) std::clog << "Prio of " << F.FileName() << ' ' << PFPriority[F->ID] << std::endl; return true; @@ -162,12 +162,12 @@ pkgCache::VerIterator pkgPolicy::GetCandidateVer(pkgCache::PkgIterator const &Pk tracks the default when the default is taken away, and a permanent pin that stays at that setting. */ - for (pkgCache::VerIterator Ver = Pkg.VersionList(); Ver.end() == false; Ver++) + for (pkgCache::VerIterator Ver = Pkg.VersionList(); Ver.end() == false; ++Ver) { /* Lets see if this version is the installed version */ bool instVer = (Pkg.CurrentVer() == Ver); - for (pkgCache::VerFileIterator VF = Ver.FileList(); VF.end() == false; VF++) + for (pkgCache::VerFileIterator VF = Ver.FileList(); VF.end() == false; ++VF) { /* If this is the status file, and the current version is not the version in the status file (ie it is not installed, or somesuch) @@ -356,7 +356,7 @@ bool ReadPinDir(pkgPolicy &Plcy,string Dir) vector const List = GetListOfFilesInDir(Dir, "pref", true, true); // Read the files - for (vector::const_iterator I = List.begin(); I != List.end(); I++) + for (vector::const_iterator I = List.begin(); I != List.end(); ++I) if (ReadPinFile(Plcy, *I) == false) return false; return true; diff --git a/apt-pkg/sourcelist.cc b/apt-pkg/sourcelist.cc index c96ccfd77..a25358bf2 100644 --- a/apt-pkg/sourcelist.cc +++ b/apt-pkg/sourcelist.cc @@ -173,7 +173,7 @@ pkgSourceList::pkgSourceList(string File) /* */ pkgSourceList::~pkgSourceList() { - for (const_iterator I = SrcList.begin(); I != SrcList.end(); I++) + for (const_iterator I = SrcList.begin(); I != SrcList.end(); ++I) delete *I; } /*}}}*/ @@ -218,7 +218,7 @@ bool pkgSourceList::ReadMainList() /* */ void pkgSourceList::Reset() { - for (const_iterator I = SrcList.begin(); I != SrcList.end(); I++) + for (const_iterator I = SrcList.begin(); I != SrcList.end(); ++I) delete *I; SrcList.erase(SrcList.begin(),SrcList.end()); } @@ -296,11 +296,11 @@ bool pkgSourceList::ReadAppend(string File) bool pkgSourceList::FindIndex(pkgCache::PkgFileIterator File, pkgIndexFile *&Found) const { - for (const_iterator I = SrcList.begin(); I != SrcList.end(); I++) + for (const_iterator I = SrcList.begin(); I != SrcList.end(); ++I) { vector *Indexes = (*I)->GetIndexFiles(); for (vector::const_iterator J = Indexes->begin(); - J != Indexes->end(); J++) + J != Indexes->end(); ++J) { if ((*J)->FindInCache(*File.Cache()) == File) { @@ -318,7 +318,7 @@ bool pkgSourceList::FindIndex(pkgCache::PkgFileIterator File, /* */ bool pkgSourceList::GetIndexes(pkgAcquire *Owner, bool GetAll) const { - for (const_iterator I = SrcList.begin(); I != SrcList.end(); I++) + for (const_iterator I = SrcList.begin(); I != SrcList.end(); ++I) if ((*I)->GetIndexes(Owner,GetAll) == false) return false; return true; @@ -334,7 +334,7 @@ bool pkgSourceList::ReadSourceDir(string Dir) vector const List = GetListOfFilesInDir(Dir, "list", true); // Read the files - for (vector::const_iterator I = List.begin(); I != List.end(); I++) + for (vector::const_iterator I = List.begin(); I != List.end(); ++I) if (ReadAppend(*I) == false) return false; return true; @@ -353,7 +353,7 @@ time_t pkgSourceList::GetLastModifiedTime() // calculate the time time_t mtime_sources = GetModificationTime(Main); - for (vector::const_iterator I = List.begin(); I != List.end(); I++) + for (vector::const_iterator I = List.begin(); I != List.end(); ++I) mtime_sources = std::max(mtime_sources, GetModificationTime(*I)); return mtime_sources; diff --git a/apt-pkg/srcrecords.cc b/apt-pkg/srcrecords.cc index 46a02b55c..946ac1a1a 100644 --- a/apt-pkg/srcrecords.cc +++ b/apt-pkg/srcrecords.cc @@ -24,11 +24,11 @@ /* Open all the source index files */ pkgSrcRecords::pkgSrcRecords(pkgSourceList &List) : Files(0), Current(0) { - for (pkgSourceList::const_iterator I = List.begin(); I != List.end(); I++) + for (pkgSourceList::const_iterator I = List.begin(); I != List.end(); ++I) { vector *Indexes = (*I)->GetIndexFiles(); for (vector::const_iterator J = Indexes->begin(); - J != Indexes->end(); J++) + J != Indexes->end(); ++J) { Parser* P = (*J)->CreateSrcParser(); if (_error->PendingError() == true) @@ -66,7 +66,7 @@ bool pkgSrcRecords::Restart() { Current = Files.begin(); for (vector::iterator I = Files.begin(); - I != Files.end(); I++) + I != Files.end(); ++I) (*I)->Restart(); return true; @@ -89,7 +89,7 @@ pkgSrcRecords::Parser *pkgSrcRecords::Find(const char *Package,bool const &SrcOn { if (_error->PendingError() == true) return 0; - Current++; + ++Current; if (Current == Files.end()) return 0; } @@ -107,7 +107,7 @@ pkgSrcRecords::Parser *pkgSrcRecords::Find(const char *Package,bool const &SrcOn // Check for a binary hit const char **I = (*Current)->Binaries(); - for (; I != 0 && *I != 0; I++) + for (; I != 0 && *I != 0; ++I) if (strcmp(Package,*I) == 0) return *Current; } diff --git a/apt-pkg/vendorlist.cc b/apt-pkg/vendorlist.cc index 48ac12cee..4cc500727 100644 --- a/apt-pkg/vendorlist.cc +++ b/apt-pkg/vendorlist.cc @@ -11,7 +11,7 @@ pkgVendorList::~pkgVendorList() { for (vector::const_iterator I = VendorList.begin(); - I != VendorList.end(); I++) + I != VendorList.end(); ++I) delete *I; } @@ -49,7 +49,7 @@ bool pkgVendorList::Read(string File) /*{{{*/ bool pkgVendorList::CreateList(Configuration& Cnf) /*{{{*/ { for (vector::const_iterator I = VendorList.begin(); - I != VendorList.end(); I++) + I != VendorList.end(); ++I) delete *I; VendorList.erase(VendorList.begin(),VendorList.end()); @@ -129,7 +129,7 @@ const Vendor* pkgVendorList::LookupFingerprint(string Fingerprint) /*{{{*/ /*}}}*/ const Vendor* pkgVendorList::FindVendor(const std::vector GPGVOutput) /*{{{*/ { - for (std::vector::const_iterator I = GPGVOutput.begin(); I != GPGVOutput.end(); I++) + for (std::vector::const_iterator I = GPGVOutput.begin(); I != GPGVOutput.end(); ++I) { string::size_type pos = (*I).find("VALIDSIG "); if (_config->FindB("Debug::Vendor", false)) diff --git a/apt-pkg/versionmatch.cc b/apt-pkg/versionmatch.cc index c40b1fdbc..6d667acad 100644 --- a/apt-pkg/versionmatch.cc +++ b/apt-pkg/versionmatch.cc @@ -60,7 +60,7 @@ pkgVersionMatch::pkgVersionMatch(string Data,MatchType Type) : Type(Type) // Are we a simple specification? string::const_iterator I = Data.begin(); - for (; I != Data.end() && *I != '='; I++); + for (; I != Data.end() && *I != '='; ++I); if (I == Data.end()) { // Temporary @@ -152,7 +152,7 @@ bool pkgVersionMatch::MatchVer(const char *A,string B,bool Prefix) pkgCache::VerIterator pkgVersionMatch::Find(pkgCache::PkgIterator Pkg) { pkgCache::VerIterator Ver = Pkg.VersionList(); - for (; Ver.end() == false; Ver++) + for (; Ver.end() == false; ++Ver) { if (Type == Version) { @@ -163,7 +163,7 @@ pkgCache::VerIterator pkgVersionMatch::Find(pkgCache::PkgIterator Pkg) continue; } - for (pkgCache::VerFileIterator VF = Ver.FileList(); VF.end() == false; VF++) + for (pkgCache::VerFileIterator VF = Ver.FileList(); VF.end() == false; ++VF) if (FileMatch(VF.File()) == true) return Ver; } -- cgit v1.2.3 From 91c03d370d36b7a802b841394fb6afdccbd34893 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Thu, 11 Aug 2011 23:01:15 +0200 Subject: fix a few more cppcheck performance and scope warnings --- apt-pkg/contrib/netrc.cc | 7 ++++--- apt-pkg/indexcopy.cc | 3 +-- apt-pkg/orderlist.cc | 10 +++++----- apt-pkg/packagemanager.cc | 12 ++++++------ 4 files changed, 16 insertions(+), 16 deletions(-) (limited to 'apt-pkg') diff --git a/apt-pkg/contrib/netrc.cc b/apt-pkg/contrib/netrc.cc index 34f472ee1..9ff5796c5 100644 --- a/apt-pkg/contrib/netrc.cc +++ b/apt-pkg/contrib/netrc.cc @@ -47,10 +47,7 @@ int parsenetrc (char *host, char *login, char *password, char *netrcfile = NULL) int specific_login = (login[0] != 0); char *home = NULL; bool netrc_alloc = false; - int state = NOTHING; - char state_login = 0; /* Found a login keyword */ - char state_password = 0; /* Found a password keyword */ int state_our_login = false; /* With specific_login, found *our* login name */ @@ -81,6 +78,10 @@ int parsenetrc (char *host, char *login, char *password, char *netrcfile = NULL) bool done = false; char netrcbuffer[256]; + int state = NOTHING; + char state_login = 0; /* Found a login keyword */ + char state_password = 0; /* Found a password keyword */ + while (!done && fgets(netrcbuffer, sizeof (netrcbuffer), file)) { tok = strtok_r (netrcbuffer, " \t\n", &tok_buf); while (!done && tok) { diff --git a/apt-pkg/indexcopy.cc b/apt-pkg/indexcopy.cc index b262e21c4..747e464be 100644 --- a/apt-pkg/indexcopy.cc +++ b/apt-pkg/indexcopy.cc @@ -885,7 +885,6 @@ bool TranslationsCopy::CopyTranslations(string CDROM,string Name, /*{{{*/ this->Section = &Section; string Prefix; unsigned long Hits = 0; - unsigned long Chop = 0; while (Parser.Step(Section) == true) { if(Progress) @@ -903,7 +902,7 @@ bool TranslationsCopy::CopyTranslations(string CDROM,string Name, /*{{{*/ fclose(TargetFl); if (Debug == true) - cout << " Processed by using Prefix '" << Prefix << "' and chop " << Chop << endl; + cout << " Processed by using Prefix '" << Prefix << "' and chop " << endl; if (_config->FindB("APT::CDROM::NoAct",false) == false) { diff --git a/apt-pkg/orderlist.cc b/apt-pkg/orderlist.cc index 6034138cf..a58efa987 100644 --- a/apt-pkg/orderlist.cc +++ b/apt-pkg/orderlist.cc @@ -145,13 +145,13 @@ bool pkgOrderList::DoRun() Depth = 0; WipeFlags(Added | AddPending | Loop | InList); - for (iterator I = List; I != End; I++) + for (iterator I = List; I != End; ++I) Flag(*I,InList); // Rebuild the main list into the temp list. iterator OldEnd = End; End = NList; - for (iterator I = List; I != OldEnd; I++) + for (iterator I = List; I != OldEnd; ++I) if (VisitNode(PkgIterator(Cache,*I)) == false) { End = OldEnd; @@ -197,7 +197,7 @@ bool pkgOrderList::OrderCritical() { clog << "** Critical Unpack ordering done" << endl; - for (iterator I = List; I != End; I++) + for (iterator I = List; I != End; ++I) { PkgIterator P(Cache,*I); if (IsNow(P) == true) @@ -222,7 +222,7 @@ bool pkgOrderList::OrderUnpack(string *FileList) WipeFlags(After); // Set the inlist flag - for (iterator I = List; I != End; I++) + for (iterator I = List; I != End; ++I) { PkgIterator P(Cache,*I); if (IsMissing(P) == true && IsNow(P) == true) @@ -270,7 +270,7 @@ bool pkgOrderList::OrderUnpack(string *FileList) { clog << "** Unpack ordering done" << endl; - for (iterator I = List; I != End; I++) + for (iterator I = List; I != End; ++I) { PkgIterator P(Cache,*I); if (IsNow(P) == true) diff --git a/apt-pkg/packagemanager.cc b/apt-pkg/packagemanager.cc index 999a7b0a0..060cd3248 100644 --- a/apt-pkg/packagemanager.cc +++ b/apt-pkg/packagemanager.cc @@ -63,7 +63,7 @@ bool pkgPackageManager::GetArchives(pkgAcquire *Owner,pkgSourceList *Sources, if (ordering == false) return _error->Error("Internal ordering error"); - for (pkgOrderList::iterator I = List->begin(); I != List->end(); I++) + for (pkgOrderList::iterator I = List->begin(); I != List->end(); ++I) { PkgIterator Pkg(Cache,*I); FileNames[Pkg->ID] = string(); @@ -262,7 +262,7 @@ bool pkgPackageManager::ConfigureAll() pkgOrderList OList(&Cache); // Populate the order list - for (pkgOrderList::iterator I = List->begin(); I != List->end(); I++) + for (pkgOrderList::iterator I = List->begin(); I != List->end(); ++I) if (List->IsFlag(pkgCache::PkgIterator(Cache,*I), pkgOrderList::UnPacked) == true) OList.push_back(*I); @@ -274,7 +274,7 @@ bool pkgPackageManager::ConfigureAll() bool const ConfigurePkgs = (conf == "all"); // Perform the configuring - for (pkgOrderList::iterator I = OList.begin(); I != OList.end(); I++) + for (pkgOrderList::iterator I = OList.begin(); I != OList.end(); ++I) { PkgIterator Pkg(Cache,*I); @@ -309,7 +309,7 @@ bool pkgPackageManager::SmartConfigure(PkgIterator Pkg) return false; // Perform the configuring - for (pkgOrderList::iterator I = OList.begin(); I != OList.end(); I++) + for (pkgOrderList::iterator I = OList.begin(); I != OList.end(); ++I) { PkgIterator Pkg(Cache,*I); @@ -652,7 +652,7 @@ pkgPackageManager::OrderResult pkgPackageManager::OrderInstall() clog << "Done ordering" << endl; bool DoneSomething = false; - for (pkgOrderList::iterator I = List->begin(); I != List->end(); I++) + for (pkgOrderList::iterator I = List->begin(); I != List->end(); ++I) { PkgIterator Pkg(Cache,*I); @@ -701,7 +701,7 @@ pkgPackageManager::OrderResult pkgPackageManager::OrderInstall() return Failed; // Sanity check - for (pkgOrderList::iterator I = List->begin(); I != List->end(); I++) + for (pkgOrderList::iterator I = List->begin(); I != List->end(); ++I) { if (List->IsFlag(*I,pkgOrderList::Configured) == false) { -- cgit v1.2.3 From 1842a17db2ecebaf7b19de574cb4cd87c687202c Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Thu, 11 Aug 2011 23:06:46 +0200 Subject: rename the parameter name of MarkDelete from Purge to MarkPurge to fix a cosmetic warning from cppcheck: [apt-pkg/depcache.h:462] -> [apt-pkg/depcache.h:122]: (style) Variable 'Purge' hides enumerator with same name --- apt-pkg/depcache.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'apt-pkg') diff --git a/apt-pkg/depcache.h b/apt-pkg/depcache.h index 9efe110f5..760f0b589 100644 --- a/apt-pkg/depcache.h +++ b/apt-pkg/depcache.h @@ -390,7 +390,7 @@ class pkgDepCache : protected pkgCache::Namespace // @{ void MarkKeep(PkgIterator const &Pkg, bool Soft = false, bool FromUser = true, unsigned long Depth = 0); - void MarkDelete(PkgIterator const &Pkg, bool Purge = false, + void MarkDelete(PkgIterator const &Pkg, bool MarkPurge = false, unsigned long Depth = 0, bool FromUser = true); void MarkInstall(PkgIterator const &Pkg,bool AutoInst = true, unsigned long Depth = 0, bool FromUser = true, @@ -459,7 +459,7 @@ class pkgDepCache : protected pkgCache::Namespace * \param Depth recursive deep of this Marker call * \param FromUser was the remove requested by the user? */ - virtual bool IsDeleteOk(const PkgIterator &Pkg,bool Purge = false, + virtual bool IsDeleteOk(const PkgIterator &Pkg,bool MarkPurge = false, unsigned long Depth = 0, bool FromUser = true); // read persistent states -- cgit v1.2.3