fix(3p/nix): Fix all remaining compiler warnings
This compiles under `-Wall -Werror`. The largest chunk of this change is `final` qualifiers for the various Nix CLI command structs, which inherit from a Command class that has more virtual functions than are implemented by each command. Change-Id: I0925e6e1a39013f026773db5816e4a77d50f3b4a Reviewed-on: https://cl.tvl.fyi/c/depot/+/1294 Tested-by: BuildkiteCI Reviewed-by: isomer <isomer@tvl.fyi> Reviewed-by: kanepyork <rikingcoding@gmail.com>
This commit is contained in:
parent
ca50fb66d2
commit
15afa8472e
33 changed files with 66 additions and 39 deletions
1
third_party/nix/src/libexpr/eval.cc
vendored
1
third_party/nix/src/libexpr/eval.cc
vendored
|
@ -1252,7 +1252,6 @@ void EvalState::concatLists(Value& v, const NixList& lists, const Pos& pos) {
|
|||
|
||||
auto outlist = new (GC) NixList();
|
||||
|
||||
size_t len = 0;
|
||||
for (Value* list : lists) {
|
||||
forceList(*list, pos);
|
||||
outlist->insert(outlist->end(), list->list->begin(), list->list->end());
|
||||
|
|
11
third_party/nix/src/libexpr/parser.hh
vendored
11
third_party/nix/src/libexpr/parser.hh
vendored
|
@ -34,6 +34,15 @@ struct ParseData : public gc {
|
|||
sLetBody(symbols.Create("<let-body>")){};
|
||||
};
|
||||
|
||||
// Clang fails to identify these functions as used, probably because
|
||||
// of some interaction between the lexer/parser codegen and something
|
||||
// else.
|
||||
//
|
||||
// To avoid warnings for that we disable -Wunused-function in this block.
|
||||
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Wunused-function"
|
||||
|
||||
// TODO(tazjin): move dupAttr to anonymous namespace
|
||||
static void dupAttr(const AttrPath& attrPath, const Pos& pos,
|
||||
const Pos& prevPos) {
|
||||
|
@ -85,4 +94,6 @@ static Expr* unescapeStr(SymbolTable& symbols, const char* s, size_t length) {
|
|||
return new ExprString(symbols.Create(t));
|
||||
}
|
||||
|
||||
#pragma clang diagnostic pop // re-enable -Wunused-function
|
||||
|
||||
} // namespace nix
|
||||
|
|
5
third_party/nix/src/libexpr/parser.y
vendored
5
third_party/nix/src/libexpr/parser.y
vendored
|
@ -11,7 +11,10 @@
|
|||
%expect 1
|
||||
%expect-rr 1
|
||||
|
||||
%code requires { #include "libexpr/parser.hh" }
|
||||
%code requires {
|
||||
#define YY_NO_INPUT 1 // disable unused yyinput features
|
||||
#include "libexpr/parser.hh"
|
||||
}
|
||||
|
||||
%{
|
||||
|
||||
|
|
2
third_party/nix/src/libexpr/primops.cc
vendored
2
third_party/nix/src/libexpr/primops.cc
vendored
|
@ -1680,8 +1680,6 @@ static void prim_partition(EvalState& state, const Pos& pos, Value** args,
|
|||
state.forceFunction(*args[0], pos);
|
||||
state.forceList(*args[1], pos);
|
||||
|
||||
auto len = args[1]->listSize();
|
||||
|
||||
NixList* right = new (GC) NixList();
|
||||
NixList* wrong = new (GC) NixList();
|
||||
|
||||
|
|
8
third_party/nix/src/libstore/local-store.cc
vendored
8
third_party/nix/src/libstore/local-store.cc
vendored
|
@ -490,10 +490,18 @@ static void canonicalisePathMetaData_(const Path& path, uid_t fromUid,
|
|||
if (inodesSeen.find(Inode(st.st_dev, st.st_ino)) == inodesSeen.end()) {
|
||||
throw BuildError(format("invalid ownership on file '%1%'") % path);
|
||||
}
|
||||
|
||||
// `mode` variable is only used in debug builds
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Wunused-variable"
|
||||
|
||||
mode_t mode = st.st_mode & ~S_IFMT;
|
||||
assert(S_ISLNK(st.st_mode) ||
|
||||
(st.st_uid == geteuid() && (mode == 0444 || mode == 0555) &&
|
||||
st.st_mtime == mtimeStore));
|
||||
|
||||
#pragma clang diagnostic pop
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -49,7 +49,7 @@ create table if not exists LastPurge (
|
|||
|
||||
)sql";
|
||||
|
||||
class NarInfoDiskCacheImpl : public NarInfoDiskCache {
|
||||
class NarInfoDiskCacheImpl final : public NarInfoDiskCache {
|
||||
public:
|
||||
/* How often to purge expired entries from the cache. */
|
||||
const int purgeInterval = 24 * 3600;
|
||||
|
@ -280,8 +280,9 @@ class NarInfoDiskCacheImpl : public NarInfoDiskCache {
|
|||
}
|
||||
};
|
||||
|
||||
ref<NarInfoDiskCache> getNarInfoDiskCache() {
|
||||
static ref<NarInfoDiskCache> cache = make_ref<NarInfoDiskCacheImpl>();
|
||||
std::shared_ptr<NarInfoDiskCache> getNarInfoDiskCache() {
|
||||
static std::shared_ptr<NarInfoDiskCache> cache =
|
||||
std::make_shared<NarInfoDiskCacheImpl>();
|
||||
return cache;
|
||||
}
|
||||
|
||||
|
|
|
@ -25,6 +25,6 @@ class NarInfoDiskCache {
|
|||
|
||||
/* Return a singleton cache object that can be used concurrently by
|
||||
multiple threads. */
|
||||
ref<NarInfoDiskCache> getNarInfoDiskCache();
|
||||
std::shared_ptr<NarInfoDiskCache> getNarInfoDiskCache();
|
||||
|
||||
} // namespace nix
|
||||
|
|
7
third_party/nix/src/libutil/util.hh
vendored
7
third_party/nix/src/libutil/util.hh
vendored
|
@ -390,6 +390,11 @@ class Callback {
|
|||
}
|
||||
}
|
||||
|
||||
// The unused-variable assert is disabled in this block because the
|
||||
// `prev` variables are only used in debug mode (in the asserts).
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Wunused-variable"
|
||||
|
||||
void operator()(T&& t) noexcept {
|
||||
auto prev = done.test_and_set();
|
||||
assert(!prev);
|
||||
|
@ -406,6 +411,8 @@ class Callback {
|
|||
promise.set_exception(exc);
|
||||
fun(promise.get_future());
|
||||
}
|
||||
|
||||
#pragma clang diagnostic pop
|
||||
};
|
||||
|
||||
/* Start a thread that handles various signals. Also block those signals
|
||||
|
|
2
third_party/nix/src/nix/add-to-store.cc
vendored
2
third_party/nix/src/nix/add-to-store.cc
vendored
|
@ -5,7 +5,7 @@
|
|||
|
||||
using namespace nix;
|
||||
|
||||
struct CmdAddToStore : MixDryRun, StoreCommand {
|
||||
struct CmdAddToStore final : MixDryRun, StoreCommand {
|
||||
Path path;
|
||||
std::optional<std::string> namePart;
|
||||
|
||||
|
|
2
third_party/nix/src/nix/build.cc
vendored
2
third_party/nix/src/nix/build.cc
vendored
|
@ -5,7 +5,7 @@
|
|||
|
||||
using namespace nix;
|
||||
|
||||
struct CmdBuild : MixDryRun, InstallablesCommand {
|
||||
struct CmdBuild final : MixDryRun, InstallablesCommand {
|
||||
Path outLink = "result";
|
||||
|
||||
CmdBuild() {
|
||||
|
|
4
third_party/nix/src/nix/cat.cc
vendored
4
third_party/nix/src/nix/cat.cc
vendored
|
@ -21,7 +21,7 @@ struct MixCat : virtual Args {
|
|||
}
|
||||
};
|
||||
|
||||
struct CmdCatStore : StoreCommand, MixCat {
|
||||
struct CmdCatStore final : StoreCommand, MixCat {
|
||||
CmdCatStore() { expectArg("path", &path); }
|
||||
|
||||
std::string name() override { return "cat-store"; }
|
||||
|
@ -33,7 +33,7 @@ struct CmdCatStore : StoreCommand, MixCat {
|
|||
void run(ref<Store> store) override { cat(store->getFSAccessor()); }
|
||||
};
|
||||
|
||||
struct CmdCatNar : StoreCommand, MixCat {
|
||||
struct CmdCatNar final : StoreCommand, MixCat {
|
||||
Path narPath;
|
||||
|
||||
CmdCatNar() {
|
||||
|
|
2
third_party/nix/src/nix/copy.cc
vendored
2
third_party/nix/src/nix/copy.cc
vendored
|
@ -8,7 +8,7 @@
|
|||
|
||||
using namespace nix;
|
||||
|
||||
struct CmdCopy : StorePathsCommand {
|
||||
struct CmdCopy final : StorePathsCommand {
|
||||
std::string srcUri, dstUri;
|
||||
|
||||
CheckSigsFlag checkSigs = CheckSigs;
|
||||
|
|
2
third_party/nix/src/nix/doctor.cc
vendored
2
third_party/nix/src/nix/doctor.cc
vendored
|
@ -19,7 +19,7 @@ std::string formatProtocol(unsigned int proto) {
|
|||
return "unknown";
|
||||
}
|
||||
|
||||
struct CmdDoctor : StoreCommand {
|
||||
struct CmdDoctor final : StoreCommand {
|
||||
bool success = true;
|
||||
|
||||
std::string name() override { return "doctor"; }
|
||||
|
|
2
third_party/nix/src/nix/dump-path.cc
vendored
2
third_party/nix/src/nix/dump-path.cc
vendored
|
@ -3,7 +3,7 @@
|
|||
|
||||
using namespace nix;
|
||||
|
||||
struct CmdDumpPath : StorePathCommand {
|
||||
struct CmdDumpPath final : StorePathCommand {
|
||||
std::string name() override { return "dump-path"; }
|
||||
|
||||
std::string description() override {
|
||||
|
|
2
third_party/nix/src/nix/edit.cc
vendored
2
third_party/nix/src/nix/edit.cc
vendored
|
@ -9,7 +9,7 @@
|
|||
|
||||
using namespace nix;
|
||||
|
||||
struct CmdEdit : InstallableCommand {
|
||||
struct CmdEdit final : InstallableCommand {
|
||||
std::string name() override { return "edit"; }
|
||||
|
||||
std::string description() override {
|
||||
|
|
2
third_party/nix/src/nix/eval.cc
vendored
2
third_party/nix/src/nix/eval.cc
vendored
|
@ -9,7 +9,7 @@
|
|||
|
||||
using namespace nix;
|
||||
|
||||
struct CmdEval : MixJSON, InstallableCommand {
|
||||
struct CmdEval final : MixJSON, InstallableCommand {
|
||||
bool raw = false;
|
||||
|
||||
CmdEval() { mkFlag(0, "raw", "print strings unquoted", &raw); }
|
||||
|
|
4
third_party/nix/src/nix/hash.cc
vendored
4
third_party/nix/src/nix/hash.cc
vendored
|
@ -6,7 +6,7 @@
|
|||
|
||||
using namespace nix;
|
||||
|
||||
struct CmdHash : Command {
|
||||
struct CmdHash final : Command {
|
||||
enum Mode { mFile, mPath };
|
||||
Mode mode;
|
||||
Base base = SRI;
|
||||
|
@ -47,7 +47,7 @@ struct CmdHash : Command {
|
|||
static RegisterCommand r1(make_ref<CmdHash>(CmdHash::mFile));
|
||||
static RegisterCommand r2(make_ref<CmdHash>(CmdHash::mPath));
|
||||
|
||||
struct CmdToBase : Command {
|
||||
struct CmdToBase final : Command {
|
||||
Base base;
|
||||
HashType ht = htUnknown;
|
||||
std::vector<std::string> args;
|
||||
|
|
6
third_party/nix/src/nix/installables.cc
vendored
6
third_party/nix/src/nix/installables.cc
vendored
|
@ -98,7 +98,7 @@ Buildable Installable::toBuildable() {
|
|||
return std::move(buildables[0]);
|
||||
}
|
||||
|
||||
struct InstallableStorePath : Installable {
|
||||
struct InstallableStorePath final : Installable {
|
||||
Path storePath;
|
||||
|
||||
explicit InstallableStorePath(Path storePath)
|
||||
|
@ -158,7 +158,7 @@ struct InstallableValue : Installable {
|
|||
}
|
||||
};
|
||||
|
||||
struct InstallableExpr : InstallableValue {
|
||||
struct InstallableExpr final : InstallableValue {
|
||||
std::string text;
|
||||
|
||||
InstallableExpr(SourceExprCommand& cmd, std::string text)
|
||||
|
@ -173,7 +173,7 @@ struct InstallableExpr : InstallableValue {
|
|||
}
|
||||
};
|
||||
|
||||
struct InstallableAttrPath : InstallableValue {
|
||||
struct InstallableAttrPath final : InstallableValue {
|
||||
std::string attrPath;
|
||||
|
||||
InstallableAttrPath(SourceExprCommand& cmd, std::string attrPath)
|
||||
|
|
2
third_party/nix/src/nix/log.cc
vendored
2
third_party/nix/src/nix/log.cc
vendored
|
@ -7,7 +7,7 @@
|
|||
|
||||
using namespace nix;
|
||||
|
||||
struct CmdLog : InstallableCommand {
|
||||
struct CmdLog final : InstallableCommand {
|
||||
CmdLog() = default;
|
||||
|
||||
std::string name() override { return "log"; }
|
||||
|
|
4
third_party/nix/src/nix/ls.cc
vendored
4
third_party/nix/src/nix/ls.cc
vendored
|
@ -88,7 +88,7 @@ struct MixLs : virtual Args, MixJSON {
|
|||
}
|
||||
};
|
||||
|
||||
struct CmdLsStore : StoreCommand, MixLs {
|
||||
struct CmdLsStore final : StoreCommand, MixLs {
|
||||
CmdLsStore() { expectArg("path", &path); }
|
||||
|
||||
Examples examples() override {
|
||||
|
@ -108,7 +108,7 @@ struct CmdLsStore : StoreCommand, MixLs {
|
|||
void run(ref<Store> store) override { list(store->getFSAccessor()); }
|
||||
};
|
||||
|
||||
struct CmdLsNar : Command, MixLs {
|
||||
struct CmdLsNar final : Command, MixLs {
|
||||
Path narPath;
|
||||
|
||||
CmdLsNar() {
|
||||
|
|
2
third_party/nix/src/nix/optimise-store.cc
vendored
2
third_party/nix/src/nix/optimise-store.cc
vendored
|
@ -6,7 +6,7 @@
|
|||
|
||||
using namespace nix;
|
||||
|
||||
struct CmdOptimiseStore : StoreCommand {
|
||||
struct CmdOptimiseStore final : StoreCommand {
|
||||
CmdOptimiseStore() = default;
|
||||
|
||||
std::string name() override { return "optimise-store"; }
|
||||
|
|
2
third_party/nix/src/nix/path-info.cc
vendored
2
third_party/nix/src/nix/path-info.cc
vendored
|
@ -9,7 +9,7 @@
|
|||
|
||||
using namespace nix;
|
||||
|
||||
struct CmdPathInfo : StorePathsCommand, MixJSON {
|
||||
struct CmdPathInfo final : StorePathsCommand, MixJSON {
|
||||
bool showSize = false;
|
||||
bool showClosureSize = false;
|
||||
bool humanReadable = false;
|
||||
|
|
2
third_party/nix/src/nix/ping-store.cc
vendored
2
third_party/nix/src/nix/ping-store.cc
vendored
|
@ -4,7 +4,7 @@
|
|||
|
||||
using namespace nix;
|
||||
|
||||
struct CmdPingStore : StoreCommand {
|
||||
struct CmdPingStore final : StoreCommand {
|
||||
std::string name() override { return "ping-store"; }
|
||||
|
||||
std::string description() override {
|
||||
|
|
2
third_party/nix/src/nix/repl.cc
vendored
2
third_party/nix/src/nix/repl.cc
vendored
|
@ -799,7 +799,7 @@ std::ostream& NixRepl::printValue(std::ostream& str, Value& v,
|
|||
return str;
|
||||
}
|
||||
|
||||
struct CmdRepl : StoreCommand, MixEvalArgs {
|
||||
struct CmdRepl final : StoreCommand, MixEvalArgs {
|
||||
std::vector<std::string> files;
|
||||
|
||||
CmdRepl() { expectArgs("files", &files); }
|
||||
|
|
2
third_party/nix/src/nix/run.cc
vendored
2
third_party/nix/src/nix/run.cc
vendored
|
@ -17,7 +17,7 @@ using namespace nix;
|
|||
|
||||
std::string chrootHelperName = "__run_in_chroot";
|
||||
|
||||
struct CmdRun : InstallablesCommand {
|
||||
struct CmdRun final : InstallablesCommand {
|
||||
std::vector<std::string> command = {"bash"};
|
||||
StringSet keep, unset;
|
||||
bool ignoreEnvironment = false;
|
||||
|
|
2
third_party/nix/src/nix/search.cc
vendored
2
third_party/nix/src/nix/search.cc
vendored
|
@ -27,7 +27,7 @@ std::string hilite(const std::string& s, const std::smatch& m,
|
|||
postfix + std::string(m.suffix());
|
||||
}
|
||||
|
||||
struct CmdSearch : SourceExprCommand, MixJSON {
|
||||
struct CmdSearch final : SourceExprCommand, MixJSON {
|
||||
std::vector<std::string> res;
|
||||
|
||||
bool writeCache = true;
|
||||
|
|
2
third_party/nix/src/nix/show-config.cc
vendored
2
third_party/nix/src/nix/show-config.cc
vendored
|
@ -6,7 +6,7 @@
|
|||
|
||||
using namespace nix;
|
||||
|
||||
struct CmdShowConfig : Command, MixJSON {
|
||||
struct CmdShowConfig final : Command, MixJSON {
|
||||
CmdShowConfig() = default;
|
||||
|
||||
std::string name() override { return "show-config"; }
|
||||
|
|
2
third_party/nix/src/nix/show-derivation.cc
vendored
2
third_party/nix/src/nix/show-derivation.cc
vendored
|
@ -9,7 +9,7 @@
|
|||
|
||||
using namespace nix;
|
||||
|
||||
struct CmdShowDerivation : InstallablesCommand {
|
||||
struct CmdShowDerivation final : InstallablesCommand {
|
||||
bool recursive = false;
|
||||
|
||||
CmdShowDerivation() {
|
||||
|
|
4
third_party/nix/src/nix/sigs.cc
vendored
4
third_party/nix/src/nix/sigs.cc
vendored
|
@ -9,7 +9,7 @@
|
|||
|
||||
using namespace nix;
|
||||
|
||||
struct CmdCopySigs : StorePathsCommand {
|
||||
struct CmdCopySigs final : StorePathsCommand {
|
||||
Strings substituterUris;
|
||||
|
||||
CmdCopySigs() {
|
||||
|
@ -99,7 +99,7 @@ struct CmdCopySigs : StorePathsCommand {
|
|||
|
||||
static RegisterCommand r1(make_ref<CmdCopySigs>());
|
||||
|
||||
struct CmdSignPaths : StorePathsCommand {
|
||||
struct CmdSignPaths final : StorePathsCommand {
|
||||
Path secretKeyFile;
|
||||
|
||||
CmdSignPaths() {
|
||||
|
|
2
third_party/nix/src/nix/upgrade-nix.cc
vendored
2
third_party/nix/src/nix/upgrade-nix.cc
vendored
|
@ -13,7 +13,7 @@
|
|||
|
||||
using namespace nix;
|
||||
|
||||
struct CmdUpgradeNix : MixDryRun, StoreCommand {
|
||||
struct CmdUpgradeNix final : MixDryRun, StoreCommand {
|
||||
Path profileDir;
|
||||
std::string storePathsUrl =
|
||||
"https://github.com/NixOS/nixpkgs/raw/master/nixos/modules/installer/"
|
||||
|
|
2
third_party/nix/src/nix/verify.cc
vendored
2
third_party/nix/src/nix/verify.cc
vendored
|
@ -10,7 +10,7 @@
|
|||
|
||||
using namespace nix;
|
||||
|
||||
struct CmdVerify : StorePathsCommand {
|
||||
struct CmdVerify final : StorePathsCommand {
|
||||
bool noContents = false;
|
||||
bool noTrust = false;
|
||||
Strings substituterUris;
|
||||
|
|
2
third_party/nix/src/nix/why-depends.cc
vendored
2
third_party/nix/src/nix/why-depends.cc
vendored
|
@ -23,7 +23,7 @@ static std::string filterPrintable(const std::string& s) {
|
|||
return res;
|
||||
}
|
||||
|
||||
struct CmdWhyDepends : SourceExprCommand {
|
||||
struct CmdWhyDepends final : SourceExprCommand {
|
||||
std::string _package, _dependency;
|
||||
bool all = false;
|
||||
|
||||
|
|
2
third_party/nix/src/tests/language-tests.cc
vendored
2
third_party/nix/src/tests/language-tests.cc
vendored
|
@ -174,7 +174,7 @@ TEST_P(EvalFailureTest, Fails) {
|
|||
EvalState state({}, ref<Store>(store));
|
||||
auto path = GetParam();
|
||||
|
||||
Expr* expr;
|
||||
Expr* expr = nullptr;
|
||||
EXPECT_NO_THROW(expr = state.parseExprFromFile(GetParam().string()))
|
||||
<< path.stem().string() << ": should parse successfully";
|
||||
|
||||
|
|
Loading…
Reference in a new issue