summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Kalnischkies <david@kalnischkies.de>2015-11-04 21:08:55 +0100
committerDavid Kalnischkies <david@kalnischkies.de>2015-11-05 12:21:33 +0100
commit258b9e512c4001e806c5c0966acecd3d742ec6e9 (patch)
treec8bdbb43dd9e1b5d54b90e4845065a653d585ca5
parent9fb4e6510faaa9c84b88d4cb567bf3deebf8e0b7 (diff)
downloadapt-258b9e512c4001e806c5c0966acecd3d742ec6e9.tar.gz
apply various suggestions made by cppcheck
Reported-By: cppcheck Git-Dch: Ignore
-rw-r--r--apt-inst/contrib/extracttar.cc2
-rw-r--r--apt-pkg/acquire-item.cc12
-rw-r--r--apt-pkg/algorithms.cc2
-rw-r--r--apt-pkg/deb/dpkgpm.cc2
-rw-r--r--apt-pkg/indexfile.h2
-rw-r--r--apt-pkg/pkgcachegen.cc1
-rw-r--r--apt-pkg/policy.cc4
-rw-r--r--apt-private/acqprogress.cc3
-rw-r--r--apt-private/private-cachefile.h2
-rw-r--r--apt-private/private-cacheset.cc6
-rw-r--r--apt-private/private-cacheset.h2
-rw-r--r--apt-private/private-install.cc2
-rw-r--r--apt-private/private-list.cc2
-rw-r--r--apt-private/private-show.cc2
-rw-r--r--ftparchive/apt-ftparchive.cc8
-rw-r--r--ftparchive/cachedb.h2
-rw-r--r--ftparchive/contents.cc2
-rw-r--r--methods/ftp.h2
-rw-r--r--methods/gzip.cc2
-rw-r--r--methods/http.h2
-rw-r--r--methods/https.cc4
-rw-r--r--methods/https.h4
-rw-r--r--methods/rred.cc4
-rw-r--r--methods/rsh.h4
-rw-r--r--test/libapt/acqprogress_test.cc2
25 files changed, 35 insertions, 45 deletions
diff --git a/apt-inst/contrib/extracttar.cc b/apt-inst/contrib/extracttar.cc
index 8be61c5ad..60360053e 100644
--- a/apt-inst/contrib/extracttar.cc
+++ b/apt-inst/contrib/extracttar.cc
@@ -101,7 +101,7 @@ bool ExtractTar::StartGzip()
std::vector<APT::Configuration::Compressor> const compressors = APT::Configuration::getCompressors();
std::vector<APT::Configuration::Compressor>::const_iterator compressor = compressors.begin();
- for (; compressor != compressors.end(); compressor++) {
+ for (; compressor != compressors.end(); ++compressor) {
if (compressor->Name == DecompressProg) {
return InFd.OpenDescriptor(File.Fd(), FileFd::ReadOnly, *compressor, false);
}
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<DiffInfo>::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<pkgIndexFile *> 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;
diff --git a/apt-private/acqprogress.cc b/apt-private/acqprogress.cc
index dcc538a39..a33d51c71 100644
--- a/apt-private/acqprogress.cc
+++ b/apt-private/acqprogress.cc
@@ -176,8 +176,6 @@ bool AcqTextStatus::Pulse(pkgAcquire *Owner)
if (Quiet > 0)
return true;
- enum {Long = 0,Medium,Short} Mode = Medium;
-
std::string Line;
{
std::stringstream S;
@@ -203,6 +201,7 @@ bool AcqTextStatus::Pulse(pkgAcquire *Owner)
if (I->CurrentItem->Owner->ActiveSubprocess.empty() == false)
S << " " << I->CurrentItem->Owner->ActiveSubprocess;
+ enum {Long = 0,Medium,Short} Mode = Medium;
// Add the current progress
if (Mode == Long)
S << " " << I->CurrentSize;
diff --git a/apt-private/private-cachefile.h b/apt-private/private-cachefile.h
index 51703b0ad..27642e025 100644
--- a/apt-private/private-cachefile.h
+++ b/apt-private/private-cachefile.h
@@ -46,7 +46,7 @@ class SortedPackageUniverse : public APT::PackageUniverse
void LazyInit() const;
public:
- SortedPackageUniverse(CacheFile &Cache);
+ explicit SortedPackageUniverse(CacheFile &Cache);
class const_iterator : public APT::Container_iterator_base<APT::PackageContainerInterface, SortedPackageUniverse, SortedPackageUniverse::const_iterator, std::vector<map_pointer_t>::const_iterator, pkgCache::PkgIterator>
{
diff --git a/apt-private/private-cacheset.cc b/apt-private/private-cacheset.cc
index 439b844d5..981766cdf 100644
--- a/apt-private/private-cacheset.cc
+++ b/apt-private/private-cacheset.cc
@@ -179,8 +179,8 @@ CacheSetHelperVirtuals::CacheSetHelperVirtuals(bool const ShowErrors, GlobalErro
/*}}}*/
// CacheSetHelperAPTGet - responsible for message telling from the CacheSets/*{{{*/
-CacheSetHelperAPTGet::CacheSetHelperAPTGet(std::ostream &out) :
- APT::CacheSetHelper{true}, out(out)
+CacheSetHelperAPTGet::CacheSetHelperAPTGet(std::ostream &pout) :
+ APT::CacheSetHelper{true}, out(pout)
{
explicitlyNamed = true;
}
@@ -245,8 +245,6 @@ bool CacheSetHelperAPTGet::showVirtualPackageErrors(pkgCacheFile &Cache)
"This may mean that the package is missing, has been obsoleted, or\n"
"is only available from another source\n"),Pkg.FullName(true).c_str());
- std::string List;
- std::string VersionsList;
std::vector<bool> Seen(Cache.GetPkgCache()->Head().PackageCount, false);
APT::PackageList pkglist;
for (pkgCache::DepIterator Dep = Pkg.RevDependsList();
diff --git a/apt-private/private-cacheset.h b/apt-private/private-cacheset.h
index 2b452ab7d..4cbc4efa1 100644
--- a/apt-private/private-cacheset.h
+++ b/apt-private/private-cacheset.h
@@ -89,7 +89,7 @@ class APT_PUBLIC CacheSetHelperAPTGet : public APT::CacheSetHelper {
public:
std::list<std::pair<pkgCache::VerIterator, std::string> > selectedByRelease;
- CacheSetHelperAPTGet(std::ostream &out);
+ explicit CacheSetHelperAPTGet(std::ostream &out);
virtual void showTaskSelection(pkgCache::PkgIterator const &Pkg, std::string const &pattern) APT_OVERRIDE;
virtual void showFnmatchSelection(pkgCache::PkgIterator const &Pkg, std::string const &pattern) APT_OVERRIDE;
diff --git a/apt-private/private-install.cc b/apt-private/private-install.cc
index 52572ed80..74a2424c5 100644
--- a/apt-private/private-install.cc
+++ b/apt-private/private-install.cc
@@ -666,7 +666,7 @@ struct PkgIsExtraInstalled {
pkgCacheFile * const Cache;
APT::VersionSet const * const verset;
PkgIsExtraInstalled(pkgCacheFile * const Cache, APT::VersionSet const * const Container) : Cache(Cache), verset(Container) {}
- bool operator() (pkgCache::PkgIterator const Pkg)
+ bool operator() (pkgCache::PkgIterator const &Pkg)
{
if ((*Cache)[Pkg].Install() == false)
return false;
diff --git a/apt-private/private-list.cc b/apt-private/private-list.cc
index c4d5e8bc3..a948c7d9f 100644
--- a/apt-private/private-list.cc
+++ b/apt-private/private-list.cc
@@ -41,7 +41,7 @@ struct PackageSortAlphabetic /*{{{*/
class PackageNameMatcher : public Matcher
{
public:
- PackageNameMatcher(const char **patterns)
+ explicit PackageNameMatcher(const char **patterns)
{
for(int i=0; patterns[i] != NULL; ++i)
{
diff --git a/apt-private/private-show.cc b/apt-private/private-show.cc
index aaa4268c6..34214d955 100644
--- a/apt-private/private-show.cc
+++ b/apt-private/private-show.cc
@@ -396,7 +396,7 @@ bool Policy(CommandLine &CmdL)
continue;
}
// New code
- for (pkgCache::VerIterator V = I.VersionList(); !V.end(); V++) {
+ for (pkgCache::VerIterator V = I.VersionList(); !V.end(); ++V) {
auto Prio = Plcy->GetPriority(V, false);
if (Prio == 0)
continue;
diff --git a/ftparchive/apt-ftparchive.cc b/ftparchive/apt-ftparchive.cc
index c7e38badf..bb3ade1e8 100644
--- a/ftparchive/apt-ftparchive.cc
+++ b/ftparchive/apt-ftparchive.cc
@@ -819,12 +819,12 @@ static bool DoGeneratePackagesAndSources(Configuration &Setup,
_error->DumpErrors();
// Do the generation for Packages
- for (End = List; End->Str != 0; End++)
+ for (End = List; End->Str != 0; ++End)
{
if (End->Hit == false)
continue;
- PackageMap *I = (PackageMap *)End->UserData;
+ PackageMap * const I = static_cast<PackageMap *>(End->UserData);
if (I->PkgDone == true)
continue;
if (I->GenPackages(Setup,Stats) == false)
@@ -832,12 +832,12 @@ static bool DoGeneratePackagesAndSources(Configuration &Setup,
}
// Do the generation for Sources
- for (End = List; End->Str != 0; End++)
+ for (End = List; End->Str != 0; ++End)
{
if (End->Hit == false)
continue;
- PackageMap *I = (PackageMap *)End->UserData;
+ PackageMap * const I = static_cast<PackageMap *>(End->UserData);
if (I->SrcDone == true)
continue;
if (I->GenSources(Setup,SrcStats) == false)
diff --git a/ftparchive/cachedb.h b/ftparchive/cachedb.h
index 613963f6f..417c25a9f 100644
--- a/ftparchive/cachedb.h
+++ b/ftparchive/cachedb.h
@@ -189,7 +189,7 @@ class CacheDB
bool Clean();
- CacheDB(std::string const &DB);
+ explicit CacheDB(std::string const &DB);
~CacheDB();
};
diff --git a/ftparchive/contents.cc b/ftparchive/contents.cc
index 145f3910e..0ce15b3d6 100644
--- a/ftparchive/contents.cc
+++ b/ftparchive/contents.cc
@@ -100,7 +100,7 @@ void *GenContents::Node::operator new(size_t Amount,GenContents *Owner)
if (Owner->NodeLeft == 0)
{
Owner->NodeLeft = 10000;
- Owner->NodePool = (Node *)malloc(Amount*Owner->NodeLeft);
+ Owner->NodePool = static_cast<Node *>(malloc(Amount*Owner->NodeLeft));
BigBlock *Block = new BigBlock;
Block->Block = Owner->NodePool;
Block->Next = Owner->BlockList;
diff --git a/methods/ftp.h b/methods/ftp.h
index c5165782d..de2c232bd 100644
--- a/methods/ftp.h
+++ b/methods/ftp.h
@@ -68,7 +68,7 @@ class FTPConn
Hashes &MD5,bool &Missing, unsigned long long MaximumSize,
pkgAcqMethod *Owner);
- FTPConn(URI Srv);
+ explicit FTPConn(URI Srv);
~FTPConn();
};
diff --git a/methods/gzip.cc b/methods/gzip.cc
index fbfd3bbac..c470807ac 100644
--- a/methods/gzip.cc
+++ b/methods/gzip.cc
@@ -36,7 +36,7 @@ class GzipMethod : public aptMethod
public:
- GzipMethod(std::string const &pProg) : aptMethod(pProg.c_str(),"1.1",SingleInstance | SendConfig), Prog(pProg) {};
+ explicit GzipMethod(std::string const &pProg) : aptMethod(pProg.c_str(),"1.1",SingleInstance | SendConfig), Prog(pProg) {};
};
// GzipMethod::Fetch - Decompress the passed URI /*{{{*/
diff --git a/methods/http.h b/methods/http.h
index 7b7e78b64..9e2b1da5c 100644
--- a/methods/http.h
+++ b/methods/http.h
@@ -87,7 +87,7 @@ class CircleBuf
// Dump everything
void Stats();
- CircleBuf(unsigned long long Size);
+ explicit CircleBuf(unsigned long long Size);
~CircleBuf();
};
diff --git a/methods/https.cc b/methods/https.cc
index 8d9454545..a99b1861b 100644
--- a/methods/https.cc
+++ b/methods/https.cc
@@ -49,7 +49,7 @@ size_t
HttpsMethod::parse_header(void *buffer, size_t size, size_t nmemb, void *userp)
{
size_t len = size * nmemb;
- CURLUserPointer *me = (CURLUserPointer *)userp;
+ CURLUserPointer *me = static_cast<CURLUserPointer *>(userp);
std::string line((char*) buffer, len);
for (--len; len > 0; --len)
if (isspace(line[len]) == 0)
@@ -115,7 +115,7 @@ HttpsMethod::parse_header(void *buffer, size_t size, size_t nmemb, void *userp)
size_t
HttpsMethod::write_data(void *buffer, size_t size, size_t nmemb, void *userp)
{
- HttpsMethod *me = (HttpsMethod *)userp;
+ HttpsMethod *me = static_cast<HttpsMethod *>(userp);
size_t buffer_size = size * nmemb;
// we don't need to count the junk here, just drop anything we get as
// we don't always know how long it would be, e.g. in chunked encoding.
diff --git a/methods/https.h b/methods/https.h
index 0147f96a0..4d50c5a04 100644
--- a/methods/https.h
+++ b/methods/https.h
@@ -68,21 +68,19 @@ class HttpsMethod : public ServerMethod
double ultotal, double ulnow);
void SetupProxy();
CURL *curl;
- std::unique_ptr<ServerState> Server;
// Used by ServerMethods unused by https
virtual void SendReq(FetchItem *) APT_OVERRIDE { exit(42); }
virtual void RotateDNS() APT_OVERRIDE { exit(42); }
public:
- FileFd *File;
virtual bool Configuration(std::string Message) APT_OVERRIDE;
virtual std::unique_ptr<ServerState> CreateServerState(URI const &uri) APT_OVERRIDE;
using pkgAcqMethod::FetchResult;
using pkgAcqMethod::FetchItem;
- HttpsMethod() : ServerMethod("https","1.2",Pipeline | SendConfig), File(NULL)
+ HttpsMethod() : ServerMethod("https","1.2",Pipeline | SendConfig)
{
curl = curl_easy_init();
};
diff --git a/methods/rred.cc b/methods/rred.cc
index b379d384d..bb801cb4e 100644
--- a/methods/rred.cc
+++ b/methods/rred.cc
@@ -39,7 +39,7 @@ class MemBlock {
char *free;
MemBlock *next;
- MemBlock(size_t size) : size(size), next(NULL)
+ explicit MemBlock(size_t size) : size(size), next(NULL)
{
free = start = new char[size];
}
@@ -118,7 +118,7 @@ struct Change {
size_t add_len; /* bytes */
char *add;
- Change(size_t off)
+ explicit Change(size_t off)
{
offset = off;
del_cnt = add_cnt = add_len = 0;
diff --git a/methods/rsh.h b/methods/rsh.h
index 9ca14425f..35cbee3e0 100644
--- a/methods/rsh.h
+++ b/methods/rsh.h
@@ -49,7 +49,7 @@ class RSHConn
bool Get(const char *Path,FileFd &To,unsigned long long Resume,
Hashes &Hash,bool &Missing, unsigned long long Size);
- RSHConn(URI Srv);
+ explicit RSHConn(URI Srv);
~RSHConn();
};
@@ -71,7 +71,7 @@ class RSHMethod : public aptMethod
public:
- RSHMethod(std::string const &Prog);
+ explicit RSHMethod(std::string const &Prog);
};
#endif
diff --git a/test/libapt/acqprogress_test.cc b/test/libapt/acqprogress_test.cc
index 50792528d..0e82a285d 100644
--- a/test/libapt/acqprogress_test.cc
+++ b/test/libapt/acqprogress_test.cc
@@ -11,7 +11,7 @@
class TestItem: public pkgAcquire::Item
{
public:
- TestItem(pkgAcquire * const Acq) : pkgAcquire::Item(Acq) {}
+ explicit TestItem(pkgAcquire * const Acq) : pkgAcquire::Item(Acq) {}
virtual std::string DescURI() const APT_OVERRIDE { return ""; }
virtual HashStringList GetExpectedHashes() const APT_OVERRIDE { return HashStringList(); }