summaryrefslogtreecommitdiff
path: root/apt-pkg/contrib
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/contrib
parentcbe90ee516d7f747f981e423f164f99eb767240b (diff)
Apply various suggestions by cppcheck
Reported-By: cppcheck
Diffstat (limited to 'apt-pkg/contrib')
-rw-r--r--apt-pkg/contrib/cmndline.cc3
-rw-r--r--apt-pkg/contrib/hashes.cc5
-rw-r--r--apt-pkg/contrib/strutl.cc9
3 files changed, 9 insertions, 8 deletions
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;