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 --- ftparchive/contents.cc | 2 +- ftparchive/multicompress.cc | 6 ++---- ftparchive/writer.cc | 5 ++--- 3 files changed, 5 insertions(+), 8 deletions(-) (limited to 'ftparchive') diff --git a/ftparchive/contents.cc b/ftparchive/contents.cc index a743283b0..8a7adfd8e 100644 --- a/ftparchive/contents.cc +++ b/ftparchive/contents.cc @@ -204,7 +204,7 @@ void GenContents::Add(const char *Dir,const char *Package) Node *Root = &this->Root; // Drop leading slashes - while (*Dir == '/' && *Dir != 0) + while (*Dir == '/') Dir++; // Run over the string and grab out each bit up to and including a / diff --git a/ftparchive/multicompress.cc b/ftparchive/multicompress.cc index 19e6563e0..f5fe14164 100644 --- a/ftparchive/multicompress.cc +++ b/ftparchive/multicompress.cc @@ -56,12 +56,10 @@ static std::vector::const_iterator findMatchingC // MultiCompress::MultiCompress - Constructor /*{{{*/ // --------------------------------------------------------------------- /* Setup the file outputs, compression modes and fork the writer child */ -MultiCompress::MultiCompress(string const &Output,string const &Compress, - mode_t const &Permissions,bool const &Write) : - Permissions(Permissions) +MultiCompress::MultiCompress(string const &Output, string const &Compress, + mode_t const &Permissions, bool const &Write) : Outputter{-1}, Permissions(Permissions) { Outputs = 0; - Outputter = -1; UpdateMTime = 0; auto const Compressors = APT::Configuration::getCompressors(); diff --git a/ftparchive/writer.cc b/ftparchive/writer.cc index dbc097af6..078638c41 100644 --- a/ftparchive/writer.cc +++ b/ftparchive/writer.cc @@ -216,9 +216,8 @@ bool FTWScanner::RecursiveScan(string const &Dir) std::sort(FilesToProcess.begin(), FilesToProcess.end(), [](PairType a, PairType b) { return a.first < b.first; }); - for (PairType it : FilesToProcess) - if (ProcessFile(it.first.c_str(), it.second) != 0) - return false; + if (not std::all_of(FilesToProcess.cbegin(), FilesToProcess.cend(), [](auto &&it) { return ProcessFile(it.first.c_str(), it.second) == 0; })) + return false; FilesToProcess.clear(); return true; } -- cgit v1.2.3