summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--README.md2
-rw-r--r--apt-pkg/acquire-item.cc1
-rw-r--r--apt-pkg/acquire.cc110
-rw-r--r--apt-pkg/algorithms.h2
-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/deblistparser.cc7
-rw-r--r--apt-pkg/deb/debmetaindex.cc6
-rw-r--r--apt-pkg/edsp/edspindexfile.cc4
-rw-r--r--apt-pkg/packagemanager.cc2
-rw-r--r--apt-pkg/pkgcache.cc2
-rw-r--r--apt-pkg/pkgsystem.h2
-rw-r--r--apt-pkg/sourcelist.cc2
-rw-r--r--apt-pkg/sourcelist.h2
-rw-r--r--apt-private/private-cacheset.cc9
-rw-r--r--apt-private/private-cmndline.cc7
-rw-r--r--apt-private/private-install.cc6
-rw-r--r--apt-private/private-json-hooks.cc2
-rw-r--r--apt-private/private-show.cc2
-rw-r--r--apt-private/private-source.cc4
-rw-r--r--cmdline/apt-cache.cc15
-rw-r--r--cmdline/apt-extracttemplates.cc2
-rw-r--r--cmdline/apt-get.cc7
-rw-r--r--cmdline/apt-helper.cc4
-rw-r--r--cmdline/apt-internal-solver.cc1
-rw-r--r--debian/changelog4
-rw-r--r--debian/libapt-pkg-doc.doc-base.dpkg-tech2
-rw-r--r--ftparchive/contents.cc2
-rw-r--r--ftparchive/multicompress.cc6
-rw-r--r--ftparchive/writer.cc5
-rw-r--r--methods/aptmethod.h4
-rw-r--r--methods/basehttp.cc1
-rw-r--r--methods/cdrom.cc4
-rw-r--r--methods/connect.cc2
-rw-r--r--methods/connect.h2
-rw-r--r--methods/file.cc1
-rw-r--r--methods/http.cc13
-rw-r--r--methods/mirror.cc10
-rw-r--r--methods/rfc2553emu.cc4
-rw-r--r--methods/rsh.cc4
-rw-r--r--methods/rsh.h4
-rwxr-xr-xtest/integration/test-apt-cache-showsrc6
-rwxr-xr-xtest/integration/test-hashsum-verification2
44 files changed, 153 insertions, 141 deletions
diff --git a/README.md b/README.md
index 9c4bfe8b5..360229447 100644
--- a/README.md
+++ b/README.md
@@ -86,7 +86,7 @@ as well as the manual pages and other documentation shipped with APT.
Software tools like APT, which are used by thousands of users every
day, have a steady flow of incoming bug reports. Not all of them are really
bugs in APT: It can be packaging bugs, like failing maintainer scripts, that a
-user reports against apt, because apt was the command he executed that lead
+user reports against apt, because apt was the command they executed that lead
to this failure; or various wishlist items for new features. Given enough time
the occasional duplicate enters the system as well.
Our bug tracker is therefore full with open bug reports which are waiting for you! ;)
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/acquire.cc b/apt-pkg/acquire.cc
index 8bb72d549..6cf8b4c83 100644
--- a/apt-pkg/acquire.cc
+++ b/apt-pkg/acquire.cc
@@ -385,75 +385,97 @@ void pkgAcquire::Dequeue(Item *Itm)
return http://foo.org or http */
string pkgAcquire::QueueName(string Uri,MethodConfig const *&Config)
{
+ constexpr int DEFAULT_HOST_LIMIT = 10;
URI U(Uri);
-
- Config = GetConfig(U.Access);
- if (Config == 0)
- return string();
-
- /* Single-Instance methods get exactly one queue per URI. This is
- also used for the Access queue method */
- if (Config->SingleInstance == true || QueueMode == QueueAccess)
+ // Access mode forces all methods to be Single-Instance
+ if (QueueMode == QueueAccess)
return U.Access;
- int Limit = 10;
- string AccessSchema = U.Access + ':';
- string FullQueueName;
+ Config = GetConfig(U.Access);
+ if (Config == nullptr)
+ return {};
+
+ // Single-Instance methods get exactly one queue per URI
+ if (Config->SingleInstance == true)
+ return U.Access;
+ // Host-less methods like rred, store, …
if (U.Host.empty())
{
- long existing = 0;
+ int existing = 0;
// check how many queues exist already and reuse empty ones
+ auto const AccessSchema = U.Access + ':';
for (Queue const *I = Queues; I != 0; I = I->Next)
- if (I->Name.compare(0, AccessSchema.length(), AccessSchema) == 0)
+ if (APT::String::Startswith(I->Name, AccessSchema))
{
if (I->Items == nullptr)
return I->Name;
++existing;
}
+ int const Limit = _config->FindI("Acquire::QueueHost::Limit",
#ifdef _SC_NPROCESSORS_ONLN
- long cpuCount = sysconf(_SC_NPROCESSORS_ONLN) * 2;
+ sysconf(_SC_NPROCESSORS_ONLN) * 2
#else
- long cpuCount = Limit;
+ DEFAULT_HOST_LIMIT
#endif
- Limit = _config->FindI("Acquire::QueueHost::Limit", cpuCount);
+ );
+ // create a new worker if we don't have too many yet
if (Limit <= 0 || existing < Limit)
- strprintf(FullQueueName, "%s%ld", AccessSchema.c_str(), existing);
- else
- {
- long const randomQueue = random() % Limit;
- strprintf(FullQueueName, "%s%ld", AccessSchema.c_str(), randomQueue);
- }
+ return AccessSchema + std::to_string(existing);
+
+ // find the worker with the least to do
+ // we already established that there are no empty and we can't spawn new
+ Queue const *selected = nullptr;
+ auto selected_backlog = std::numeric_limits<decltype(HashStringList().FileSize())>::max();
+ for (Queue const *Q = Queues; Q != nullptr; Q = Q->Next)
+ if (APT::String::Startswith(Q->Name, AccessSchema))
+ {
+ decltype(selected_backlog) current_backlog = 0;
+ for (auto const *I = Q->Items; I != nullptr; I = I->Next)
+ {
+ auto const hashes = I->Owner->GetExpectedHashes();
+ if (not hashes.empty())
+ current_backlog += hashes.FileSize();
+ else
+ current_backlog += I->Owner->FileSize;
+ }
+ if (current_backlog < selected_backlog)
+ {
+ selected = Q;
+ selected_backlog = current_backlog;
+ }
+ }
- if (Debug)
- clog << "Chose random queue " << FullQueueName << " for " << Uri << endl;
- } else
- {
- Limit = _config->FindI("Acquire::QueueHost::Limit", Limit);
- FullQueueName = AccessSchema + U.Host;
+ if (unlikely(selected == nullptr))
+ return AccessSchema + "0";
+ return selected->Name;
}
- unsigned int Instances = 0, SchemaLength = AccessSchema.length();
-
- Queue *I = Queues;
- for (; I != 0; I = I->Next) {
+ // most methods talking to remotes like http
+ else
+ {
+ auto const FullQueueName = U.Access + ':' + U.Host;
// if the queue already exists, re-use it
- if (I->Name == FullQueueName)
- return FullQueueName;
-
- if (I->Name.compare(0, SchemaLength, AccessSchema) == 0)
- Instances++;
- }
+ for (Queue const *Q = Queues; Q != nullptr; Q = Q->Next)
+ if (Q->Name == FullQueueName)
+ return FullQueueName;
- if (Debug) {
- clog << "Found " << Instances << " instances of " << U.Access << endl;
- }
+ int existing = 0;
+ // check how many queues exist already and reuse empty ones
+ auto const AccessSchema = U.Access + ':';
+ for (Queue const *Q = Queues; Q != nullptr; Q = Q->Next)
+ if (APT::String::Startswith(Q->Name, AccessSchema))
+ ++existing;
- if (Instances >= static_cast<decltype(Instances)>(Limit))
- return U.Access;
+ int const Limit = _config->FindI("Acquire::QueueHost::Limit", DEFAULT_HOST_LIMIT);
+ // if we have too many hosts open use a single generic for the rest
+ if (existing >= Limit)
+ return U.Access;
- return FullQueueName;
+ // we can still create new named queues
+ return FullQueueName;
+ }
}
/*}}}*/
// Acquire::GetConfig - Fetch the configuration information /*{{{*/
diff --git a/apt-pkg/algorithms.h b/apt-pkg/algorithms.h
index 21d79367b..789f304a9 100644
--- a/apt-pkg/algorithms.h
+++ b/apt-pkg/algorithms.h
@@ -16,7 +16,7 @@
pkgFixBroken corrects a broken system so that it is in a sane state.
- pkgAllUpgrade attempts to upgade as many packages as possible but
+ pkgAllUpgrade attempts to upgrade as many packages as possible but
without installing new packages.
The problem resolver class contains a number of complex algorithms
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/deblistparser.cc b/apt-pkg/deb/deblistparser.cc
index 832e3948d..75fc2d242 100644
--- a/apt-pkg/deb/deblistparser.cc
+++ b/apt-pkg/deb/deblistparser.cc
@@ -820,7 +820,8 @@ bool debListParser::ParseDepends(pkgCache::VerIterator &Ver,
Start = ParseDepends(Start, Stop, Package, Version, Op, false, false, false, myArch);
if (Start == 0)
- return _error->Error("Problem parsing dependency %zu",static_cast<size_t>(Key)); // TODO
+ return _error->Error("Problem parsing dependency %zu of %s:%s=%s", static_cast<size_t>(Key), // TODO
+ Ver.ParentPkg().Name(), Ver.Arch(), Ver.VerStr());
size_t const found = Package.rfind(':');
if (found == string::npos)
@@ -888,9 +889,9 @@ bool debListParser::ParseProvides(pkgCache::VerIterator &Ver)
Start = ParseDepends(Start,Stop,Package,Version,Op, false, false, false);
const size_t archfound = Package.rfind(':');
if (Start == 0)
- return _error->Error("Problem parsing Provides line");
+ return _error->Error("Problem parsing Provides line of %s:%s=%s", Ver.ParentPkg().Name(), Ver.Arch(), Ver.VerStr());
if (unlikely(Op != pkgCache::Dep::NoOp && Op != pkgCache::Dep::Equals)) {
- _error->Warning("Ignoring Provides line with non-equal DepCompareOp for package %s", Package.to_string().c_str());
+ _error->Warning("Ignoring non-equal Provides for package %s in %s:%s=%s", Package.to_string().c_str(), Ver.ParentPkg().Name(), Ver.Arch(), Ver.VerStr());
} else if (archfound != string::npos) {
StringView spzArch = Package.substr(archfound + 1);
if (spzArch != "any")
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;
}
diff --git a/apt-pkg/edsp/edspindexfile.cc b/apt-pkg/edsp/edspindexfile.cc
index 1a8af89f0..faade6e0a 100644
--- a/apt-pkg/edsp/edspindexfile.cc
+++ b/apt-pkg/edsp/edspindexfile.cc
@@ -96,7 +96,7 @@ class APT_HIDDEN edspIFType: public pkgIndexFile::Type
public:
virtual pkgRecords::Parser *CreatePkgParser(pkgCache::PkgFileIterator const &) const APT_OVERRIDE
{
- // we don't have a record parser for this type as the file is not presistent
+ // we don't have a record parser for this type as the file is not persistent
return NULL;
};
edspIFType() {Label = "EDSP scenario file";};
@@ -112,7 +112,7 @@ class APT_HIDDEN eippIFType: public pkgIndexFile::Type
public:
virtual pkgRecords::Parser *CreatePkgParser(pkgCache::PkgFileIterator const &) const APT_OVERRIDE
{
- // we don't have a record parser for this type as the file is not presistent
+ // we don't have a record parser for this type as the file is not persistent
return NULL;
};
eippIFType() {Label = "EIPP scenario file";};
diff --git a/apt-pkg/packagemanager.cc b/apt-pkg/packagemanager.cc
index 21905c7b6..e58589d73 100644
--- a/apt-pkg/packagemanager.cc
+++ b/apt-pkg/packagemanager.cc
@@ -918,7 +918,7 @@ bool pkgPackageManager::SmartUnPack(PkgIterator Pkg, bool const Immediate, int c
else
{
if (Debug)
- clog << OutputInDepth(Depth) << "So temprorary remove/deconfigure " << ConflictPkg.FullName() << " to satisfy " << APT::PrettyDep(&Cache, End) << endl;
+ clog << OutputInDepth(Depth) << "So temporary remove/deconfigure " << ConflictPkg.FullName() << " to satisfy " << APT::PrettyDep(&Cache, End) << endl;
if (EarlyRemove(ConflictPkg, &End) == false)
return _error->Error("Internal Error, Could not early remove %s (%d)",ConflictPkg.FullName().c_str(), 2);
}
diff --git a/apt-pkg/pkgcache.cc b/apt-pkg/pkgcache.cc
index cbb67820a..ba9a39f13 100644
--- a/apt-pkg/pkgcache.cc
+++ b/apt-pkg/pkgcache.cc
@@ -128,7 +128,7 @@ bool pkgCache::Header::CheckSizes(Header &Against) const
pkgCache::pkgCache(MMap *Map, bool DoMap) : Map(*Map), VS(nullptr), d(NULL)
{
// call getArchitectures() with cached=false to ensure that the
- // architectures cache is re-evaulated. this is needed in cases
+ // architectures cache is re-evaluated. this is needed in cases
// when the APT::Architecture field changes between two cache creations
MultiArchEnabled = APT::Configuration::getArchitectures(false).size() > 1;
if (DoMap == true)
diff --git a/apt-pkg/pkgsystem.h b/apt-pkg/pkgsystem.h
index 1be2668ff..051b11ac2 100644
--- a/apt-pkg/pkgsystem.h
+++ b/apt-pkg/pkgsystem.h
@@ -83,7 +83,7 @@ class pkgSystem
virtual bool FindIndex(pkgCache::PkgFileIterator File,
pkgIndexFile *&Found) const = 0;
- /* Evauluate how 'right' we are for this system based on the filesystem
+ /* Evaluate how 'right' we are for this system based on the filesystem
etc.. */
virtual signed Score(Configuration const &/*Cnf*/) {
return 0;
diff --git a/apt-pkg/sourcelist.cc b/apt-pkg/sourcelist.cc
index eef4d8a7f..cd7dbce9c 100644
--- a/apt-pkg/sourcelist.cc
+++ b/apt-pkg/sourcelist.cc
@@ -215,7 +215,7 @@ bool pkgSourceList::Type::ParseLine(vector<metaIndex *> &List,
// get one option, e.g. option1=value1
string option;
if (ParseQuoteWord(Buffer,option) == false)
- return _error->Error(_("Malformed entry %u in %s file %s (%s)"), CurLine, "list", File.c_str(), "[option] unparseable");
+ return _error->Error(_("Malformed entry %u in %s file %s (%s)"), CurLine, "list", File.c_str(), "[option] unparsable");
if (option.length() < 3)
return _error->Error(_("Malformed entry %u in %s file %s (%s)"), CurLine, "list", File.c_str(), "[option] too short");
diff --git a/apt-pkg/sourcelist.h b/apt-pkg/sourcelist.h
index efbf4bfbc..91dc03dcf 100644
--- a/apt-pkg/sourcelist.h
+++ b/apt-pkg/sourcelist.h
@@ -108,7 +108,7 @@ class pkgSourceList
/** \brief add file for parsing, but not to the cache
*
- * pkgIndexFiles origining from pkgSourcesList are included in
+ * pkgIndexFiles originating from pkgSourcesList are included in
* srcpkgcache, the status files added via #AddStatusFiles are
* included in pkgcache, but these files here are not included in
* any cache to have the possibility of having a file included just
diff --git a/apt-private/private-cacheset.cc b/apt-private/private-cacheset.cc
index 98b842adb..2a5afac7b 100644
--- a/apt-private/private-cacheset.cc
+++ b/apt-private/private-cacheset.cc
@@ -254,11 +254,12 @@ bool CacheSetHelperAPTGet::showVirtualPackageErrors(pkgCacheFile &Cache)
pkgCache::PrvIterator I = Pkg.ProvidesList();
unsigned short provider = 0;
for (; I.end() == false; ++I) {
- pkgCache::PkgIterator Pkg = I.OwnerPkg();
+ pkgCache::PkgIterator const OPkg = I.OwnerPkg();
- if (Cache[Pkg].CandidateVerIter(Cache) == I.OwnerVer()) {
- c1out << " " << Pkg.FullName(true) << " " << I.OwnerVer().VerStr();
- if (Cache[Pkg].Install() == true && Cache[Pkg].NewInstall() == false)
+ if (Cache[OPkg].CandidateVerIter(Cache) == I.OwnerVer())
+ {
+ c1out << " " << OPkg.FullName(true) << " " << I.OwnerVer().VerStr();
+ if (Cache[OPkg].Install() == true && Cache[OPkg].NewInstall() == false)
c1out << _(" [Installed]");
c1out << std::endl;
++provider;
diff --git a/apt-private/private-cmndline.cc b/apt-private/private-cmndline.cc
index 3f43d6eb1..5944e530d 100644
--- a/apt-private/private-cmndline.cc
+++ b/apt-private/private-cmndline.cc
@@ -16,6 +16,7 @@
#include <stdlib.h>
#include <string.h>
+#include <algorithm>
#include <iomanip>
#include <vector>
@@ -508,15 +509,15 @@ std::vector<CommandLine::Dispatch> ParseCommandLine(CommandLine &CmdL, APT_CMD c
if (likely(argc != 0 && argv[0] != NULL))
BinarySpecificConfiguration(argv[0]);
- std::vector<aptDispatchWithHelp> const CmdsWithHelp = GetCommands();
std::vector<CommandLine::Dispatch> Cmds;
+ std::vector<aptDispatchWithHelp> const CmdsWithHelp = GetCommands();
if (CmdsWithHelp.empty() == false)
{
CommandLine::Dispatch const help = { "help", [](CommandLine &){return false;} };
Cmds.push_back(std::move(help));
}
- for (auto const& cmd : CmdsWithHelp)
- Cmds.push_back({cmd.Match, cmd.Handler});
+ std::transform(CmdsWithHelp.begin(), CmdsWithHelp.end(), std::back_inserter(Cmds),
+ [](auto &&cmd) { return CommandLine::Dispatch{cmd.Match, cmd.Handler}; });
char const * CmdCalled = nullptr;
if (Cmds.empty() == false && Cmds[0].Handler != nullptr)
diff --git a/apt-private/private-install.cc b/apt-private/private-install.cc
index a5a88c99d..af6697d7f 100644
--- a/apt-private/private-install.cc
+++ b/apt-private/private-install.cc
@@ -727,8 +727,7 @@ bool AddVolatileSourceFile(pkgSourceList *const SL, PseudoPkg &&pkg, std::vector
return false;
std::vector<std::string> files;
SL->AddVolatileFile(pkg.name, &files);
- for (auto &&f: files)
- VolatileCmdL.emplace_back(std::move(f), pkg.arch, pkg.release, pkg.index);
+ std::transform(files.begin(), files.end(), std::back_inserter(VolatileCmdL), [&](auto &&f) { return PseudoPkg{std::move(f), pkg.arch, pkg.release, pkg.index}; });
return true;
}
@@ -740,8 +739,7 @@ bool AddVolatileBinaryFile(pkgSourceList *const SL, PseudoPkg &&pkg, std::vector
return false;
std::vector<std::string> files;
SL->AddVolatileFile(pkg.name, &files);
- for (auto &&f: files)
- VolatileCmdL.emplace_back(std::move(f), pkg.arch, pkg.release, pkg.index);
+ std::transform(files.begin(), files.end(), std::back_inserter(VolatileCmdL), [&](auto &&f) { return PseudoPkg{std::move(f), pkg.arch, pkg.release, pkg.index}; });
return true;
}
/*}}}*/
diff --git a/apt-private/private-json-hooks.cc b/apt-private/private-json-hooks.cc
index 480c4f732..0b765a4ed 100644
--- a/apt-private/private-json-hooks.cc
+++ b/apt-private/private-json-hooks.cc
@@ -81,7 +81,7 @@ class APT_HIDDEN JsonWriter
}
public:
- explicit JsonWriter(std::ostream &os) : os(os) { old_locale = os.imbue(std::locale::classic()); }
+ explicit JsonWriter(std::ostream &os) : os(os), old_locale{os.imbue(std::locale::classic())} {}
~JsonWriter() { os.imbue(old_locale); }
JsonWriter &beginArray()
{
diff --git a/apt-private/private-show.cc b/apt-private/private-show.cc
index b69008ec9..9ebbe6ac0 100644
--- a/apt-private/private-show.cc
+++ b/apt-private/private-show.cc
@@ -89,7 +89,7 @@ static APT_PURE char const *skipColonSpaces(char const *Buffer, size_t const Len
++Buffer;
for (; isspace(*Buffer) != 0 && Length - (Buffer - Start) > 0; ++Buffer)
;
- if (Length - (Buffer - Start) <= 0)
+ if (Length < static_cast<size_t>(Buffer - Start))
return nullptr;
return Buffer;
}
diff --git a/apt-private/private-source.cc b/apt-private/private-source.cc
index bbb14b1d8..3964ca48e 100644
--- a/apt-private/private-source.cc
+++ b/apt-private/private-source.cc
@@ -340,10 +340,10 @@ bool DoSource(CommandLine &CmdL)
// Load the requestd sources into the fetcher
aptAcquireWithTextStatus Fetcher;
std::vector<std::string> UntrustedList;
- for (const char **I = CmdL.FileList + 1; *I != 0; I++)
+ for (const char **cmdl = CmdL.FileList + 1; *cmdl != 0; ++cmdl)
{
std::string Src;
- pkgSrcRecords::Parser *Last = FindSrc(*I,SrcRecs,Src,Cache);
+ pkgSrcRecords::Parser *Last = FindSrc(*cmdl, SrcRecs, Src, Cache);
if (Last == 0) {
return _error->Error(_("Unable to find a source package for %s"),Src.c_str());
}
diff --git a/cmdline/apt-cache.cc b/cmdline/apt-cache.cc
index 499c9edc9..acf00bdda 100644
--- a/cmdline/apt-cache.cc
+++ b/cmdline/apt-cache.cc
@@ -136,12 +136,12 @@ static bool DumpPackage(CommandLine &CmdL)
/* */
static map_pointer_t PackageNext(pkgCache::Package const * const P) { return P->NextPackage; }
static map_pointer_t GroupNext(pkgCache::Group const * const G) { return G->Next; }
-template<class T>
-static void ShowHashTableStats(std::string Type,
- T *StartP,
- map_pointer_t *Hashtable,
- unsigned long Size,
- map_pointer_t(*Next)(T const * const))
+template <class T>
+static void ShowHashTableStats(char const *const Type,
+ T *StartP,
+ map_pointer_t *Hashtable,
+ unsigned long Size,
+ map_pointer_t (*Next)(T const *const))
{
// hashtable stats for the HashTable
unsigned long NumBuckets = Size;
@@ -201,8 +201,7 @@ static bool Stats(CommandLine &CmdL)
int NVirt = 0;
int DVirt = 0;
int Missing = 0;
- pkgCache::PkgIterator I = Cache->PkgBegin();
- for (;I.end() != true; ++I)
+ for (pkgCache::PkgIterator I = Cache->PkgBegin(); I.end() != true; ++I)
{
if (I->VersionList != 0 && I->ProvidesList == 0)
{
diff --git a/cmdline/apt-extracttemplates.cc b/cmdline/apt-extracttemplates.cc
index bc8a27dbe..01b5dbb11 100644
--- a/cmdline/apt-extracttemplates.cc
+++ b/cmdline/apt-extracttemplates.cc
@@ -326,7 +326,7 @@ static std::vector<aptDispatchWithHelp> GetCommands() /*{{{*/
int main(int argc, const char **argv) /*{{{*/
{
CommandLine CmdL;
- auto const Cmds = ParseCommandLine(CmdL, APT_CMD::APT_EXTRACTTEMPLATES, &_config, &_system, argc, argv, &ShowHelp, &GetCommands);
+ ParseCommandLine(CmdL, APT_CMD::APT_EXTRACTTEMPLATES, &_config, &_system, argc, argv, &ShowHelp, &GetCommands);
Go(CmdL);
diff --git a/cmdline/apt-get.cc b/cmdline/apt-get.cc
index 7ef07fbf0..5d81c08a4 100644
--- a/cmdline/apt-get.cc
+++ b/cmdline/apt-get.cc
@@ -148,8 +148,7 @@ static bool DoDSelectUpgrade(CommandLine &)
pkgDepCache::ActionGroup group(Cache);
// Install everything with the install flag set
- pkgCache::PkgIterator I = Cache->PkgBegin();
- for (;I.end() != true; ++I)
+ for (pkgCache::PkgIterator I = Cache->PkgBegin(); I.end() != true; ++I)
{
/* Install the package only if it is a new install, the autoupgrader
will deal with the rest */
@@ -159,7 +158,7 @@ static bool DoDSelectUpgrade(CommandLine &)
/* Now install their deps too, if we do this above then order of
the status file is significant for | groups */
- for (I = Cache->PkgBegin();I.end() != true; ++I)
+ for (pkgCache::PkgIterator I = Cache->PkgBegin(); I.end() != true; ++I)
{
/* Install the package only if it is a new install, the autoupgrader
will deal with the rest */
@@ -168,7 +167,7 @@ static bool DoDSelectUpgrade(CommandLine &)
}
// Apply erasures now, they override everything else.
- for (I = Cache->PkgBegin();I.end() != true; ++I)
+ for (pkgCache::PkgIterator I = Cache->PkgBegin(); I.end() != true; ++I)
{
// Remove packages
if (I->SelectedState == pkgCache::State::DeInstall ||
diff --git a/cmdline/apt-helper.cc b/cmdline/apt-helper.cc
index 119cbc4c8..97a4342f5 100644
--- a/cmdline/apt-helper.cc
+++ b/cmdline/apt-helper.cc
@@ -67,7 +67,7 @@ static bool DoDownloadFile(CommandLine &CmdL) /*{{{*/
fileind += 2;
- // An empty string counts as a hash for compatability reasons
+ // An empty string counts as a hash for compatibility reasons
if (CmdL.FileSize() > fileind + 1 && *CmdL.FileList[fileind + 1] == '\0')
fileind++;
@@ -133,7 +133,7 @@ static bool DoSrvLookup(CommandLine &CmdL) /*{{{*/
return true;
}
/*}}}*/
-static const APT::Configuration::Compressor *FindCompressor(std::vector<APT::Configuration::Compressor> const & compressors, std::string name) /*{{{*/
+static const APT::Configuration::Compressor *FindCompressor(std::vector<APT::Configuration::Compressor> const &compressors, std::string const &name) /*{{{*/
{
APT::Configuration::Compressor const * compressor = NULL;
for (auto const & c : compressors)
diff --git a/cmdline/apt-internal-solver.cc b/cmdline/apt-internal-solver.cc
index 5c9ca5a35..d22eb75b4 100644
--- a/cmdline/apt-internal-solver.cc
+++ b/cmdline/apt-internal-solver.cc
@@ -67,7 +67,6 @@ static bool WriteSolution(pkgDepCache &Cache, FileFd &output) /*{{{*/
bool Okay = output.Failed() == false;
for (pkgCache::PkgIterator Pkg = Cache.PkgBegin(); Pkg.end() == false && likely(Okay); ++Pkg)
{
- std::string action;
if (Cache[Pkg].Delete() == true)
Okay &= EDSP::WriteSolutionStanza(output, "Remove", Pkg.CurrentVer());
else if (Cache[Pkg].NewInstall() == true || Cache[Pkg].Upgrade() == true)
diff --git a/debian/changelog b/debian/changelog
index a098eeb88..378f6bcb0 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -25,7 +25,7 @@ apt (1.9.0) experimental; urgency=medium
* Use debDebFile to get control file instead of dpkg-deb
* prepare-release: Add bump-abi command
* Change soname to libapt-pkg.so.5.90
- * CMake: Enforce "override" use on overriden methods
+ * CMake: Enforce "override" use on overridden methods
* debmetaindex: Use isspace_ascii() variant to normalize Signed-By
* README.md: Quote -j <count> as code with backticks
* apt-mark: Add hidden showheld alias for showhold
@@ -3518,7 +3518,7 @@ apt (0.9.14.3~exp4) experimental; urgency=medium
- add Description tag for deb822 sources
- add support for Enabled: no in deb822 sources.list
- add support for multiple URIs in deb822 style sources.list
- - add support for multipl types in one line
+ - add support for multiple types in one line
* add integration test for apt search and apt show
* do not ignore ioctl(TIOCSCTTY) errors
diff --git a/debian/libapt-pkg-doc.doc-base.dpkg-tech b/debian/libapt-pkg-doc.doc-base.dpkg-tech
index 055e8e674..823a7cb02 100644
--- a/debian/libapt-pkg-doc.doc-base.dpkg-tech
+++ b/debian/libapt-pkg-doc.doc-base.dpkg-tech
@@ -1,5 +1,5 @@
Document: libapt-pkg-doc-dpkg-tech
-Title: APT's interpetation of DPkg Technical Specification
+Title: APT's interpretation of DPkg Technical Specification
Author: Jason Gunthorpe
Abstract: The DPkg Technical Manual gives an overview of dpkg's external
functions(as APT sees them) and describes how it views the world.
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<APT::Configuration::Compressor>::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;
}
diff --git a/methods/aptmethod.h b/methods/aptmethod.h
index 02ef04cf9..5d792ceb7 100644
--- a/methods/aptmethod.h
+++ b/methods/aptmethod.h
@@ -502,10 +502,10 @@ class aptAuthConfMethod : public aptMethod
auto const netrcparts = _config->FindDir("Dir::Etc::netrcparts");
if (netrcparts.empty() == false)
{
- for (auto const &netrc : GetListOfFilesInDir(netrcparts, "conf", true, true))
+ for (auto &&netrcpart : GetListOfFilesInDir(netrcparts, "conf", true, true))
{
authconfs.emplace_back(new FileFd());
- authconfs.back()->Open(netrc, FileFd::ReadOnly);
+ authconfs.back()->Open(netrcpart, FileFd::ReadOnly);
}
}
_error->RevertToStack();
diff --git a/methods/basehttp.cc b/methods/basehttp.cc
index fd5934b40..e659da255 100644
--- a/methods/basehttp.cc
+++ b/methods/basehttp.cc
@@ -349,7 +349,6 @@ BaseHttpMethod::DealWithHeaders(FetchResult &Res, RequestState &Req)
tmpURI.Access = base + '+' + tmpURI.Access;
if (tmpURI.Access == Binary)
{
- std::string tmpAccess = Uri.Access;
std::swap(tmpURI.Access, Uri.Access);
NextURI = tmpURI;
std::swap(tmpURI.Access, Uri.Access);
diff --git a/methods/cdrom.cc b/methods/cdrom.cc
index d024d18d1..4ae64c8d3 100644
--- a/methods/cdrom.cc
+++ b/methods/cdrom.cc
@@ -43,7 +43,7 @@ class CDROMMethod : public aptMethod
bool IsCorrectCD(URI want, string MountPath, string& NewID);
bool AutoDetectAndMount(const URI, string &NewID);
virtual bool Fetch(FetchItem *Itm) APT_OVERRIDE;
- string GetID(string Name);
+ std::string GetID(std::string const &Name);
virtual void Exit() APT_OVERRIDE;
virtual bool Configuration(std::string Message) APT_OVERRIDE;
@@ -77,7 +77,7 @@ void CDROMMethod::Exit()
// CDROMMethod::GetID - Search the database for a matching string /*{{{*/
// ---------------------------------------------------------------------
/* */
-string CDROMMethod::GetID(string Name)
+std::string CDROMMethod::GetID(std::string const &Name)
{
// Search for an ID
const Configuration::Item *Top = Database.Tree("CD");
diff --git a/methods/connect.cc b/methods/connect.cc
index 61968efe0..57dfb6299 100644
--- a/methods/connect.cc
+++ b/methods/connect.cc
@@ -893,7 +893,7 @@ struct TlsFd : public MethodFd
}
};
-ResultState UnwrapTLS(std::string Host, std::unique_ptr<MethodFd> &Fd,
+ResultState UnwrapTLS(std::string const &Host, std::unique_ptr<MethodFd> &Fd,
unsigned long Timeout, aptMethod *Owner)
{
if (_config->FindB("Acquire::AllowTLS", true) == false)
diff --git a/methods/connect.h b/methods/connect.h
index 86f6d529c..bd6507761 100644
--- a/methods/connect.h
+++ b/methods/connect.h
@@ -42,7 +42,7 @@ ResultState Connect(std::string To, int Port, const char *Service, int DefPort,
std::unique_ptr<MethodFd> &Fd, unsigned long TimeOut, aptMethod *Owner);
ResultState UnwrapSocks(std::string To, int Port, URI Proxy, std::unique_ptr<MethodFd> &Fd, unsigned long Timeout, aptMethod *Owner);
-ResultState UnwrapTLS(std::string To, std::unique_ptr<MethodFd> &Fd, unsigned long Timeout, aptMethod *Owner);
+ResultState UnwrapTLS(std::string const &To, std::unique_ptr<MethodFd> &Fd, unsigned long Timeout, aptMethod *Owner);
void RotateDNS();
diff --git a/methods/file.cc b/methods/file.cc
index 9f4e713b8..80e47f1ad 100644
--- a/methods/file.cc
+++ b/methods/file.cc
@@ -57,7 +57,6 @@ bool FileMethod::Fetch(FetchItem *Itm)
{
if (Itm->LastModified == Buf.st_mtime && Itm->LastModified != 0)
{
- HashStringList const hsl = Itm->ExpectedHashes;
if (Itm->ExpectedHashes.VerifyFile(File))
{
Res.Filename = Itm->DestFile;
diff --git a/methods/http.cc b/methods/http.cc
index a4d187189..bd866d321 100644
--- a/methods/http.cc
+++ b/methods/http.cc
@@ -349,7 +349,7 @@ static ResultState UnwrapHTTPConnect(std::string Host, int Port, URI Proxy, std:
Out.Read(Req.str());
// Writing from proxy
- while (Out.WriteSpace() > 0)
+ while (Out.WriteSpace())
{
if (WaitFd(Fd->Fd(), true, Timeout) == false)
{
@@ -363,7 +363,7 @@ static ResultState UnwrapHTTPConnect(std::string Host, int Port, URI Proxy, std:
}
}
- while (In.ReadSpace() > 0)
+ while (In.ReadSpace())
{
if (WaitFd(Fd->Fd(), false, Timeout) == false)
{
@@ -389,7 +389,7 @@ static ResultState UnwrapHTTPConnect(std::string Host, int Port, URI Proxy, std:
return ResultState::TRANSIENT_ERROR;
}
- if (In.WriteSpace() > 0)
+ if (In.WriteSpace())
{
// Maybe there is actual data already read, if so we need to buffer it
std::unique_ptr<HttpConnectFd> NewFd(new HttpConnectFd());
@@ -974,9 +974,10 @@ void HttpMethod::SendReq(FetchItem *Itm)
Req << "User-Agent: " << ConfigFind("User-Agent",
"Debian APT-HTTP/1.3 (" PACKAGE_VERSION ")") << "\r\n";
- auto const referer = ConfigFind("Referer", "");
- if (referer.empty() == false)
- Req << "Referer: " << referer << "\r\n";
+ // the famously typoed HTTP header field
+ auto const referrer = ConfigFind("Referer", "");
+ if (referrer.empty() == false)
+ Req << "Referer: " << referrer << "\r\n";
Req << "\r\n";
diff --git a/methods/mirror.cc b/methods/mirror.cc
index dcf4cbd13..3e382e497 100644
--- a/methods/mirror.cc
+++ b/methods/mirror.cc
@@ -56,7 +56,7 @@ class MirrorMethod : public aptMethod /*{{{*/
unsigned long priority = std::numeric_limits<decltype(priority)>::max();
decltype(genrng)::result_type seed = 0;
std::unordered_map<std::string, std::vector<std::string>> tags;
- MirrorInfo(std::string const &u, std::vector<std::string> &&ptags = {}) : uri(u)
+ explicit MirrorInfo(std::string const &u, std::vector<std::string> &&ptags = {}) : uri(u)
{
for (auto &&tag : ptags)
{
@@ -222,8 +222,7 @@ bool MirrorMethod::MirrorListFileRecieved(MirrorListInfo &info, FetchItem *const
[&access](char const *const a) { return APT::String::Endswith(access, std::string("+") + a); }) ||
access == "mirror")
{
- for (auto const &a : disallowLocal)
- limitAccess.emplace_back(a);
+ std::copy(std::begin(disallowLocal), std::end(disallowLocal), std::back_inserter(limitAccess));
}
std::string line;
while (mirrorlist.ReadLine(line))
@@ -323,12 +322,9 @@ std::string MirrorMethod::GetMirrorFileURI(std::string const &Message, FetchItem
if (plus < colon)
{
// started as tor+mirror+http we want to get the file via tor+http
- auto access = uristr.substr(0, colon);
- std::string prefixAccess;
+ auto const access = uristr.substr(0, colon);
if (APT::String::Startswith(access, "mirror") == false)
{
- prefixAccess = uristr.substr(0, plus);
- access.erase(0, plus + 1);
uristr.erase(plus, strlen("mirror") + 1);
return uristr;
}
diff --git a/methods/rfc2553emu.cc b/methods/rfc2553emu.cc
index 72b3fc42b..41aa7470e 100644
--- a/methods/rfc2553emu.cc
+++ b/methods/rfc2553emu.cc
@@ -202,7 +202,7 @@ int getnameinfo(const struct sockaddr *sa, socklen_t salen,
}
}
- // Resolve as a plain numberic
+ // Resolve as a plain numeric
if ((flags & NI_NUMERICHOST) == NI_NUMERICHOST)
{
strncpy(host,inet_ntoa(sin->sin_addr),hostlen);
@@ -231,7 +231,7 @@ int getnameinfo(const struct sockaddr *sa, socklen_t salen,
}
}
- // Resolve as a plain numberic
+ // Resolve as a plain numeric
if ((flags & NI_NUMERICSERV) == NI_NUMERICSERV)
{
snprintf(serv,servlen,"%u",ntohs(sin->sin_port));
diff --git a/methods/rsh.cc b/methods/rsh.cc
index 5c08959c6..cc42b43e7 100644
--- a/methods/rsh.cc
+++ b/methods/rsh.cc
@@ -90,7 +90,7 @@ bool RSHConn::Open()
// RSHConn::Connect - Fire up rsh and connect /*{{{*/
// ---------------------------------------------------------------------
/* */
-bool RSHConn::Connect(std::string Host, unsigned int Port, std::string User)
+bool RSHConn::Connect(std::string const &Host, unsigned int Port, std::string const &User)
{
char *PortStr = NULL;
if (Port != 0)
@@ -169,7 +169,7 @@ bool RSHConn::Connect(std::string Host, unsigned int Port, std::string User)
return true;
}
-bool RSHConn::Connect(std::string Host, std::string User)
+bool RSHConn::Connect(std::string const &Host, std::string const &User)
{
return Connect(Host, 0, User);
}
diff --git a/methods/rsh.h b/methods/rsh.h
index acdcb64e3..7545d5815 100644
--- a/methods/rsh.h
+++ b/methods/rsh.h
@@ -35,8 +35,8 @@ class RSHConn
// Raw connection IO
bool WriteMsg(std::string &Text,bool Sync,const char *Fmt,...);
- bool Connect(std::string Host, std::string User);
- bool Connect(std::string Host, unsigned int Port, std::string User);
+ bool Connect(std::string const &Host, std::string const &User);
+ bool Connect(std::string const &Host, unsigned int Port, std::string const &User);
bool Comp(URI Other) const {return Other.Host == ServerName.Host && Other.Port == ServerName.Port;};
// Connection control
diff --git a/test/integration/test-apt-cache-showsrc b/test/integration/test-apt-cache-showsrc
index 88de077fc..d3f61d972 100755
--- a/test/integration/test-apt-cache-showsrc
+++ b/test/integration/test-apt-cache-showsrc
@@ -11,7 +11,7 @@ configarchitecture "i386"
insertsource 'unstable' 'foo' 'all' '1.0' '' 'foo-binary'
# and a similar one that builds a foo binary package
-insertsource 'unstable' 'unreleated' 'all' '1.0' '' 'foo'
+insertsource 'unstable' 'unrelated' 'all' '1.0' '' 'foo'
# just here to workaround the need for a authenticated package
insertpackage 'unstable' 'workaround' 'all' '1.0'
@@ -22,10 +22,10 @@ setupaptarchive
# and show all matches
aptcache showsrc foo > output.txt
testsuccess grep "Package: foo" output.txt
-testsuccess grep "Package: unreleated" output.txt
+testsuccess grep "Package: unrelated" output.txt
# by default apt-cache showsrc will look into "binary" and "source" names
# and show all matches
aptcache showsrc --only-source foo > output.txt
testsuccess grep "Package: foo" output.txt
-testfailure grep "Package: unreleated" output.txt
+testfailure grep "Package: unrelated" output.txt
diff --git a/test/integration/test-hashsum-verification b/test/integration/test-hashsum-verification
index a514b85e2..4060dfbba 100755
--- a/test/integration/test-hashsum-verification
+++ b/test/integration/test-hashsum-verification
@@ -22,7 +22,7 @@ prepare() {
cp "$1" aptarchive/Packages
find aptarchive -name 'Release' -delete
compressfile aptarchive/Packages
- # create Release file with incorret checksums
+ # create Release file with incorrect checksums
cat > aptarchive/Release <<EOF
Date: Fri, 05 Aug 2011 09:22:08 UTC
MD5Sum: