summaryrefslogtreecommitdiff
path: root/methods
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 /methods
parentcbe90ee516d7f747f981e423f164f99eb767240b (diff)
Apply various suggestions by cppcheck
Reported-By: cppcheck
Diffstat (limited to 'methods')
-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.cc6
-rw-r--r--methods/mirror.cc10
-rw-r--r--methods/rsh.cc4
-rw-r--r--methods/rsh.h4
10 files changed, 16 insertions, 22 deletions
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..0a29109fb 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());
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/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