summaryrefslogtreecommitdiff
path: root/apt-pkg
diff options
context:
space:
mode:
authorDavid Kalnischkies <david@kalnischkies.de>2019-09-13 12:01:47 +0200
committerDavid Kalnischkies <david@kalnischkies.de>2019-11-26 12:36:46 +0100
commit35012abf30ec1cfc9b5ee29647d4b1e25d98e99f (patch)
treeef2db5018db5878c4fc467bbcaabaac911831c3f /apt-pkg
parentfe3627d769006a223ff65afff52a21d9ba479cdf (diff)
Fix some style warnings from cppcheck
Unused variable, std::algorithms instead of raw for-loops. There should be no observeable difference in behaviour. Reported-By: cppcheck Gbp-Dch: Ignore
Diffstat (limited to 'apt-pkg')
-rw-r--r--apt-pkg/acquire-item.cc27
-rw-r--r--apt-pkg/acquire.cc2
-rw-r--r--apt-pkg/contrib/configuration.cc9
-rw-r--r--apt-pkg/contrib/fileutl.cc2
4 files changed, 22 insertions, 18 deletions
diff --git a/apt-pkg/acquire-item.cc b/apt-pkg/acquire-item.cc
index 58bd6475e..a108eb213 100644
--- a/apt-pkg/acquire-item.cc
+++ b/apt-pkg/acquire-item.cc
@@ -2025,7 +2025,6 @@ void pkgAcqMetaClearSig::Failed(string const &Message,pkgAcquire::MethodConfig c
* they would be considered as trusted later on */
string const FinalRelease = GetFinalFileNameFromURI(DetachedDataTarget.URI);
string const PartialRelease = GetPartialFileNameFromURI(DetachedDataTarget.URI);
- string const FinalReleasegpg = GetFinalFileNameFromURI(DetachedSigTarget.URI);
string const FinalInRelease = GetFinalFilename();
Rename(DestFile, PartialRelease);
TransactionManager->TransactionStageCopy(this, PartialRelease, FinalRelease);
@@ -2586,14 +2585,18 @@ bool pkgAcqDiffIndex::ParseDiffIndex(string const &IndexDiffFile) /*{{{*/
return false;
}
- for (auto const &patch: available_patches)
- if (patch.result_hashes.usable() == false ||
- patch.patch_hashes.usable() == false ||
- patch.download_hashes.usable() == false)
+ {
+ auto const patch = std::find_if(available_patches.cbegin(), available_patches.cend(), [](auto const &patch) {
+ return not patch.result_hashes.usable() ||
+ not patch.patch_hashes.usable() ||
+ not patch.download_hashes.usable();
+ });
+ if (patch != available_patches.cend())
{
- strprintf(ErrorText, "Provides no usable hashes for %s", patch.file.c_str());
+ strprintf(ErrorText, "Provides no usable hashes for %s", patch->file.c_str());
return false;
}
+ }
// patching with too many files is rather slow compared to a fast download
unsigned long const fileLimit = _config->FindI("Acquire::PDiffs::FileLimit", 0);
@@ -2655,13 +2658,15 @@ bool pkgAcqDiffIndex::ParseDiffIndex(string const &IndexDiffFile) /*{{{*/
return false;
std::string const PartialFile = GetPartialFileNameFromURI(Target.URI);
std::string const PatchedFile = GetKeepCompressedFileName(PartialFile + "-patched", Target);
- if (RemoveFileForBootstrapLinking(ErrorText, CurrentPackagesFile, PartialFile) == false ||
- RemoveFileForBootstrapLinking(ErrorText, CurrentPackagesFile, PatchedFile) == false)
+ if (not RemoveFileForBootstrapLinking(ErrorText, CurrentPackagesFile, PartialFile) ||
+ not RemoveFileForBootstrapLinking(ErrorText, CurrentPackagesFile, PatchedFile))
return false;
- for (auto const &ext : APT::Configuration::getCompressorExtensions())
{
- if (RemoveFileForBootstrapLinking(ErrorText, CurrentPackagesFile, PartialFile + ext) == false ||
- RemoveFileForBootstrapLinking(ErrorText, CurrentPackagesFile, PatchedFile + ext) == false)
+ auto const exts = APT::Configuration::getCompressorExtensions();
+ if (not std::all_of(exts.cbegin(), exts.cend(), [&](auto const &ext) {
+ return RemoveFileForBootstrapLinking(ErrorText, CurrentPackagesFile, PartialFile + ext) &&
+ RemoveFileForBootstrapLinking(ErrorText, CurrentPackagesFile, PatchedFile + ext);
+ }))
return false;
}
std::string const Ext = Final.substr(CurrentPackagesFile.length());
diff --git a/apt-pkg/acquire.cc b/apt-pkg/acquire.cc
index 776c82b3b..dd7dedb03 100644
--- a/apt-pkg/acquire.cc
+++ b/apt-pkg/acquire.cc
@@ -1378,8 +1378,6 @@ bool pkgAcquireStatus::Pulse(pkgAcquire *Owner)
int fd = _config->FindI("APT::Status-Fd",-1);
if(fd > 0)
{
- ostringstream status;
-
unsigned long long ETA = 0;
if(CurrentCPS > 0 && TotalBytes > CurrentBytes)
ETA = (TotalBytes - CurrentBytes) / CurrentCPS;
diff --git a/apt-pkg/contrib/configuration.cc b/apt-pkg/contrib/configuration.cc
index 997ef7423..931df9f6c 100644
--- a/apt-pkg/contrib/configuration.cc
+++ b/apt-pkg/contrib/configuration.cc
@@ -32,6 +32,7 @@
#include <algorithm>
#include <fstream>
#include <iterator>
+#include <numeric>
#include <sstream>
#include <stack>
#include <string>
@@ -1149,10 +1150,10 @@ bool ReadConfigFile(Configuration &Conf,const string &FName,bool const &AsSectio
bool ReadConfigDir(Configuration &Conf,const string &Dir,
bool const &AsSectional, unsigned const &Depth)
{
- bool good = true;
- for (auto const &I : GetListOfFilesInDir(Dir, "conf", true, true))
- good = ReadConfigFile(Conf, I, AsSectional, Depth) && good;
- return good;
+ auto const files = GetListOfFilesInDir(Dir, "conf", true, true);
+ return std::accumulate(files.cbegin(), files.cend(), true, [&](bool good, auto const &file) {
+ return ReadConfigFile(Conf, file, AsSectional, Depth) && good;
+ });
}
/*}}}*/
// MatchAgainstConfig Constructor /*{{{*/
diff --git a/apt-pkg/contrib/fileutl.cc b/apt-pkg/contrib/fileutl.cc
index 336f979d6..b83a4bad7 100644
--- a/apt-pkg/contrib/fileutl.cc
+++ b/apt-pkg/contrib/fileutl.cc
@@ -1781,7 +1781,7 @@ class APT_HIDDEN ZstdFileFdPrivate : public FileFdPrivate
#ifdef HAVE_ZSTD
ZSTD_DStream *dctx;
ZSTD_CStream *cctx;
- size_t res;
+ size_t res = 0;
FileFd backend;
simple_buffer zstd_buffer;
// Count of bytes that the decompressor expects to read next, or buffer size.