summaryrefslogtreecommitdiff
path: root/apt-pkg
diff options
context:
space:
mode:
authorDavid Kalnischkies <david@kalnischkies.de>2019-07-08 15:48:59 +0200
committerDavid Kalnischkies <david@kalnischkies.de>2019-07-08 15:51:17 +0200
commit2b734a7ec429825c7007c1093883229e069d36c7 (patch)
treeb67360f3201634c82f5a9e7dd84f47b28fa63acb /apt-pkg
parentcbe90ee516d7f747f981e423f164f99eb767240b (diff)
Apply various suggestions by cppcheck
Reported-By: cppcheck
Diffstat (limited to 'apt-pkg')
-rw-r--r--apt-pkg/acquire-item.cc1
-rw-r--r--apt-pkg/contrib/cmndline.cc3
-rw-r--r--apt-pkg/contrib/hashes.cc5
-rw-r--r--apt-pkg/contrib/strutl.cc9
-rw-r--r--apt-pkg/deb/debmetaindex.cc6
5 files changed, 12 insertions, 12 deletions
diff --git a/apt-pkg/acquire-item.cc b/apt-pkg/acquire-item.cc
index cbfc91007..58bd6475e 100644
--- a/apt-pkg/acquire-item.cc
+++ b/apt-pkg/acquire-item.cc
@@ -3382,7 +3382,6 @@ pkgAcqArchive::pkgAcqArchive(pkgAcquire *const Owner, pkgSourceList *const Sourc
Trusted = false;
StoreFilename.clear();
- std::set<string> targetComponents, targetCodenames, targetSuites;
std::vector<std::unique_ptr<FileFd>> authconfs;
for (auto Vf = Version.FileList(); Vf.end() == false; ++Vf)
{
diff --git a/apt-pkg/contrib/cmndline.cc b/apt-pkg/contrib/cmndline.cc
index b2a96cadf..3b844edc2 100644
--- a/apt-pkg/contrib/cmndline.cc
+++ b/apt-pkg/contrib/cmndline.cc
@@ -300,7 +300,8 @@ bool CommandLine::HandleOpt(int &I,int argc,const char *argv[],
// Skip the leading dash
const char *J = argv[I];
- for (; *J != 0 && *J == '-'; J++);
+ for (; *J == '-'; J++)
+ ;
const char *JEnd = strchr(J, '-');
if (JEnd != NULL)
diff --git a/apt-pkg/contrib/hashes.cc b/apt-pkg/contrib/hashes.cc
index d03fb6083..366133b02 100644
--- a/apt-pkg/contrib/hashes.cc
+++ b/apt-pkg/contrib/hashes.cc
@@ -169,10 +169,7 @@ bool HashStringList::usable() const /*{{{*/
if (forcedType.empty() == true)
{
// See if there is at least one usable hash
- for (auto const &hs: list)
- if (hs.usable())
- return true;
- return false;
+ return std::any_of(list.begin(), list.end(), [](auto const &hs) { return hs.usable(); });
}
return find(forcedType) != NULL;
}
diff --git a/apt-pkg/contrib/strutl.cc b/apt-pkg/contrib/strutl.cc
index e02067e13..860e3fe47 100644
--- a/apt-pkg/contrib/strutl.cc
+++ b/apt-pkg/contrib/strutl.cc
@@ -239,7 +239,8 @@ bool ParseQuoteWord(const char *&String,string &Res)
{
// Skip leading whitespace
const char *C = String;
- for (;*C != 0 && *C == ' '; C++);
+ for (; *C == ' '; C++)
+ ;
if (*C == 0)
return false;
@@ -287,7 +288,8 @@ bool ParseQuoteWord(const char *&String,string &Res)
Res = Buffer;
// Skip ending white space
- for (;*C != 0 && isspace(*C) != 0; C++);
+ for (; isspace(*C) != 0; C++)
+ ;
String = C;
return true;
}
@@ -300,7 +302,8 @@ bool ParseCWord(const char *&String,string &Res)
{
// Skip leading whitespace
const char *C = String;
- for (;*C != 0 && *C == ' '; C++);
+ for (; *C == ' '; C++)
+ ;
if (*C == 0)
return false;
diff --git a/apt-pkg/deb/debmetaindex.cc b/apt-pkg/deb/debmetaindex.cc
index 71e047257..a88b19807 100644
--- a/apt-pkg/deb/debmetaindex.cc
+++ b/apt-pkg/deb/debmetaindex.cc
@@ -986,7 +986,7 @@ class APT_HIDDEN debSLTypeDebian : public pkgSourceList::Type /*{{{*/
return std::find(minus.begin(), minus.end(), v) != minus.end();
}), Values.end());
}
- return Values;
+ return std::move(Values);
}
static std::vector<std::string> parsePlusMinusOptions(std::string const &Name,
std::map<std::string, std::string> const &Options, std::vector<std::string> const &defaultValues)
@@ -1095,8 +1095,8 @@ class APT_HIDDEN debSLTypeDebian : public pkgSourceList::Type /*{{{*/
{
std::vector<std::string> ret;
ret.reserve(Options.size());
- for (auto &&O: Options)
- ret.emplace_back(O.first);
+ std::transform(Options.begin(), Options.end(), std::back_inserter(ret),
+ [](auto &&O) { return O.first; });
std::sort(ret.begin(), ret.end());
return ret;
}