From 1de00e6c42ee6beaaa490104888ef09be1d4a0d4 Mon Sep 17 00:00:00 2001 From: Kane York Date: Sat, 1 Aug 2020 17:17:44 -0700 Subject: chore(3p/nix): apply google-readability-casting Command run: jq Reviewed-by: tazjin --- third_party/nix/src/libexpr/eval.cc | 7 ++--- third_party/nix/src/libexpr/nixexpr.cc | 6 ++--- third_party/nix/src/libexpr/primops.cc | 11 +++++--- third_party/nix/src/libexpr/primops/fetchGit.cc | 3 ++- .../nix/src/libexpr/primops/fetchMercurial.cc | 3 ++- third_party/nix/src/libmain/shared.cc | 2 +- third_party/nix/src/libmain/stack.cc | 4 +-- third_party/nix/src/libstore/binary-cache-store.cc | 11 ++++---- third_party/nix/src/libstore/build.cc | 31 ++++++++++++---------- third_party/nix/src/libstore/crypto.cc | 11 +++++--- third_party/nix/src/libstore/download.cc | 25 ++++++++++------- third_party/nix/src/libstore/gc.cc | 5 ++-- third_party/nix/src/libstore/legacy-ssh-store.cc | 2 +- third_party/nix/src/libstore/local-fs-store.cc | 2 +- third_party/nix/src/libstore/local-store.cc | 18 ++++++++----- third_party/nix/src/libstore/nar-accessor.cc | 2 +- .../nix/src/libstore/nar-info-disk-cache.cc | 10 ++++--- third_party/nix/src/libstore/remote-fs-accessor.cc | 6 +++-- third_party/nix/src/libstore/remote-store.cc | 2 +- third_party/nix/src/libstore/sqlite.cc | 2 +- third_party/nix/src/libstore/ssh.cc | 2 +- third_party/nix/src/libstore/store-api.cc | 6 ++--- third_party/nix/src/libutil/archive.cc | 6 ++--- third_party/nix/src/libutil/args.cc | 4 +-- third_party/nix/src/libutil/compression.cc | 8 +++--- third_party/nix/src/libutil/hash.cc | 7 ++--- third_party/nix/src/libutil/json.cc | 2 +- third_party/nix/src/libutil/serialise.cc | 16 +++++------ third_party/nix/src/libutil/util.cc | 15 ++++++----- third_party/nix/src/nix-build/nix-build.cc | 8 +++--- third_party/nix/src/nix-channel/nix-channel.cc | 2 +- third_party/nix/src/nix-daemon/nix-daemon-proto.cc | 2 +- third_party/nix/src/nix-env/nix-env.cc | 7 ++--- .../nix/src/nix-prefetch-url/nix-prefetch-url.cc | 4 +-- third_party/nix/src/nix-store/nix-store.cc | 16 ++++++----- third_party/nix/src/nix/main.cc | 3 ++- third_party/nix/src/nix/path-info.cc | 4 ++- third_party/nix/src/nix/repl.cc | 4 +-- third_party/nix/src/nix/search.cc | 4 +-- third_party/nix/src/nix/verify.cc | 3 ++- 40 files changed, 161 insertions(+), 125 deletions(-) (limited to 'third_party') diff --git a/third_party/nix/src/libexpr/eval.cc b/third_party/nix/src/libexpr/eval.cc index 3ecd990daa..4064f1594f 100644 --- a/third_party/nix/src/libexpr/eval.cc +++ b/third_party/nix/src/libexpr/eval.cc @@ -577,8 +577,8 @@ Value& mkString(Value& v, const std::string& s, const PathSet& context) { mkString(v, s.c_str()); if (!context.empty()) { size_t n = 0; - v.string.context = - (const char**)allocBytes((context.size() + 1) * sizeof(char*)); + v.string.context = static_cast( + allocBytes((context.size() + 1) * sizeof(char*))); for (auto& i : context) { v.string.context[n++] = dupString(i.c_str()); } @@ -1703,7 +1703,8 @@ void EvalState::printStats() { struct rusage buf; getrusage(RUSAGE_SELF, &buf); - float cpuTime = buf.ru_utime.tv_sec + ((float)buf.ru_utime.tv_usec / 1000000); + float cpuTime = buf.ru_utime.tv_sec + + (static_cast(buf.ru_utime.tv_usec) / 1000000); uint64_t bEnvs = nrEnvs * sizeof(Env) + nrValuesInEnvs * sizeof(Value*); uint64_t bLists = nrListElems * sizeof(Value*); diff --git a/third_party/nix/src/libexpr/nixexpr.cc b/third_party/nix/src/libexpr/nixexpr.cc index 94e7d335cf..24ce6ec3fc 100644 --- a/third_party/nix/src/libexpr/nixexpr.cc +++ b/third_party/nix/src/libexpr/nixexpr.cc @@ -18,7 +18,7 @@ std::ostream& operator<<(std::ostream& str, const Expr& e) { static void showString(std::ostream& str, const std::string& s) { str << '"'; - for (auto c : (std::string)s) { + for (auto c : std::string(s)) { if (c == '"' || c == '\\' || c == '$') { str << "\\" << c; } else if (c == '\n') { @@ -191,7 +191,7 @@ std::ostream& operator<<(std::ostream& str, const Pos& pos) { str << "undefined position"; } else { str << (format(ANSI_BOLD "%1%" ANSI_NORMAL ":%2%:%3%") % - (std::string)pos.file.value() % pos.line % pos.column) + std::string(pos.file.value()) % pos.line % pos.column) .str(); } return str; @@ -405,7 +405,7 @@ void ExprLambda::setName(Symbol& name) { this->name = name; } std::string ExprLambda::showNamePos() const { return (format("%1% at %2%") % - (name.has_value() ? "'" + (std::string)name.value() + "'" + (name.has_value() ? "'" + std::string(name.value()) + "'" : "anonymous function") % pos) .str(); diff --git a/third_party/nix/src/libexpr/primops.cc b/third_party/nix/src/libexpr/primops.cc index 04ccf7623b..0008b7b180 100644 --- a/third_party/nix/src/libexpr/primops.cc +++ b/third_party/nix/src/libexpr/primops.cc @@ -876,7 +876,7 @@ static void prim_readFile(EvalState& state, const Pos& pos, Value** args, } std::string s = readFile(state.checkSourcePath(state.toRealPath(path, context))); - if (s.find((char)0) != std::string::npos) { + if (s.find(static_cast(0)) != std::string::npos) { throw Error(format("the contents of the file '%1%' cannot be represented " "as a Nix string") % path); @@ -1421,7 +1421,7 @@ static void prim_isList(EvalState& state, const Pos& pos, Value** args, static void elemAt(EvalState& state, const Pos& pos, Value& list, int n, Value& v) { state.forceList(list, pos); - if (n < 0 || (unsigned int)n >= list.listSize()) { + if (n < 0 || static_cast(n) >= list.listSize()) { throw Error(format("list index %1% is out of bounds, at %2%") % n % pos); } state.forceValue(*(*list.list)[n]); @@ -1587,7 +1587,7 @@ static void prim_genList(EvalState& state, const Pos& pos, Value** args, state.mkList(v, len); - for (unsigned int n = 0; n < (unsigned int)len; ++n) { + for (unsigned int n = 0; n < static_cast(len); ++n) { Value* arg = state.allocValue(); mkInt(*arg, n); mkApp(*((*v.list)[n] = state.allocValue()), *args[0], *arg); @@ -1790,7 +1790,10 @@ static void prim_substring(EvalState& state, const Pos& pos, Value** args, pos); } - mkString(v, (unsigned int)start >= s.size() ? "" : std::string(s, start, len), + mkString(v, + static_cast(start) >= s.size() + ? "" + : std::string(s, start, len), context); } diff --git a/third_party/nix/src/libexpr/primops/fetchGit.cc b/third_party/nix/src/libexpr/primops/fetchGit.cc index d0e0d389cc..2b2ca476cb 100644 --- a/third_party/nix/src/libexpr/primops/fetchGit.cc +++ b/third_party/nix/src/libexpr/primops/fetchGit.cc @@ -129,7 +129,8 @@ GitInfo exportGit(ref store, const std::string& uri, git fetch to update the local ref to the remote ref. */ struct stat st; doFetch = stat(localRefFile.c_str(), &st) != 0 || - (uint64_t)st.st_mtime + settings.tarballTtl <= (uint64_t)now; + static_cast(st.st_mtime) + settings.tarballTtl <= + static_cast(now); } if (doFetch) { DLOG(INFO) << "fetching Git repository '" << uri << "'"; diff --git a/third_party/nix/src/libexpr/primops/fetchMercurial.cc b/third_party/nix/src/libexpr/primops/fetchMercurial.cc index 0367b2120b..df42b6d948 100644 --- a/third_party/nix/src/libexpr/primops/fetchMercurial.cc +++ b/third_party/nix/src/libexpr/primops/fetchMercurial.cc @@ -92,7 +92,8 @@ HgInfo exportMercurial(ref store, const std::string& uri, time_t now = time(0); struct stat st; if (stat(stampFile.c_str(), &st) != 0 || - (uint64_t)st.st_mtime + settings.tarballTtl <= (uint64_t)now) { + static_cast(st.st_mtime) + settings.tarballTtl <= + static_cast(now)) { /* Except that if this is a commit hash that we already have, we don't have to pull again. */ if (!(std::regex_match(rev, commitHashRegex) && pathExists(cacheDir) && diff --git a/third_party/nix/src/libmain/shared.cc b/third_party/nix/src/libmain/shared.cc index b04bd279b9..348b91ab55 100644 --- a/third_party/nix/src/libmain/shared.cc +++ b/third_party/nix/src/libmain/shared.cc @@ -327,7 +327,7 @@ RunPager::RunPager() { if (pager == nullptr) { pager = getenv("PAGER"); } - if (pager && ((std::string)pager == "" || (std::string)pager == "cat")) { + if (pager && (std::string(pager) == "" || std::string(pager) == "cat")) { return; } diff --git a/third_party/nix/src/libmain/stack.cc b/third_party/nix/src/libmain/stack.cc index c7744f69c8..628b6313a8 100644 --- a/third_party/nix/src/libmain/stack.cc +++ b/third_party/nix/src/libmain/stack.cc @@ -16,7 +16,7 @@ static void sigsegvHandler(int signo, siginfo_t* info, void* ctx) { bool haveSP = true; char* sp = nullptr; #if defined(__x86_64__) && defined(REG_RSP) - sp = (char*)((ucontext_t*)ctx)->uc_mcontext.gregs[REG_RSP]; + sp = (char*)(static_cast(ctx))->uc_mcontext.gregs[REG_RSP]; #elif defined(REG_ESP) sp = (char*)((ucontext_t*)ctx)->uc_mcontext.gregs[REG_ESP]; #else @@ -24,7 +24,7 @@ static void sigsegvHandler(int signo, siginfo_t* info, void* ctx) { #endif if (haveSP) { - ptrdiff_t diff = (char*)info->si_addr - sp; + ptrdiff_t diff = static_cast(info->si_addr) - sp; if (diff < 0) { diff = -diff; } diff --git a/third_party/nix/src/libstore/binary-cache-store.cc b/third_party/nix/src/libstore/binary-cache-store.cc index fce4dc0e11..d38db375ed 100644 --- a/third_party/nix/src/libstore/binary-cache-store.cc +++ b/third_party/nix/src/libstore/binary-cache-store.cc @@ -88,7 +88,7 @@ void BinaryCacheStore::getFile(const std::string& path, Sink& sink) { } }}); auto data = promise.get_future().get(); - sink((unsigned char*)data->data(), data->size()); + sink(reinterpret_cast(data->data()), data->size()); } std::shared_ptr BinaryCacheStore::getFile( @@ -206,7 +206,9 @@ void BinaryCacheStore::addToStore(const ValidPathInfo& info, .count(); DLOG(INFO) << "copying path '" << narInfo->path << "' (" << narInfo->narSize << " bytes, compressed " - << ((1.0 - (double)narCompressed->size() / nar->size()) * 100.0) + << ((1.0 - + static_cast(narCompressed->size()) / nar->size()) * + 100.0) << "% in " << duration << "ms) to binary cache"; /* Atomically write the NAR file. */ @@ -288,9 +290,8 @@ void BinaryCacheStore::queryPathInfoUncached( stats.narInfoRead++; - (*callbackPtr)( - (std::shared_ptr)std::make_shared( - *this, *data, narInfoFile)); + (*callbackPtr)(std::shared_ptr( + std::make_shared(*this, *data, narInfoFile))); } catch (...) { callbackPtr->rethrow(); diff --git a/third_party/nix/src/libstore/build.cc b/third_party/nix/src/libstore/build.cc index 9bff3b8345..c48e1abd72 100644 --- a/third_party/nix/src/libstore/build.cc +++ b/third_party/nix/src/libstore/build.cc @@ -1589,11 +1589,13 @@ MakeError(NotDeterministic, BuildError) 8ULL * 1024 * 1024; // FIXME: make configurable struct statvfs st; if (statvfs(worker.store.realStoreDir.c_str(), &st) == 0 && - (unsigned long long)st.f_bavail * st.f_bsize < required) { + static_cast(st.f_bavail) * st.f_bsize < + required) { diskFull = true; } if (statvfs(tmpDir.c_str(), &st) == 0 && - (unsigned long long)st.f_bavail * st.f_bsize < required) { + static_cast(st.f_bavail) * st.f_bsize < + required) { diskFull = true; } #endif @@ -1832,7 +1834,7 @@ void chmod_(const Path& path, mode_t mode) { } int childEntry(void* arg) { - ((DerivationGoal*)arg)->runChild(); + (static_cast(arg))->runChild(); return 1; } @@ -2361,9 +2363,9 @@ void DerivationGoal::startBuilder() { } size_t stackSize = 1 * 1024 * 1024; - char* stack = - (char*)mmap(nullptr, stackSize, PROT_WRITE | PROT_READ, - MAP_PRIVATE | MAP_ANONYMOUS | MAP_STACK, -1, 0); + char* stack = static_cast( + mmap(nullptr, stackSize, PROT_WRITE | PROT_READ, + MAP_PRIVATE | MAP_ANONYMOUS | MAP_STACK, -1, 0)); if (stack == MAP_FAILED) { throw SysError("allocating stack"); } @@ -4483,9 +4485,9 @@ void Worker::waitForInput() { } if (nearest != steady_time_point::max()) { timeout.tv_sec = std::max( - 1L, - (long)std::chrono::duration_cast(nearest - before) - .count()); + 1L, static_cast(std::chrono::duration_cast( + nearest - before) + .count())); useTimeout = true; } @@ -4500,10 +4502,11 @@ void Worker::waitForInput() { lastWokenUp = before; } timeout.tv_sec = std::max( - 1L, - (long)std::chrono::duration_cast( - lastWokenUp + std::chrono::seconds(settings.pollInterval) - before) - .count()); + 1L, static_cast(std::chrono::duration_cast( + lastWokenUp + + std::chrono::seconds(settings.pollInterval) - + before) + .count())); } else { lastWokenUp = steady_time_point::min(); } @@ -4568,7 +4571,7 @@ void Worker::waitForInput() { } } else { DLOG(INFO) << goal->getName() << ": read " << rd << " bytes"; - std::string data((char*)buffer.data(), rd); + std::string data(reinterpret_cast(buffer.data()), rd); j->lastOutput = after; goal->handleChildOutput(k, data); } diff --git a/third_party/nix/src/libstore/crypto.cc b/third_party/nix/src/libstore/crypto.cc index 4661cbbb18..0a2795cb0a 100644 --- a/third_party/nix/src/libstore/crypto.cc +++ b/third_party/nix/src/libstore/crypto.cc @@ -58,7 +58,8 @@ std::string SecretKey::signDetached(const std::string& data) const { unsigned long long sigLen; crypto_sign_detached(sig, &sigLen, (unsigned char*)data.data(), data.size(), (unsigned char*)key.data()); - return name + ":" + absl::Base64Escape(std::string((char*)sig, sigLen)); + return name + ":" + + absl::Base64Escape(std::string(reinterpret_cast(sig), sigLen)); #else noSodium(); #endif @@ -68,7 +69,8 @@ PublicKey SecretKey::toPublicKey() const { #if HAVE_SODIUM unsigned char pk[crypto_sign_PUBLICKEYBYTES]; crypto_sign_ed25519_sk_to_pk(pk, (unsigned char*)key.data()); - return PublicKey(name, std::string((char*)pk, crypto_sign_PUBLICKEYBYTES)); + return PublicKey(name, std::string(reinterpret_cast(pk), + crypto_sign_PUBLICKEYBYTES)); #else noSodium(); #endif @@ -102,8 +104,9 @@ bool verifyDetached(const std::string& data, const std::string& sig, } return crypto_sign_verify_detached( - (unsigned char*)sig2.data(), (unsigned char*)data.data(), - data.size(), (unsigned char*)key->second.key.data()) == 0; + reinterpret_cast(sig2.data()), + (unsigned char*)data.data(), data.size(), + (unsigned char*)key->second.key.data()) == 0; #else noSodium(); #endif diff --git a/third_party/nix/src/libstore/download.cc b/third_party/nix/src/libstore/download.cc index cf64a6bad7..60a409d0dc 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(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(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(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(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(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( - nextWakeup - std::chrono::steady_clock::now()) - .count()) + static_cast( + std::chrono::duration_cast( + 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(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(lastChecked) + request.ttl >= + static_cast(time(nullptr))) { skip = true; result.effectiveUri = request.uri; result.etag = ss[1]; diff --git a/third_party/nix/src/libstore/gc.cc b/third_party/nix/src/libstore/gc.cc index a491d7e32c..596046e4f3 100644 --- a/third_party/nix/src/libstore/gc.cc +++ b/third_party/nix/src/libstore/gc.cc @@ -241,7 +241,8 @@ void LocalStore::findTempRoots(FDs& fds, Roots& tempRoots, bool censor) { std::string::size_type pos = 0; std::string::size_type end; - while ((end = contents.find((char)0, pos)) != std::string::npos) { + while ((end = contents.find(static_cast(0), pos)) != + std::string::npos) { Path root(contents, pos, end - pos); DLOG(INFO) << "got temporary root " << root; assertStorePath(root); @@ -916,7 +917,7 @@ void LocalStore::autoGC(bool sync) { throw SysError("getting filesystem info about '%s'", realStoreDir); } - return (uint64_t)st.f_bavail * st.f_bsize; + return static_cast(st.f_bavail) * st.f_bsize; }; std::shared_future future; diff --git a/third_party/nix/src/libstore/legacy-ssh-store.cc b/third_party/nix/src/libstore/legacy-ssh-store.cc index 02231aabcd..343801870a 100644 --- a/third_party/nix/src/libstore/legacy-ssh-store.cc +++ b/third_party/nix/src/libstore/legacy-ssh-store.cc @@ -214,7 +214,7 @@ struct LegacySSHStore : public Store { conn->to.flush(); BuildResult status; - status.status = (BuildResult::Status)readInt(conn->from); + status.status = static_cast(readInt(conn->from)); conn->from >> status.errorMsg; if (GET_PROTOCOL_MINOR(conn->remoteVersion) >= 3) { diff --git a/third_party/nix/src/libstore/local-fs-store.cc b/third_party/nix/src/libstore/local-fs-store.cc index 2dd09093d5..2ebf99a9b5 100644 --- a/third_party/nix/src/libstore/local-fs-store.cc +++ b/third_party/nix/src/libstore/local-fs-store.cc @@ -41,7 +41,7 @@ struct LocalStoreAccessor : public FSAccessor { return {S_ISREG(st.st_mode) ? Type::tRegular : S_ISLNK(st.st_mode) ? Type::tSymlink : Type::tDirectory, - S_ISREG(st.st_mode) ? (uint64_t)st.st_size : 0, + S_ISREG(st.st_mode) ? static_cast(st.st_size) : 0, S_ISREG(st.st_mode) && ((st.st_mode & S_IXUSR) != 0u)}; } diff --git a/third_party/nix/src/libstore/local-store.cc b/third_party/nix/src/libstore/local-store.cc index 9b19e078b8..5e3271a5f3 100644 --- a/third_party/nix/src/libstore/local-store.cc +++ b/third_party/nix/src/libstore/local-store.cc @@ -350,7 +350,8 @@ void LocalStore::openDB(State& state, bool create) { if (sqlite3_step(stmt) != SQLITE_ROW) { throwSQLiteError(db, "querying journal mode"); } - prevMode = std::string((const char*)sqlite3_column_text(stmt, 0)); + prevMode = std::string( + reinterpret_cast(sqlite3_column_text(stmt, 0))); } if (prevMode != mode && sqlite3_exec(db, ("pragma main.journal_mode = " + mode + ";").c_str(), @@ -489,7 +490,7 @@ static void canonicalisePathMetaData_(const Path& path, uid_t fromUid, However, ignore files that we chown'ed ourselves previously to ensure that we don't fail on hard links within the same build (i.e. "touch $out/foo; ln $out/foo $out/bar"). */ - if (fromUid != (uid_t)-1 && st.st_uid != fromUid) { + if (fromUid != static_cast(-1) && st.st_uid != fromUid) { if (S_ISDIR(st.st_mode)) { throw BuildError(format("invalid file '%1%': is a directory") % path); } @@ -690,7 +691,8 @@ void LocalStore::queryPathInfoUncached( info->registrationTime = useQueryPathInfo.getInt(2); - auto s = (const char*)sqlite3_column_text(state->stmtQueryPathInfo, 3); + auto s = reinterpret_cast( + sqlite3_column_text(state->stmtQueryPathInfo, 3)); if (s != nullptr) { info->deriver = s; } @@ -700,12 +702,14 @@ void LocalStore::queryPathInfoUncached( info->ultimate = useQueryPathInfo.getInt(5) == 1; - s = (const char*)sqlite3_column_text(state->stmtQueryPathInfo, 6); + s = reinterpret_cast( + sqlite3_column_text(state->stmtQueryPathInfo, 6)); if (s != nullptr) { info->sigs = absl::StrSplit(s, absl::ByChar(' '), absl::SkipEmpty()); } - s = (const char*)sqlite3_column_text(state->stmtQueryPathInfo, 7); + s = reinterpret_cast( + sqlite3_column_text(state->stmtQueryPathInfo, 7)); if (s != nullptr) { info->ca = s; } @@ -860,8 +864,8 @@ Path LocalStore::queryPathFromHashPart(const std::string& hashPart) { return ""; } - const char* s = - (const char*)sqlite3_column_text(state->stmtQueryPathFromHashPart, 0); + const char* s = reinterpret_cast( + sqlite3_column_text(state->stmtQueryPathFromHashPart, 0)); return (s != nullptr) && prefix.compare(0, prefix.size(), s, prefix.size()) == 0 ? s diff --git a/third_party/nix/src/libstore/nar-accessor.cc b/third_party/nix/src/libstore/nar-accessor.cc index 49fa1bd1d6..cfd3d50b32 100644 --- a/third_party/nix/src/libstore/nar-accessor.cc +++ b/third_party/nix/src/libstore/nar-accessor.cc @@ -76,7 +76,7 @@ struct NarAccessor : public FSAccessor { void preallocateContents(unsigned long long size) override { currentStart = std::string(s, pos, 16); assert(size <= std::numeric_limits::max()); - parents.top()->size = (size_t)size; + parents.top()->size = static_cast(size); parents.top()->start = pos; } diff --git a/third_party/nix/src/libstore/nar-info-disk-cache.cc b/third_party/nix/src/libstore/nar-info-disk-cache.cc index b284fc698d..90ea20a893 100644 --- a/third_party/nix/src/libstore/nar-info-disk-cache.cc +++ b/third_party/nix/src/libstore/nar-info-disk-cache.cc @@ -164,8 +164,9 @@ class NarInfoDiskCacheImpl final : public NarInfoDiskCache { static_cast(wantMassQuery))(priority) .exec(); assert(sqlite3_changes(state->db) == 1); - state->caches[uri] = Cache{(int)sqlite3_last_insert_rowid(state->db), - storeDir, wantMassQuery, priority}; + state->caches[uri] = + Cache{static_cast(sqlite3_last_insert_rowid(state->db)), + storeDir, wantMassQuery, priority}; }); } @@ -181,8 +182,9 @@ class NarInfoDiskCacheImpl final : public NarInfoDiskCache { return false; } state->caches.emplace( - uri, Cache{(int)queryCache.getInt(0), queryCache.getStr(1), - queryCache.getInt(2) != 0, (int)queryCache.getInt(3)}); + uri, Cache{static_cast(queryCache.getInt(0)), + queryCache.getStr(1), queryCache.getInt(2) != 0, + static_cast(queryCache.getInt(3))}); } auto& cache(getCache(*state, uri)); diff --git a/third_party/nix/src/libstore/remote-fs-accessor.cc b/third_party/nix/src/libstore/remote-fs-accessor.cc index 2917f01f79..d5b2028847 100644 --- a/third_party/nix/src/libstore/remote-fs-accessor.cc +++ b/third_party/nix/src/libstore/remote-fs-accessor.cc @@ -75,12 +75,14 @@ std::pair, Path> RemoteFSAccessor::fetch(const Path& path_) { throw SysError("opening NAR cache file '%s'", cacheFile); } - if (lseek(fd.get(), offset, SEEK_SET) != (off_t)offset) { + if (lseek(fd.get(), offset, SEEK_SET) != + static_cast(offset)) { throw SysError("seeking in '%s'", cacheFile); } std::string buf(length, 0); - readFull(fd.get(), (unsigned char*)buf.data(), length); + readFull(fd.get(), reinterpret_cast(buf.data()), + length); return buf; }); diff --git a/third_party/nix/src/libstore/remote-store.cc b/third_party/nix/src/libstore/remote-store.cc index 7c45c5ff51..784a95d2e9 100644 --- a/third_party/nix/src/libstore/remote-store.cc +++ b/third_party/nix/src/libstore/remote-store.cc @@ -546,7 +546,7 @@ BuildResult RemoteStore::buildDerivation(const Path& drvPath, BuildResult res; unsigned int status; conn->from >> status >> res.errorMsg; - res.status = (BuildResult::Status)status; + res.status = static_cast(status); return res; } diff --git a/third_party/nix/src/libstore/sqlite.cc b/third_party/nix/src/libstore/sqlite.cc index b6ecfce924..0fb32326f5 100644 --- a/third_party/nix/src/libstore/sqlite.cc +++ b/third_party/nix/src/libstore/sqlite.cc @@ -133,7 +133,7 @@ bool SQLiteStmt::Use::next() { } std::string SQLiteStmt::Use::getStr(int col) { - auto s = (const char*)sqlite3_column_text(stmt, col); + auto s = reinterpret_cast(sqlite3_column_text(stmt, col)); assert(s); return s; } diff --git a/third_party/nix/src/libstore/ssh.cc b/third_party/nix/src/libstore/ssh.cc index 8f27f5eb22..52fbe64254 100644 --- a/third_party/nix/src/libstore/ssh.cc +++ b/third_party/nix/src/libstore/ssh.cc @@ -111,7 +111,7 @@ Path SSHMaster::startMaster() { state->tmpDir = std::make_unique(createTempDir("", "nix", true, true, 0700)); - state->socketPath = (Path)*state->tmpDir + "/ssh.sock"; + state->socketPath = Path(*state->tmpDir) + "/ssh.sock"; Pipe out; out.create(); diff --git a/third_party/nix/src/libstore/store-api.cc b/third_party/nix/src/libstore/store-api.cc index 4f4083f64f..dba9c8f95e 100644 --- a/third_party/nix/src/libstore/store-api.cc +++ b/third_party/nix/src/libstore/store-api.cc @@ -304,8 +304,8 @@ Path Store::makeFixedOutputPath(bool recursive, const Hash& hash, "output:out", hashString( htSHA256, - "fixed:out:" + (recursive ? (std::string) "r:" : "") + - hash.to_string(Base16) + ":"), + absl::StrCat("fixed:out:", (recursive ? "r:" : ""), + hash.to_string(Base16), ":")), name); } @@ -926,7 +926,7 @@ Strings ValidPathInfo::shortRefs() const { } std::string makeFixedOutputCA(bool recursive, const Hash& hash) { - return "fixed:" + (recursive ? (std::string) "r:" : "") + hash.to_string(); + return "fixed:" + (recursive ? std::string("r:") : "") + hash.to_string(); } void Store::addToStore(const ValidPathInfo& info, Source& narSource, diff --git a/third_party/nix/src/libutil/archive.cc b/third_party/nix/src/libutil/archive.cc index 4089809321..4489b7d2a8 100644 --- a/third_party/nix/src/libutil/archive.cc +++ b/third_party/nix/src/libutil/archive.cc @@ -80,7 +80,7 @@ static void dump(const Path& path, Sink& sink, PathFilter& filter) { sink << "executable" << ""; } - dumpContents(path, (size_t)st.st_size, sink); + dumpContents(path, static_cast(st.st_size), sink); } else if (S_ISDIR(st.st_mode)) { @@ -170,7 +170,7 @@ static void parseContents(ParseSink& sink, Source& source, const Path& path) { while (left != 0u) { checkInterrupt(); auto n = buf.size(); - if ((unsigned long long)n > left) { + if (static_cast(n) > left) { n = left; } source(buf.data(), n); @@ -267,7 +267,7 @@ static void parse(ParseSink& sink, Source& source, const Path& path) { name = readString(source); if (name.empty() || name == "." || name == ".." || name.find('/') != std::string::npos || - name.find((char)0) != std::string::npos) { + name.find(static_cast(0)) != std::string::npos) { throw Error(format("NAR contains invalid file name '%1%'") % name); } if (name <= prevName) { diff --git a/third_party/nix/src/libutil/args.cc b/third_party/nix/src/libutil/args.cc index c56383ef88..2be8a1b0ce 100644 --- a/third_party/nix/src/libutil/args.cc +++ b/third_party/nix/src/libutil/args.cc @@ -27,12 +27,12 @@ void Args::parseCmdline(const Strings& _cmdline) { `-j3` -> `-j 3`). */ if (!dashDash && arg.length() > 2 && arg[0] == '-' && arg[1] != '-' && (isalpha(arg[1]) != 0)) { - *pos = (std::string) "-" + arg[1]; + *pos = std::string("-") + arg[1]; auto next = pos; ++next; for (unsigned int j = 2; j < arg.length(); j++) { if (isalpha(arg[j]) != 0) { - cmdline.insert(next, (std::string) "-" + arg[j]); + cmdline.insert(next, std::string("-") + arg[j]); } else { cmdline.insert(next, std::string(arg, j)); break; diff --git a/third_party/nix/src/libutil/compression.cc b/third_party/nix/src/libutil/compression.cc index 779d326eb2..d0895ca5fd 100644 --- a/third_party/nix/src/libutil/compression.cc +++ b/third_party/nix/src/libutil/compression.cc @@ -99,7 +99,7 @@ struct BzipDecompressionSink : ChunkedCompressionSink { throw CompressionError("unable to initialise bzip2 decoder"); } - strm.next_out = (char*)outbuf; + strm.next_out = reinterpret_cast(outbuf); strm.avail_out = sizeof(outbuf); } @@ -128,7 +128,7 @@ struct BzipDecompressionSink : ChunkedCompressionSink { if (strm.avail_out < sizeof(outbuf) || strm.avail_in == 0) { nextSink(outbuf, sizeof(outbuf) - strm.avail_out); - strm.next_out = (char*)outbuf; + strm.next_out = reinterpret_cast(outbuf); strm.avail_out = sizeof(outbuf); } } @@ -287,7 +287,7 @@ struct BzipCompressionSink : ChunkedCompressionSink { throw CompressionError("unable to initialise bzip2 encoder"); } - strm.next_out = (char*)outbuf; + strm.next_out = reinterpret_cast(outbuf); strm.avail_out = sizeof(outbuf); } @@ -316,7 +316,7 @@ struct BzipCompressionSink : ChunkedCompressionSink { if (strm.avail_out < sizeof(outbuf) || strm.avail_in == 0) { nextSink(outbuf, sizeof(outbuf) - strm.avail_out); - strm.next_out = (char*)outbuf; + strm.next_out = reinterpret_cast(outbuf); strm.avail_out = sizeof(outbuf); } } diff --git a/third_party/nix/src/libutil/hash.cc b/third_party/nix/src/libutil/hash.cc index f7ee44728f..426096e73a 100644 --- a/third_party/nix/src/libutil/hash.cc +++ b/third_party/nix/src/libutil/hash.cc @@ -166,7 +166,7 @@ static std::string printHash32(const Hash& hash) { std::string s; s.reserve(len); - for (int n = (int)len - 1; n >= 0; n--) { + for (int n = static_cast(len) - 1; n >= 0; n--) { unsigned int b = n * 5; unsigned int i = b / 8; unsigned int j = b % 8; @@ -199,7 +199,8 @@ std::string Hash::to_string(Base base, bool includeType) const { case Base64: case SRI: std::string b64; - absl::Base64Escape(std::string((const char*)hash, hashSize), &b64); + absl::Base64Escape( + std::string(reinterpret_cast(hash), hashSize), &b64); s += b64; break; } @@ -366,7 +367,7 @@ Hash hashString(HashType ht, const std::string& s) { hash::Ctx ctx{}; Hash hash(ht); start(ht, ctx); - update(ht, ctx, (const unsigned char*)s.data(), s.length()); + update(ht, ctx, reinterpret_cast(s.data()), s.length()); finish(ht, ctx, hash.hash); return hash; } diff --git a/third_party/nix/src/libutil/json.cc b/third_party/nix/src/libutil/json.cc index da636e7be9..59ff74f579 100644 --- a/third_party/nix/src/libutil/json.cc +++ b/third_party/nix/src/libutil/json.cc @@ -18,7 +18,7 @@ void toJSON(std::ostream& str, const char* start, const char* end) { str << "\\t"; } else if (*i >= 0 && *i < 32) { str << "\\u" << std::setfill('0') << std::setw(4) << std::hex - << (uint16_t)*i << std::dec; + << static_cast(*i) << std::dec; } else { str << *i; } diff --git a/third_party/nix/src/libutil/serialise.cc b/third_party/nix/src/libutil/serialise.cc index d02a0205af..288255089b 100644 --- a/third_party/nix/src/libutil/serialise.cc +++ b/third_party/nix/src/libutil/serialise.cc @@ -96,7 +96,7 @@ std::string Source::drain() { size_t n; try { n = read(buf.data(), buf.size()); - s.append((char*)buf.data(), n); + s.append(reinterpret_cast(buf.data()), n); } catch (EndOfFile&) { break; } @@ -129,7 +129,7 @@ size_t FdSource::readUnbuffered(unsigned char* data, size_t len) { ssize_t n; do { checkInterrupt(); - n = ::read(fd, (char*)data, len); + n = ::read(fd, reinterpret_cast(data), len); } while (n == -1 && errno == EINTR); if (n == -1) { _good = false; @@ -149,7 +149,7 @@ size_t StringSource::read(unsigned char* data, size_t len) { if (pos == s.size()) { throw EndOfFile("end of string reached"); } - size_t n = s.copy((char*)data, len, pos); + size_t n = s.copy(reinterpret_cast(data), len, pos); pos += n; return n; } @@ -179,7 +179,7 @@ std::unique_ptr sinkToSource(const std::function& fun, coro = coro_t::pull_type([&](coro_t::push_type& yield) { LambdaSink sink([&](const unsigned char* data, size_t len) { if (len != 0u) { - yield(std::string((const char*)data, len)); + yield(std::string(reinterpret_cast(data), len)); } }); fun(sink); @@ -200,7 +200,7 @@ std::unique_ptr sinkToSource(const std::function& fun, } auto n = std::min(cur.size() - pos, len); - memcpy(data, (unsigned char*)cur.data() + pos, n); + memcpy(data, reinterpret_cast(cur.data()) + pos, n); pos += n; return n; @@ -225,7 +225,7 @@ void writeString(const unsigned char* buf, size_t len, Sink& sink) { } Sink& operator<<(Sink& sink, const std::string& s) { - writeString((const unsigned char*)s.data(), s.size(), sink); + writeString(reinterpret_cast(s.data()), s.size(), sink); return sink; } @@ -276,7 +276,7 @@ std::string readString(Source& source, size_t max) { throw SerialisationError("string is too long"); } std::string res(len, 0); - source((unsigned char*)res.data(), len); + source(reinterpret_cast(res.data()), len); readPadding(len, source); return res; } @@ -305,7 +305,7 @@ void StringSink::operator()(const unsigned char* data, size_t len) { warnLargeDump(); warned = true; } - s->append((const char*)data, len); + s->append(reinterpret_cast(data), len); } } // namespace nix diff --git a/third_party/nix/src/libutil/util.cc b/third_party/nix/src/libutil/util.cc index 3e88fd29b9..c93570d7b0 100644 --- a/third_party/nix/src/libutil/util.cc +++ b/third_party/nix/src/libutil/util.cc @@ -308,7 +308,7 @@ std::string readFile(int fd) { std::vector buf(st.st_size); readFull(fd, buf.data(), st.st_size); - return std::string((char*)buf.data(), st.st_size); + return std::string(reinterpret_cast(buf.data()), st.st_size); } std::string readFile(absl::string_view path, bool drain) { @@ -349,7 +349,7 @@ void writeFile(const Path& path, Source& source, mode_t mode) { while (true) { try { auto n = source.read(buf.data(), buf.size()); - writeFull(fd.get(), (unsigned char*)buf.data(), n); + writeFull(fd.get(), static_cast(buf.data()), n); } catch (EndOfFile&) { break; } @@ -619,7 +619,7 @@ void replaceSymlink(const Path& target, const Path& link) { void readFull(int fd, unsigned char* buf, size_t count) { while (count != 0u) { checkInterrupt(); - ssize_t res = read(fd, (char*)buf, count); + ssize_t res = read(fd, reinterpret_cast(buf), count); if (res == -1) { if (errno == EINTR) { continue; @@ -652,7 +652,8 @@ void writeFull(int fd, const unsigned char* buf, size_t count, } void writeFull(int fd, const std::string& s, bool allowInterrupts) { - writeFull(fd, (const unsigned char*)s.data(), s.size(), allowInterrupts); + writeFull(fd, reinterpret_cast(s.data()), s.size(), + allowInterrupts); } std::string drainFD(int fd, bool block) { @@ -954,7 +955,7 @@ pid_t startProcess(std::function fun, const ProcessOptions& options) { std::vector stringsToCharPtrs(const Strings& ss) { std::vector res; for (auto& s : ss) { - res.push_back((char*)s.c_str()); + res.push_back(const_cast(s.c_str())); } res.push_back(nullptr); return res; @@ -1270,7 +1271,7 @@ std::string filterANSIEscapes(const std::string& s, bool filterAll, size_t w = 0; auto i = s.begin(); - while (w < (size_t)width && i != s.end()) { + while (w < static_cast(width) && i != s.end()) { if (*i == '\e') { std::string e; e += *i++; @@ -1305,7 +1306,7 @@ std::string filterANSIEscapes(const std::string& s, bool filterAll, i++; t += ' '; w++; - while (w < (size_t)width && ((w % 8) != 0u)) { + while (w < static_cast(width) && ((w % 8) != 0u)) { t += ' '; w++; } diff --git a/third_party/nix/src/nix-build/nix-build.cc b/third_party/nix/src/nix-build/nix-build.cc index dde03c52cb..34d551c2d8 100644 --- a/third_party/nix/src/nix-build/nix-build.cc +++ b/third_party/nix/src/nix-build/nix-build.cc @@ -156,7 +156,7 @@ static void _main(int argc, char** argv) { ; // obsolete } else if (*arg == "--no-out-link" || *arg == "--no-link") { - outLink = (Path)tmpDir + "/result"; + outLink = Path(tmpDir) + "/result"; } else if (*arg == "--attr" || *arg == "-A") { attrPaths.push_back(getArg(*arg, arg, end)); @@ -455,7 +455,7 @@ static void _main(int argc, char** argv) { if (passAsFile.count(var.first) != 0u) { keepTmp = true; std::string fn = ".attr-" + std::to_string(fileNr++); - Path p = (Path)tmpDir + "/" + fn; + Path p = Path(tmpDir) + "/" + fn; writeFile(p, var.second); env[var.first + "Path"] = p; } else { @@ -469,7 +469,7 @@ static void _main(int argc, char** argv) { convenience, source $stdenv/setup to setup additional environment variables and shell functions. Also don't lose the current $PATH directories. */ - auto rcfile = (Path)tmpDir + "/rc"; + auto rcfile = Path(tmpDir) + "/rc"; writeFile( rcfile, fmt((keepTmp ? "" : "rm -rf '%1%'; "s) + @@ -488,7 +488,7 @@ static void _main(int argc, char** argv) { "shopt -u nullglob; " "unset TZ; %6%" "%7%", - (Path)tmpDir, (pure ? "" : "p=$PATH; "), + Path(tmpDir), (pure ? "" : "p=$PATH; "), (pure ? "" : "PATH=$PATH:$p; unset p; "), dirOf(shell), shell, (getenv("TZ") != nullptr ? (std::string("export TZ='") + getenv("TZ") + "'; ") diff --git a/third_party/nix/src/nix-channel/nix-channel.cc b/third_party/nix/src/nix-channel/nix-channel.cc index 8afdc16ac0..5cc16d1b4b 100644 --- a/third_party/nix/src/nix-channel/nix-channel.cc +++ b/third_party/nix/src/nix-channel/nix-channel.cc @@ -113,7 +113,7 @@ static void update(const StringSet& channelNames) { std::smatch match; auto urlBase = baseNameOf(url); if (std::regex_search(urlBase, match, std::regex("(-\\d.*)$"))) { - cname = cname + (std::string)match[1]; + cname = cname + std::string(match[1]); } std::string extraAttrs; diff --git a/third_party/nix/src/nix-daemon/nix-daemon-proto.cc b/third_party/nix/src/nix-daemon/nix-daemon-proto.cc index 58dbec04f3..d5c65e197f 100644 --- a/third_party/nix/src/nix-daemon/nix-daemon-proto.cc +++ b/third_party/nix/src/nix-daemon/nix-daemon-proto.cc @@ -78,7 +78,7 @@ struct RetrieveRegularNARSink : ParseSink { void createDirectory(const Path& path) override { regular = false; } void receiveContents(unsigned char* data, unsigned int len) override { - s.append((const char*)data, len); + s.append(reinterpret_cast(data), len); } void createSymlink(const Path& path, const std::string& target) override { diff --git a/third_party/nix/src/nix-env/nix-env.cc b/third_party/nix/src/nix-env/nix-env.cc index 585cfbe3f7..81eab2dedb 100644 --- a/third_party/nix/src/nix-env/nix-env.cc +++ b/third_party/nix/src/nix-env/nix-env.cc @@ -1050,8 +1050,9 @@ static void opQuery(Globals& globals, Strings opFlags, Strings opArgs) { attrs["valid"] = isValid ? "1" : "0"; attrs["substitutable"] = hasSubs ? "1" : "0"; } else { - columns.push_back((std::string)(isInstalled ? "I" : "-") + - (isValid ? "P" : "-") + (hasSubs ? "S" : "-")); + columns.push_back(absl::StrCat((isInstalled ? "I" : "-"), + (isValid ? "P" : "-"), + (hasSubs ? "S" : "-"))); } } @@ -1102,7 +1103,7 @@ static void opQuery(Globals& globals, Strings opFlags, Strings opArgs) { attrs["maxComparedVersion"] = version; } } else { - std::string column = (std::string) "" + ch + " " + version; + std::string column = std::to_string(ch) + " " + version; if (diff == cvGreater && tty) { column = ANSI_RED + column + ANSI_NORMAL; } diff --git a/third_party/nix/src/nix-prefetch-url/nix-prefetch-url.cc b/third_party/nix/src/nix-prefetch-url/nix-prefetch-url.cc index 839227c1bb..5454c6cd10 100644 --- a/third_party/nix/src/nix-prefetch-url/nix-prefetch-url.cc +++ b/third_party/nix/src/nix-prefetch-url/nix-prefetch-url.cc @@ -181,7 +181,7 @@ static int _main(int argc, char** argv) { auto actualUri = resolveMirrorUri(*state, uri); AutoDelete tmpDir(createTempDir(), true); - Path tmpFile = (Path)tmpDir + "/tmp"; + Path tmpFile = Path(tmpDir) + "/tmp"; /* Download the file. */ { @@ -201,7 +201,7 @@ static int _main(int argc, char** argv) { /* Optionally unpack the file. */ if (unpack) { LOG(INFO) << "unpacking..."; - Path unpacked = (Path)tmpDir + "/unpacked"; + Path unpacked = Path(tmpDir) + "/unpacked"; createDirs(unpacked); if (absl::EndsWith(baseNameOf(uri), ".zip")) { runProgram("unzip", true, {"-qq", tmpFile, "-d", unpacked}); diff --git a/third_party/nix/src/nix-store/nix-store.cc b/third_party/nix/src/nix-store/nix-store.cc index df17e56441..152d716641 100644 --- a/third_party/nix/src/nix-store/nix-store.cc +++ b/third_party/nix/src/nix-store/nix-store.cc @@ -964,7 +964,7 @@ static void opServe(Strings opFlags, Strings opArgs) { while (true) { ServeCommand cmd; try { - cmd = (ServeCommand)readInt(in); + cmd = static_cast(readInt(in)); } catch (EndOfFile& e) { break; } @@ -1174,13 +1174,15 @@ static void opGenerateBinaryCacheKey(Strings opFlags, Strings opArgs) { throw Error("key generation failed"); } - writeFile(publicKeyFile, keyName + ":" + - absl::Base64Escape(std::string( - (char*)pk, crypto_sign_PUBLICKEYBYTES))); + writeFile(publicKeyFile, + keyName + ":" + + absl::Base64Escape(std::string(reinterpret_cast(pk), + crypto_sign_PUBLICKEYBYTES))); umask(0077); - writeFile(secretKeyFile, keyName + ":" + - absl::Base64Escape(std::string( - (char*)sk, crypto_sign_SECRETKEYBYTES))); + writeFile(secretKeyFile, + keyName + ":" + + absl::Base64Escape(std::string(reinterpret_cast(sk), + crypto_sign_SECRETKEYBYTES))); #else throw Error( "Nix was not compiled with libsodium, required for signed binary cache " diff --git a/third_party/nix/src/nix/main.cc b/third_party/nix/src/nix/main.cc index 9ae06bc803..08390fd24b 100644 --- a/third_party/nix/src/nix/main.cc +++ b/third_party/nix/src/nix/main.cc @@ -38,7 +38,8 @@ static bool haveInternet() { continue; } if (i->ifa_addr->sa_family == AF_INET) { - if (ntohl(((sockaddr_in*)i->ifa_addr)->sin_addr.s_addr) != + if (ntohl( + (reinterpret_cast(i->ifa_addr))->sin_addr.s_addr) != INADDR_LOOPBACK) { return true; } diff --git a/third_party/nix/src/nix/path-info.cc b/third_party/nix/src/nix/path-info.cc index dca08b06ad..300a588a2e 100644 --- a/third_party/nix/src/nix/path-info.cc +++ b/third_party/nix/src/nix/path-info.cc @@ -96,7 +96,9 @@ struct CmdPathInfo final : StorePathsCommand, MixJSON { if (showSize || showClosureSize || showSigs) { std::cout << std::string( - std::max(0, (int)pathLen - (int)storePath.size()), ' '); + std::max(0, static_cast(pathLen) - + static_cast(storePath.size())), + ' '); } if (showSize) { diff --git a/third_party/nix/src/nix/repl.cc b/third_party/nix/src/nix/repl.cc index 7644b7b8c2..281b3c1e45 100644 --- a/third_party/nix/src/nix/repl.cc +++ b/third_party/nix/src/nix/repl.cc @@ -194,7 +194,7 @@ static int listPossibleCallback(char* s, char*** avp) { return p; }; - vp = check((char**)malloc(possible.size() * sizeof(char*))); + vp = check(static_cast(malloc(possible.size() * sizeof(char*)))); for (auto& p : possible) { vp[ac++] = check(strdup(p.c_str())); @@ -626,7 +626,7 @@ void NixRepl::addVarToScope(const Symbol& name, Value& v) { } staticEnv.vars[name] = displ; env->values[displ++] = &v; - varNames.insert((std::string)name); + varNames.insert(std::string(name)); } Expr* NixRepl::parseString(const std::string& s) { diff --git a/third_party/nix/src/nix/search.cc b/third_party/nix/src/nix/search.cc index 2bfdeac6f7..06d5c207e5 100644 --- a/third_party/nix/src/nix/search.cc +++ b/third_party/nix/src/nix/search.cc @@ -196,8 +196,8 @@ struct CmdSearch final : SourceExprCommand, MixJSON { : nullptr; doExpr(i.second.value, attrPath.empty() - ? (std::string)i.second.name - : attrPath + "." + (std::string)i.second.name, + ? std::string(i.second.name) + : attrPath + "." + std::string(i.second.name), toplevel2 || fromCache, cache2 ? cache2.get() : nullptr); } } diff --git a/third_party/nix/src/nix/verify.cc b/third_party/nix/src/nix/verify.cc index a9959d50de..6552e3d1a7 100644 --- a/third_party/nix/src/nix/verify.cc +++ b/third_party/nix/src/nix/verify.cc @@ -99,7 +99,8 @@ struct CmdVerify final : StorePathsCommand { } else { StringSet sigsSeen; - size_t actualSigsNeeded = std::max(sigsNeeded, (size_t)1); + size_t actualSigsNeeded = + std::max(sigsNeeded, static_cast(1)); size_t validSigs = 0; auto doSigs = [&](const StringSet& sigs) { -- cgit 1.4.1