From d331d3a0b5c497a46e2636f308234be66566c04c Mon Sep 17 00:00:00 2001 From: Vincent Ambo Date: Wed, 20 May 2020 04:33:07 +0100 Subject: refactor(3p/nix): Apply clang-tidy's modernize-* fixes This applies the modernization fixes listed here: https://clang.llvm.org/extra/clang-tidy/checks/list.html The 'modernize-use-trailing-return-type' fix was excluded due to my personal preference (more specifically, I think the 'auto' keyword is misleading in that position). --- third_party/nix/src/libstore/download.cc | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'third_party/nix/src/libstore/download.cc') diff --git a/third_party/nix/src/libstore/download.cc b/third_party/nix/src/libstore/download.cc index 4b90a3765724..eb7095ee146a 100644 --- a/third_party/nix/src/libstore/download.cc +++ b/third_party/nix/src/libstore/download.cc @@ -45,7 +45,7 @@ std::string resolveUri(const std::string& uri) { } struct CurlDownloader : public Downloader { - CURLM* curlm = 0; + CURLM* curlm = nullptr; std::random_device rd; std::mt19937 mt19937; @@ -57,7 +57,7 @@ struct CurlDownloader : public Downloader { bool done = false; // whether either the success or failure function has // been called Callback callback; - CURL* req = 0; + CURL* req = nullptr; bool active = false; // whether the handle has been added to the multi object std::string status; @@ -68,7 +68,7 @@ struct CurlDownloader : public Downloader { has been reached. */ std::chrono::steady_clock::time_point embargo; - struct curl_slist* requestHeaders = 0; + struct curl_slist* requestHeaders = nullptr; std::string encoding; @@ -523,7 +523,7 @@ struct CurlDownloader : public Downloader { workerThread = std::thread([&]() { workerThreadEntry(); }); } - ~CurlDownloader() { + ~CurlDownloader() override { stopWorkerThread(); workerThread.join(); @@ -909,7 +909,7 @@ CachedDownloadResult Downloader::downloadCached( if (ss.size() >= 3 && ss[0] == url) { time_t lastChecked; if (string2Int(ss[2], lastChecked) && - (uint64_t)lastChecked + request.ttl >= (uint64_t)time(0)) { + (uint64_t)lastChecked + request.ttl >= (uint64_t)time(nullptr)) { skip = true; result.effectiveUri = request.uri; result.etag = ss[1]; @@ -949,8 +949,8 @@ CachedDownloadResult Downloader::downloadCached( assert(!storePath.empty()); replaceSymlink(storePath, fileLink); - writeFile(dataFile, - url + "\n" + res.etag + "\n" + std::to_string(time(0)) + "\n"); + writeFile(dataFile, url + "\n" + res.etag + "\n" + + std::to_string(time(nullptr)) + "\n"); } catch (DownloadError& e) { if (storePath.empty()) { throw; -- cgit 1.4.1