From af74a9e2d55d6a9532eb3fbb9b96c65b7ddc1e4d Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Tue, 30 Apr 2019 12:32:54 +0200 Subject: apt-pkg: URI: Add 'explicit' to single argument constructor This needs a fair amount of changes elsewhere in the code, hence this is separate from the previous commits. --- apt-pkg/acquire-worker.cc | 2 +- apt-pkg/acquire.cc | 2 +- apt-pkg/contrib/strutl.h | 4 ++-- methods/basehttp.cc | 14 +++++++------- methods/cdrom.cc | 2 +- methods/file.cc | 2 +- methods/ftp.cc | 6 +++--- methods/gpgv.cc | 2 +- methods/http.cc | 2 +- methods/rred.cc | 2 +- methods/rsh.cc | 2 +- methods/store.cc | 2 +- 12 files changed, 21 insertions(+), 21 deletions(-) diff --git a/apt-pkg/acquire-worker.cc b/apt-pkg/acquire-worker.cc index 8ebee5797..32fcde181 100644 --- a/apt-pkg/acquire-worker.cc +++ b/apt-pkg/acquire-worker.cc @@ -766,7 +766,7 @@ bool pkgAcquire::Worker::QueueItem(pkgAcquire::Queue::QItem *Item) Message += "URI: " + Item->URI; Message += "\nFilename: " + Item->Owner->DestFile; - URI URL = Item->URI; + URI URL(Item->URI); // FIXME: We should not hard code proxy protocols here. if (URL.Access == "http" || URL.Access == "https") { diff --git a/apt-pkg/acquire.cc b/apt-pkg/acquire.cc index 87bb13e39..8bb72d549 100644 --- a/apt-pkg/acquire.cc +++ b/apt-pkg/acquire.cc @@ -637,7 +637,7 @@ static void CheckDropPrivsMustBeDisabled(pkgAcquire const &Fetcher) // if its the source file (e.g. local sources) we might be lucky // by dropping the dropping only for some methods. - URI const source = (*I)->DescURI(); + URI const source((*I)->DescURI()); if (source.Access == "file" || source.Access == "copy") { std::string const conf = "Binary::" + source.Access + "::APT::Sandbox::User"; diff --git a/apt-pkg/contrib/strutl.h b/apt-pkg/contrib/strutl.h index c25ce8054..ae0aaedf9 100644 --- a/apt-pkg/contrib/strutl.h +++ b/apt-pkg/contrib/strutl.h @@ -218,8 +218,8 @@ class URI static std::string SiteOnly(const std::string &URI); static std::string ArchiveOnly(const std::string &URI); static std::string NoUserPassword(const std::string &URI); - - URI(std::string Path) {CopyFrom(Path);} + + explicit URI(std::string Path) { CopyFrom(Path); } URI() : Port(0) {} }; diff --git a/methods/basehttp.cc b/methods/basehttp.cc index f8dd7c020..04c194ad9 100644 --- a/methods/basehttp.cc +++ b/methods/basehttp.cc @@ -313,7 +313,7 @@ BaseHttpMethod::DealWithHeaders(FetchResult &Res, RequestState &Req) ; else if (Req.Location[0] == '/' && Queue->Uri.empty() == false) { - URI Uri = Queue->Uri; + URI Uri(Queue->Uri); if (Uri.Host.empty() == false) NextURI = URI::SiteOnly(Uri); else @@ -332,7 +332,7 @@ BaseHttpMethod::DealWithHeaders(FetchResult &Res, RequestState &Req) else { NextURI = DeQuoteString(Req.Location); - URI tmpURI = NextURI; + URI tmpURI(NextURI); if (tmpURI.Access.find('+') != std::string::npos) { _error->Error("Server tried to trick us into using a specific implementation: %s", tmpURI.Access.c_str()); @@ -340,7 +340,7 @@ BaseHttpMethod::DealWithHeaders(FetchResult &Res, RequestState &Req) return ERROR_WITH_CONTENT_PAGE; return ERROR_UNRECOVERABLE; } - URI Uri = Queue->Uri; + URI Uri(Queue->Uri); if (Binary.find('+') != std::string::npos) { auto base = Binary.substr(0, Binary.find('+')); @@ -493,7 +493,7 @@ bool BaseHttpMethod::Fetch(FetchItem *) do { // Make sure we stick with the same server - if (Server->Comp(QueueBack->Uri) == false) + if (Server->Comp(URI(QueueBack->Uri)) == false) break; bool const UsableHashes = QueueBack->ExpectedHashes.usable(); @@ -578,14 +578,14 @@ int BaseHttpMethod::Loop() continue; // Connect to the server - if (Server == 0 || Server->Comp(Queue->Uri) == false) + if (Server == 0 || Server->Comp(URI(Queue->Uri)) == false) { if (!Queue->Proxy().empty()) { - URI uri = Queue->Uri; + URI uri(Queue->Uri); _config->Set("Acquire::" + uri.Access + "::proxy::" + uri.Host, Queue->Proxy()); } - Server = CreateServerState(Queue->Uri); + Server = CreateServerState(URI(Queue->Uri)); setPostfixForMethodNames(::URI(Queue->Uri).Host.c_str()); AllowRedirect = ConfigFindB("AllowRedirect", true); PipelineDepth = ConfigFindI("Pipeline-Depth", 10); diff --git a/methods/cdrom.cc b/methods/cdrom.cc index 77270b09f..d024d18d1 100644 --- a/methods/cdrom.cc +++ b/methods/cdrom.cc @@ -175,7 +175,7 @@ bool CDROMMethod::Fetch(FetchItem *Itm) { FetchResult Res; - URI Get = Itm->Uri; + URI Get(Itm->Uri); string File = Get.Path; Debug = DebugEnabled(); diff --git a/methods/file.cc b/methods/file.cc index ff4301576..9f4e713b8 100644 --- a/methods/file.cc +++ b/methods/file.cc @@ -43,7 +43,7 @@ class FileMethod : public aptMethod /* */ bool FileMethod::Fetch(FetchItem *Itm) { - URI Get = Itm->Uri; + URI Get(Itm->Uri); std::string File = Get.Path; FetchResult Res; if (Get.Host.empty() == false) diff --git a/methods/ftp.cc b/methods/ftp.cc index 8213f1b50..98398341e 100644 --- a/methods/ftp.cc +++ b/methods/ftp.cc @@ -1037,7 +1037,7 @@ bool FtpMethod::Configuration(string Message) /* Fetch a single file, called by the base class.. */ bool FtpMethod::Fetch(FetchItem *Itm) { - URI Get = Itm->Uri; + URI Get(Itm->Uri); const char *File = Get.Path.c_str(); FetchResult Res; Res.Filename = Itm->DestFile; @@ -1166,8 +1166,8 @@ int main(int, const char *argv[]) proxy urls */ if (getenv("ftp_proxy") != 0) { - URI Proxy = string(getenv("ftp_proxy")); - + URI Proxy(string(getenv("ftp_proxy"))); + // Run the HTTP method if (Proxy.Access == "http") { diff --git a/methods/gpgv.cc b/methods/gpgv.cc index f66e3356f..04a4f6a83 100644 --- a/methods/gpgv.cc +++ b/methods/gpgv.cc @@ -419,7 +419,7 @@ string GPGVMethod::VerifyGetSigners(const char *file, const char *outfile, bool GPGVMethod::URIAcquire(std::string const &Message, FetchItem *Itm) { - URI const Get = Itm->Uri; + URI const Get(Itm->Uri); string const Path = Get.Host + Get.Path; // To account for relative paths SignersStorage Signers; diff --git a/methods/http.cc b/methods/http.cc index d75e9fe84..d3e16bba3 100644 --- a/methods/http.cc +++ b/methods/http.cc @@ -892,7 +892,7 @@ ResultState HttpServerState::Go(bool ToFile, RequestState &Req) /* This places the http request in the outbound buffer */ void HttpMethod::SendReq(FetchItem *Itm) { - URI Uri = Itm->Uri; + URI Uri(Itm->Uri); { auto const plus = Binary.find('+'); if (plus != std::string::npos) diff --git a/methods/rred.cc b/methods/rred.cc index d4cf1050d..949fa4773 100644 --- a/methods/rred.cc +++ b/methods/rred.cc @@ -574,7 +574,7 @@ class RredMethod : public aptMethod { protected: virtual bool URIAcquire(std::string const &Message, FetchItem *Itm) APT_OVERRIDE { Debug = DebugEnabled(); - URI Get = Itm->Uri; + URI Get(Itm->Uri); std::string Path = Get.Host + Get.Path; // rred:/path - no host FetchResult Res; diff --git a/methods/rsh.cc b/methods/rsh.cc index 0da18690b..5c08959c6 100644 --- a/methods/rsh.cc +++ b/methods/rsh.cc @@ -433,7 +433,7 @@ void RSHMethod::SigTerm(int) /* */ bool RSHMethod::Fetch(FetchItem *Itm) { - URI Get = Itm->Uri; + URI Get(Itm->Uri); const char *File = Get.Path.c_str(); FetchResult Res; Res.Filename = Itm->DestFile; diff --git a/methods/store.cc b/methods/store.cc index 7b9e202d9..1b0f07947 100644 --- a/methods/store.cc +++ b/methods/store.cc @@ -63,7 +63,7 @@ static bool OpenFileWithCompressorByName(FileFd &fileFd, std::string const &File /*}}}*/ bool StoreMethod::Fetch(FetchItem *Itm) /*{{{*/ { - URI Get = Itm->Uri; + URI Get(Itm->Uri); std::string Path = Get.Host + Get.Path; // To account for relative paths FetchResult Res; -- cgit v1.2.3