aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Ericson <John.Ericson@Obsidian.Systems>2023-01-06 12:24:20 -0500
committerJohn Ericson <John.Ericson@Obsidian.Systems>2023-01-06 12:24:20 -0500
commit6a168254ce068c067259c913ee7d6ee2e0d1dc7e (patch)
tree7fd9315876cdca5224a978cba8b0a792bbd6710d
parent8623143921f8683b88d46aaebe9f707e5b9a912b (diff)
Use named field initialization for references
-rw-r--r--perl/lib/Nix/Store.xs2
-rw-r--r--src/libexpr/primops.cc2
-rw-r--r--src/libexpr/primops/fetchTree.cc2
-rw-r--r--src/libfetchers/fetchers.cc2
-rw-r--r--src/libfetchers/tarball.cc2
-rw-r--r--src/libstore/binary-cache-store.cc4
-rw-r--r--src/libstore/build/local-derivation-goal.cc2
-rw-r--r--src/libstore/content-address.cc10
-rw-r--r--src/libstore/local-store.cc2
-rw-r--r--src/libstore/make-content-addressed.cc2
-rw-r--r--src/libstore/store-api.cc22
-rw-r--r--src/nix-store/nix-store.cc2
-rw-r--r--src/nix/add-to-store.cc2
-rw-r--r--src/nix/prefetch.cc2
-rw-r--r--src/nix/profile.cc2
15 files changed, 34 insertions, 26 deletions
diff --git a/perl/lib/Nix/Store.xs b/perl/lib/Nix/Store.xs
index 9cb078660..3ccd3c722 100644
--- a/perl/lib/Nix/Store.xs
+++ b/perl/lib/Nix/Store.xs
@@ -299,7 +299,7 @@ SV * makeFixedOutputPath(int recursive, char * algo, char * hash, char * name)
.method = method,
.hash = h,
},
- {},
+ .references = {},
});
XPUSHs(sv_2mortal(newSVpv(store()->printStorePath(path).c_str(), 0)));
} catch (Error & e) {
diff --git a/src/libexpr/primops.cc b/src/libexpr/primops.cc
index 8e9e5630d..8a19eab8f 100644
--- a/src/libexpr/primops.cc
+++ b/src/libexpr/primops.cc
@@ -1249,7 +1249,7 @@ static void prim_derivationStrict(EvalState & state, const PosIdx pos, Value * *
.method = method,
.hash = h,
},
- {},
+ .references = {},
});
drv.env["out"] = state.store->printStorePath(outPath);
drv.outputs.insert_or_assign("out",
diff --git a/src/libexpr/primops/fetchTree.cc b/src/libexpr/primops/fetchTree.cc
index 4181f0b7d..560a086f0 100644
--- a/src/libexpr/primops/fetchTree.cc
+++ b/src/libexpr/primops/fetchTree.cc
@@ -235,7 +235,7 @@ static void fetch(EvalState & state, const PosIdx pos, Value * * args, Value & v
.method = unpack ? FileIngestionMethod::Recursive : FileIngestionMethod::Flat,
.hash = *expectedHash,
},
- {}
+ .references = {}
});
if (state.store->isValidPath(expectedPath)) {
diff --git a/src/libfetchers/fetchers.cc b/src/libfetchers/fetchers.cc
index 735d9fc93..3936eadfe 100644
--- a/src/libfetchers/fetchers.cc
+++ b/src/libfetchers/fetchers.cc
@@ -215,7 +215,7 @@ StorePath Input::computeStorePath(Store & store) const
.method = FileIngestionMethod::Recursive,
.hash = *narHash,
},
- {},
+ .references = {},
});
}
diff --git a/src/libfetchers/tarball.cc b/src/libfetchers/tarball.cc
index d52d19797..155b86cc4 100644
--- a/src/libfetchers/tarball.cc
+++ b/src/libfetchers/tarball.cc
@@ -79,7 +79,7 @@ DownloadFileResult downloadFile(
.method = FileIngestionMethod::Flat,
.hash = hash,
},
- {},
+ .references = {},
},
},
hashString(htSHA256, sink.s),
diff --git a/src/libstore/binary-cache-store.cc b/src/libstore/binary-cache-store.cc
index 3bbf4c8ac..aac5e7b88 100644
--- a/src/libstore/binary-cache-store.cc
+++ b/src/libstore/binary-cache-store.cc
@@ -313,7 +313,7 @@ StorePath BinaryCacheStore::addToStoreFromDump(Source & dump, std::string_view n
.method = method,
.hash = nar.first,
},
- {
+ .references = {
.references = references,
.hasSelfReference = false,
},
@@ -433,7 +433,7 @@ StorePath BinaryCacheStore::addToStore(
.method = method,
.hash = h,
},
- {
+ .references = {
.references = references,
.hasSelfReference = false,
},
diff --git a/src/libstore/build/local-derivation-goal.cc b/src/libstore/build/local-derivation-goal.cc
index 110a6a301..3d8299bbf 100644
--- a/src/libstore/build/local-derivation-goal.cc
+++ b/src/libstore/build/local-derivation-goal.cc
@@ -2482,7 +2482,7 @@ DrvOutputs LocalDerivationGoal::registerOutputs()
.method = outputHash.method,
.hash = got,
},
- rewriteRefs(),
+ .references = rewriteRefs(),
},
},
Hash::dummy,
diff --git a/src/libstore/content-address.cc b/src/libstore/content-address.cc
index 2e6c435ce..3b8a773b7 100644
--- a/src/libstore/content-address.cc
+++ b/src/libstore/content-address.cc
@@ -154,10 +154,16 @@ Hash getContentAddressHash(const ContentAddress & ca)
ContentAddressWithReferences caWithoutRefs(const ContentAddress & ca) {
return std::visit(overloaded {
[&](const TextHash & h) -> ContentAddressWithReferences {
- return TextInfo { h, {}};
+ return TextInfo {
+ h,
+ .references = {},
+ };
},
[&](const FixedOutputHash & h) -> ContentAddressWithReferences {
- return FixedOutputInfo { h, {}};
+ return FixedOutputInfo {
+ h,
+ .references = {},
+ };
},
}, ca);
}
diff --git a/src/libstore/local-store.cc b/src/libstore/local-store.cc
index a8f060768..9f3a6db24 100644
--- a/src/libstore/local-store.cc
+++ b/src/libstore/local-store.cc
@@ -1426,7 +1426,7 @@ StorePath LocalStore::addToStoreFromDump(Source & source0, std::string_view name
.method = method,
.hash = hash,
},
- {
+ .references = {
.references = references,
.hasSelfReference = false,
},
diff --git a/src/libstore/make-content-addressed.cc b/src/libstore/make-content-addressed.cc
index 9655a0555..d6b6e87c9 100644
--- a/src/libstore/make-content-addressed.cc
+++ b/src/libstore/make-content-addressed.cc
@@ -55,7 +55,7 @@ std::map<StorePath, StorePath> makeContentAddressed(
.method = FileIngestionMethod::Recursive,
.hash = narModuloHash,
},
- std::move(refs),
+ .references = std::move(refs),
},
},
Hash::dummy,
diff --git a/src/libstore/store-api.cc b/src/libstore/store-api.cc
index 592afebd8..4b89465e7 100644
--- a/src/libstore/store-api.cc
+++ b/src/libstore/store-api.cc
@@ -232,7 +232,7 @@ std::pair<StorePath, Hash> Store::computeStorePathForPath(std::string_view name,
.method = method,
.hash = h,
},
- {},
+ .references = {},
};
return std::make_pair(makeFixedOutputPath(name, caInfo), h);
}
@@ -442,7 +442,7 @@ ValidPathInfo Store::addToStoreSlow(std::string_view name, const Path & srcPath,
.method = method,
.hash = hash,
},
- {},
+ .references = {},
},
},
narHash,
@@ -1270,16 +1270,18 @@ std::optional<StorePathDescriptor> ValidPathInfo::fullStorePathDescriptorOpt() c
return StorePathDescriptor {
.name = std::string { path.name() },
.info = std::visit(overloaded {
- [&](const TextHash & th) {
- TextInfo info { th };
+ [&](const TextHash & th) -> ContentAddressWithReferences {
assert(!hasSelfReference);
- info.references = references;
- return ContentAddressWithReferences { info };
+ return TextInfo {
+ th,
+ .references = references,
+ };
},
- [&](const FixedOutputHash & foh) {
- FixedOutputInfo info { foh };
- info.references = static_cast<PathReferences<StorePath>>(*this);
- return ContentAddressWithReferences { info };
+ [&](const FixedOutputHash & foh) -> ContentAddressWithReferences {
+ return FixedOutputInfo {
+ foh,
+ .references = static_cast<PathReferences<StorePath>>(*this),
+ };
},
}, *ca),
};
diff --git a/src/nix-store/nix-store.cc b/src/nix-store/nix-store.cc
index 75fa08551..5cb5aa53a 100644
--- a/src/nix-store/nix-store.cc
+++ b/src/nix-store/nix-store.cc
@@ -220,7 +220,7 @@ static void opPrintFixedPath(Strings opFlags, Strings opArgs)
.method = method,
.hash = Hash::parseAny(hash, hashAlgo),
},
- {},
+ .references = {},
})));
}
diff --git a/src/nix/add-to-store.cc b/src/nix/add-to-store.cc
index c2494dc9f..0b58818c3 100644
--- a/src/nix/add-to-store.cc
+++ b/src/nix/add-to-store.cc
@@ -50,7 +50,7 @@ struct CmdAddToStore : MixDryRun, StoreCommand
.method = std::move(ingestionMethod),
.hash = std::move(hash),
},
- {},
+ .references = {},
},
},
narHash,
diff --git a/src/nix/prefetch.cc b/src/nix/prefetch.cc
index aa302efc1..df9933d29 100644
--- a/src/nix/prefetch.cc
+++ b/src/nix/prefetch.cc
@@ -72,7 +72,7 @@ std::tuple<StorePath, Hash> prefetchFile(
.method = ingestionMethod,
.hash = *expectedHash,
},
- {},
+ .references = {},
});
if (store->isValidPath(*storePath))
hash = expectedHash;
diff --git a/src/nix/profile.cc b/src/nix/profile.cc
index 024849e3b..614a37eba 100644
--- a/src/nix/profile.cc
+++ b/src/nix/profile.cc
@@ -205,7 +205,7 @@ struct ProfileManifest
.method = FileIngestionMethod::Recursive,
.hash = narHash,
},
- { references },
+ .references = { references },
},
},
narHash,