From 258b9e512c4001e806c5c0966acecd3d742ec6e9 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Wed, 4 Nov 2015 21:08:55 +0100 Subject: apply various suggestions made by cppcheck Reported-By: cppcheck Git-Dch: Ignore --- apt-pkg/acquire-item.cc | 12 ++++-------- apt-pkg/algorithms.cc | 2 +- apt-pkg/deb/dpkgpm.cc | 2 +- apt-pkg/indexfile.h | 2 +- apt-pkg/pkgcachegen.cc | 1 - apt-pkg/policy.cc | 4 ++-- 6 files changed, 9 insertions(+), 14 deletions(-) (limited to 'apt-pkg') diff --git a/apt-pkg/acquire-item.cc b/apt-pkg/acquire-item.cc index 834776404..9d1c2cc61 100644 --- a/apt-pkg/acquire-item.cc +++ b/apt-pkg/acquire-item.cc @@ -2237,14 +2237,10 @@ 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.empty() == false && - I != available_patches.end() && - I->result_hashes != LocalHashes; - ++I) - { - available_patches.erase(I); - } + available_patches.erase(available_patches.begin(), + std::find_if(available_patches.begin(), available_patches.end(), [&](DiffInfo const &I) { + return I.result_hashes == LocalHashes; + })); // error checking and falling back if no patch was found if(available_patches.empty() == true) diff --git a/apt-pkg/algorithms.cc b/apt-pkg/algorithms.cc index d25cbd63a..4b84b8324 100644 --- a/apt-pkg/algorithms.cc +++ b/apt-pkg/algorithms.cc @@ -1315,7 +1315,7 @@ void pkgProblemResolver::InstallProtect() struct PrioComp { pkgCache &PrioCache; - PrioComp(pkgCache &PrioCache) : PrioCache(PrioCache) { + explicit PrioComp(pkgCache &PrioCache) : PrioCache(PrioCache) { } bool operator() (pkgCache::Version * const &A, pkgCache::Version * const &B) { diff --git a/apt-pkg/deb/dpkgpm.cc b/apt-pkg/deb/dpkgpm.cc index d253808f2..7355af9d5 100644 --- a/apt-pkg/deb/dpkgpm.cc +++ b/apt-pkg/deb/dpkgpm.cc @@ -126,7 +126,7 @@ namespace const char *target; public: - MatchProcessingOp(const char *the_target) + explicit MatchProcessingOp(const char *the_target) : target(the_target) { } diff --git a/apt-pkg/indexfile.h b/apt-pkg/indexfile.h index c3f01c774..79abe2f4f 100644 --- a/apt-pkg/indexfile.h +++ b/apt-pkg/indexfile.h @@ -168,7 +168,7 @@ public: virtual bool Merge(pkgCacheGenerator &Gen, OpProgress* const Prog) APT_OVERRIDE; virtual pkgCache::PkgFileIterator FindInCache(pkgCache &Cache) const APT_OVERRIDE; - pkgDebianIndexFile(bool const Trusted); + explicit pkgDebianIndexFile(bool const Trusted); virtual ~pkgDebianIndexFile(); }; diff --git a/apt-pkg/pkgcachegen.cc b/apt-pkg/pkgcachegen.cc index 69c8fd105..5c61ff2b8 100644 --- a/apt-pkg/pkgcachegen.cc +++ b/apt-pkg/pkgcachegen.cc @@ -1434,7 +1434,6 @@ static bool BuildCache(pkgCacheGenerator &Gen, pkgSourceList const * const List, FileIterator const Start, FileIterator const End) { - std::vector Files; bool mergeFailure = false; auto const indexFileMerge = [&](pkgIndexFile * const I) { diff --git a/apt-pkg/policy.cc b/apt-pkg/policy.cc index 4f953bd50..d442e5c90 100644 --- a/apt-pkg/policy.cc +++ b/apt-pkg/policy.cc @@ -235,7 +235,7 @@ pkgCache::VerIterator pkgPolicy::GetCandidateVerNew(pkgCache::PkgIterator const int candPriority = -1; pkgVersioningSystem *vs = Cache->VS; - for (pkgCache::VerIterator ver = Pkg.VersionList(); ver.end() == false; ver++) { + for (pkgCache::VerIterator ver = Pkg.VersionList(); ver.end() == false; ++ver) { int priority = GetPriority(ver, true); if (priority == 0 || priority <= candPriority) @@ -322,7 +322,7 @@ void pkgPolicy::CreatePin(pkgVersionMatch::MatchType Type,string Name, // Find matching version(s) and copy the pin into it pkgVersionMatch Match(P->Data,P->Type); - for (pkgCache::VerIterator Ver = Pkg.VersionList(); Ver.end() != true; Ver++) + for (pkgCache::VerIterator Ver = Pkg.VersionList(); Ver.end() != true; ++Ver) { if (Match.VersionMatches(Ver)) { Pin *VP = VerPins + Ver->ID; -- cgit v1.2.3