From 2b734a7ec429825c7007c1093883229e069d36c7 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Mon, 8 Jul 2019 15:48:59 +0200 Subject: Apply various suggestions by cppcheck Reported-By: cppcheck --- apt-pkg/acquire-item.cc | 1 - apt-pkg/contrib/cmndline.cc | 3 ++- apt-pkg/contrib/hashes.cc | 5 +---- apt-pkg/contrib/strutl.cc | 9 ++++++--- apt-pkg/deb/debmetaindex.cc | 6 +++--- 5 files changed, 12 insertions(+), 12 deletions(-) (limited to 'apt-pkg') 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 targetComponents, targetCodenames, targetSuites; std::vector> 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 parsePlusMinusOptions(std::string const &Name, std::map const &Options, std::vector const &defaultValues) @@ -1095,8 +1095,8 @@ class APT_HIDDEN debSLTypeDebian : public pkgSourceList::Type /*{{{*/ { std::vector 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; } -- cgit v1.2.3