From 911fc88bcb467ff779c5d0ab49e0a5525f284e19 Mon Sep 17 00:00:00 2001 From: John Ericson Date: Fri, 19 Jun 2020 17:42:56 +0000 Subject: [PATCH] More designated initializers --- src/libfetchers/tarball.cc | 4 ++-- src/libstore/build.cc | 5 ++++- src/libstore/content-address.cc | 10 ++++++++-- src/libstore/local-store.cc | 2 +- src/nix/add-to-store.cc | 4 ++-- src/nix/make-content-addressable.cc | 4 ++-- 6 files changed, 19 insertions(+), 10 deletions(-) diff --git a/src/libfetchers/tarball.cc b/src/libfetchers/tarball.cc index da8d20d98..f5356f0af 100644 --- a/src/libfetchers/tarball.cc +++ b/src/libfetchers/tarball.cc @@ -71,8 +71,8 @@ DownloadFileResult downloadFile( info.narHash = hashString(htSHA256, *sink.s); info.narSize = sink.s->size(); info.ca = FixedOutputHash { - FileIngestionMethod::Flat, - hash, + .method = FileIngestionMethod::Flat, + .hash = hash, }; auto source = StringSource { *sink.s }; store->addToStore(info, source, NoRepair, NoCheckSigs); diff --git a/src/libstore/build.cc b/src/libstore/build.cc index 1126c186f..0c25897f8 100644 --- a/src/libstore/build.cc +++ b/src/libstore/build.cc @@ -3764,7 +3764,10 @@ void DerivationGoal::registerOutputs() else assert(worker.store.parseStorePath(path) == dest); - ca = FixedOutputHash { i.second.hash->method, h2 }; + ca = FixedOutputHash { + .method = i.second.hash->method, + .hash = h2, + }; } /* Get rid of all weird permissions. This also checks that diff --git a/src/libstore/content-address.cc b/src/libstore/content-address.cc index 98b3677bb..3d753836f 100644 --- a/src/libstore/content-address.cc +++ b/src/libstore/content-address.cc @@ -55,10 +55,16 @@ ContentAddress parseContentAddress(std::string_view rawCa) { auto methodAndHash = rawCa.substr(prefixSeparator+1, string::npos); if (methodAndHash.substr(0,2) == "r:") { std::string_view hashRaw = methodAndHash.substr(2,string::npos); - return FixedOutputHash { FileIngestionMethod::Recursive, Hash(string(hashRaw)) }; + return FixedOutputHash { + .method = FileIngestionMethod::Recursive, + .hash = Hash(string(hashRaw)), + }; } else { std::string_view hashRaw = methodAndHash; - return FixedOutputHash { FileIngestionMethod::Flat, Hash(string(hashRaw)) }; + return FixedOutputHash { + .method = FileIngestionMethod::Flat, + .hash = Hash(string(hashRaw)), + }; } } else { throw Error("parseContentAddress: format not recognized; has to be text or fixed"); diff --git a/src/libstore/local-store.cc b/src/libstore/local-store.cc index f9b2db2e3..0dfbed9fc 100644 --- a/src/libstore/local-store.cc +++ b/src/libstore/local-store.cc @@ -1079,7 +1079,7 @@ StorePath LocalStore::addToStoreFromDump(const string & dump, const string & nam ValidPathInfo info(dstPath); info.narHash = hash.first; info.narSize = hash.second; - info.ca = FixedOutputHash { method, h }; + info.ca = FixedOutputHash { .method = method, .hash = h }; registerValidPath(info); } diff --git a/src/nix/add-to-store.cc b/src/nix/add-to-store.cc index 6d90e93e8..f9d6de16e 100644 --- a/src/nix/add-to-store.cc +++ b/src/nix/add-to-store.cc @@ -49,8 +49,8 @@ struct CmdAddToStore : MixDryRun, StoreCommand info.narHash = narHash; info.narSize = sink.s->size(); info.ca = std::optional { FixedOutputHash { - FileIngestionMethod::Recursive, - info.narHash, + .method = FileIngestionMethod::Recursive, + .hash = info.narHash, } }; if (!dryRun) { diff --git a/src/nix/make-content-addressable.cc b/src/nix/make-content-addressable.cc index c506eabd8..fb36fc410 100644 --- a/src/nix/make-content-addressable.cc +++ b/src/nix/make-content-addressable.cc @@ -83,8 +83,8 @@ struct CmdMakeContentAddressable : StorePathsCommand, MixJSON info.narHash = narHash; info.narSize = sink.s->size(); info.ca = FixedOutputHash { - FileIngestionMethod::Recursive, - info.narHash, + .method = FileIngestionMethod::Recursive, + .hash = info.narHash, }; if (!json)