about summary refs log tree commit diff
path: root/third_party/nix/src/libstore/download.cc
diff options
context:
space:
mode:
authorKane York <kanepyork@gmail.com>2020-08-02T00·17-0700
committerkanepyork <rikingcoding@gmail.com>2020-08-08T22·16+0000
commit1de00e6c42ee6beaaa490104888ef09be1d4a0d4 (patch)
treed98a37ae13525510e3b76feed56b3865360374d1 /third_party/nix/src/libstore/download.cc
parent053a1380023591e8eb3f514b4214226c95da207d (diff)
chore(3p/nix): apply google-readability-casting r/1619
Command run: jq <compile_commands.json -r 'map(.file)|.[]' | grep -v '/generated/' | parallel clang-tidy -p compile_commands.json -checks=-*,google-readability-casting --fix

Manual fixes applied in src/nix-env/nix-env.cc, src/libstore/store-api.cc

Change-Id: I406b4be9368c557ca59329bf6f7002704e955f8d
Reviewed-on: https://cl.tvl.fyi/c/depot/+/1557
Tested-by: BuildkiteCI
Reviewed-by: glittershark <grfn@gws.fyi>
Reviewed-by: tazjin <mail@tazj.in>
Diffstat (limited to 'third_party/nix/src/libstore/download.cc')
-rw-r--r--third_party/nix/src/libstore/download.cc25
1 files changed, 15 insertions, 10 deletions
diff --git a/third_party/nix/src/libstore/download.cc b/third_party/nix/src/libstore/download.cc
index cf64a6bad722..60a409d0dc4f 100644
--- a/third_party/nix/src/libstore/download.cc
+++ b/third_party/nix/src/libstore/download.cc
@@ -160,7 +160,7 @@ struct CurlDownloader : public Downloader {
           decompressionSink = makeDecompressionSink(encoding, finalSink);
         }
 
-        (*decompressionSink)((unsigned char*)contents, realSize);
+        (*decompressionSink)(static_cast<unsigned char*>(contents), realSize);
 
         return realSize;
       } catch (...) {
@@ -171,12 +171,13 @@ struct CurlDownloader : public Downloader {
 
     static size_t writeCallbackWrapper(void* contents, size_t size,
                                        size_t nmemb, void* userp) {
-      return ((DownloadItem*)userp)->writeCallback(contents, size, nmemb);
+      return (static_cast<DownloadItem*>(userp))
+          ->writeCallback(contents, size, nmemb);
     }
 
     size_t headerCallback(void* contents, size_t size, size_t nmemb) {
       size_t realSize = size * nmemb;
-      std::string line((char*)contents, realSize);
+      std::string line(static_cast<char*>(contents), realSize);
       DLOG(INFO) << "got header for '" << request.uri
                  << "': " << absl::StripAsciiWhitespace(line);
       if (line.compare(0, 5, "HTTP/") == 0) {  // new response starts
@@ -219,7 +220,8 @@ struct CurlDownloader : public Downloader {
 
     static size_t headerCallbackWrapper(void* contents, size_t size,
                                         size_t nmemb, void* userp) {
-      return ((DownloadItem*)userp)->headerCallback(contents, size, nmemb);
+      return (static_cast<DownloadItem*>(userp))
+          ->headerCallback(contents, size, nmemb);
     }
 
     static int debugCallback(CURL* handle, curl_infotype type, char* data,
@@ -246,7 +248,8 @@ struct CurlDownloader : public Downloader {
 
     static size_t readCallbackWrapper(char* buffer, size_t size, size_t nitems,
                                       void* userp) {
-      return ((DownloadItem*)userp)->readCallback(buffer, size, nitems);
+      return (static_cast<DownloadItem*>(userp))
+          ->readCallback(buffer, size, nitems);
     }
 
     void init() {
@@ -580,9 +583,10 @@ struct CurlDownloader : public Downloader {
           nextWakeup != std::chrono::steady_clock::time_point()
               ? std::max(
                     0,
-                    (int)std::chrono::duration_cast<std::chrono::milliseconds>(
-                        nextWakeup - std::chrono::steady_clock::now())
-                        .count())
+                    static_cast<int>(
+                        std::chrono::duration_cast<std::chrono::milliseconds>(
+                            nextWakeup - std::chrono::steady_clock::now())
+                            .count()))
               : maxSleepTimeMs;
       DLOG(INFO) << "download thread waiting for " << sleepTimeMs << " ms";
       mc = curl_multi_wait(curlm, extraFDs, 1, sleepTimeMs, &numfds);
@@ -846,7 +850,7 @@ void Downloader::download(DownloadRequest&& request, Sink& sink) {
        if it's blocked on a full buffer. We don't hold the state
        lock while doing this to prevent blocking the download
        thread if sink() takes a long time. */
-    sink((unsigned char*)chunk.data(), chunk.size());
+    sink(reinterpret_cast<unsigned char*>(chunk.data()), chunk.size());
   }
 }
 
@@ -902,7 +906,8 @@ CachedDownloadResult Downloader::downloadCached(
       if (ss.size() >= 3 && ss[0] == url) {
         time_t lastChecked;
         if (absl::SimpleAtoi(ss[2], &lastChecked) &&
-            (uint64_t)lastChecked + request.ttl >= (uint64_t)time(nullptr)) {
+            static_cast<uint64_t>(lastChecked) + request.ttl >=
+                static_cast<uint64_t>(time(nullptr))) {
           skip = true;
           result.effectiveUri = request.uri;
           result.etag = ss[1];