diff options
Diffstat (limited to 'third_party/nix/src/nix')
-rw-r--r-- | third_party/nix/src/nix/edit.cc | 4 | ||||
-rw-r--r-- | third_party/nix/src/nix/main.cc | 5 | ||||
-rw-r--r-- | third_party/nix/src/nix/path-info.cc | 4 | ||||
-rw-r--r-- | third_party/nix/src/nix/repl.cc | 40 | ||||
-rw-r--r-- | third_party/nix/src/nix/search.cc | 6 | ||||
-rw-r--r-- | third_party/nix/src/nix/verify.cc | 3 |
6 files changed, 33 insertions, 29 deletions
diff --git a/third_party/nix/src/nix/edit.cc b/third_party/nix/src/nix/edit.cc index 958e8aec49..94a42abb79 100644 --- a/third_party/nix/src/nix/edit.cc +++ b/third_party/nix/src/nix/edit.cc @@ -28,7 +28,7 @@ struct CmdEdit final : InstallableCommand { auto v = installable->toValue(*state); - Value* v2; + Value* v2 = nullptr; try { auto dummyArgs = Bindings::NewGC(); v2 = findAlongAttrPath(*state, "meta.position", *dummyArgs, *v); @@ -46,7 +46,7 @@ struct CmdEdit final : InstallableCommand { } std::string filename(pos, 0, colon); - int lineno; + int lineno = 0; try { lineno = std::stoi(std::string(pos, colon + 1)); } catch (std::invalid_argument& e) { diff --git a/third_party/nix/src/nix/main.cc b/third_party/nix/src/nix/main.cc index 5536aac532..fa9ebe3743 100644 --- a/third_party/nix/src/nix/main.cc +++ b/third_party/nix/src/nix/main.cc @@ -25,7 +25,7 @@ namespace nix { /* Check if we have a non-loopback/link-local network interface. */ static bool haveInternet() { - struct ifaddrs* addrs; + struct ifaddrs* addrs = nullptr; if (getifaddrs(&addrs) != 0) { return true; @@ -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<sockaddr_in*>(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<int>(pathLen) - + static_cast<int>(storePath.size())), + ' '); } if (showSize) { diff --git a/third_party/nix/src/nix/repl.cc b/third_party/nix/src/nix/repl.cc index 7644b7b8c2..91bf500893 100644 --- a/third_party/nix/src/nix/repl.cc +++ b/third_party/nix/src/nix/repl.cc @@ -38,14 +38,14 @@ namespace nix { struct NixRepl : gc { std::string curDir; EvalState state; - Bindings* autoArgs; + Bindings* autoArgs{}; Strings loadedFiles; const static int envSize = 32768; StaticEnv staticEnv; - Env* env; - int displ; + Env* env{}; + int displ{}; StringSet varNames; const Path historyFile; @@ -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<char**>(malloc(possible.size() * sizeof(char*)))); for (auto& p : possible) { vp[ac++] = check(strdup(p.c_str())); @@ -272,8 +272,8 @@ void NixRepl::mainLoop(const std::vector<std::string>& files) { } bool NixRepl::getLine(std::string& input, const std::string& prompt) { - struct sigaction act; - struct sigaction old; + struct sigaction act {}; + struct sigaction old {}; sigset_t savedSignalMask; sigset_t set; @@ -334,8 +334,8 @@ StringSet NixRepl::completePrefix(const std::string& prefix) { cur = std::string(prefix, start + 1); } - size_t slash; - size_t dot; + size_t slash = 0; + size_t dot = 0; if ((slash = cur.rfind('/')) != std::string::npos) { try { @@ -367,7 +367,7 @@ StringSet NixRepl::completePrefix(const std::string& prefix) { std::string cur2 = std::string(cur, dot + 1); Expr* e = parseString(expr); - Value v; + Value v{}; e->eval(state, *env, v); state.forceAttrs(v); @@ -477,7 +477,7 @@ bool NixRepl::processLine(std::string line) { } else if (command == ":a" || command == ":add") { - Value v; + Value v{}; evalString(arg, v); addAttrsToScope(v); } @@ -493,14 +493,14 @@ bool NixRepl::processLine(std::string line) { } else if (command == ":t") { - Value v; + Value v{}; evalString(arg, v); std::cout << showType(v) << std::endl; } else if (command == ":u") { - Value v; - Value f; - Value result; + Value v{}; + Value f{}; + Value result{}; evalString(arg, v); evalString( "drv: (import <nixpkgs> {}).runCommand \"shell\" { buildInputs = [ drv " @@ -513,7 +513,7 @@ bool NixRepl::processLine(std::string line) { } else if (command == ":b" || command == ":i" || command == ":s") { - Value v; + Value v{}; evalString(arg, v); Path drvPath = getDerivationPath(v); @@ -540,7 +540,7 @@ bool NixRepl::processLine(std::string line) { } else if (command == ":p" || command == ":print") { - Value v; + Value v{}; evalString(arg, v); printValue(std::cout, v, 1000000000) << std::endl; } @@ -563,7 +563,7 @@ bool NixRepl::processLine(std::string line) { v.thunk.expr = e; addVarToScope(state.symbols.Create(name), v); } else { - Value v; + Value v{}; evalString(line, v); printValue(std::cout, v, 1) << std::endl; } @@ -575,8 +575,8 @@ bool NixRepl::processLine(std::string line) { void NixRepl::loadFile(const Path& path) { loadedFiles.remove(path); loadedFiles.push_back(path); - Value v; - Value v2; + Value v{}; + Value v2{}; state.evalFile(lookupFileArg(state, path), v); state.autoCallFunction(*autoArgs, v, v2); addAttrsToScope(v2); @@ -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..b53f0b5088 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); } } @@ -216,7 +216,7 @@ struct CmdSearch final : SourceExprCommand, MixJSON { if (useCache && pathExists(jsonCacheFileName)) { LOG(WARNING) << "using cached results; pass '-u' to update the cache"; - Value vRoot; + Value vRoot{}; parseJSON(*state, readFile(jsonCacheFileName), vRoot); fromCache = true; 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<size_t>(1)); size_t validSigs = 0; auto doSigs = [&](const StringSet& sigs) { |