aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLulu <lulu.berlin.2023@gmail.com>2024-10-06 22:10:40 +0200
committerLulu <lulu.berlin.2023@gmail.com>2024-10-08 01:44:38 +0000
commit43e79f443469c55ef4d3a43ce1e455d6eafcd26c (patch)
tree86e67212f01f1cf18c05b75b4321ffac6b620a1e /src
parent299813f324c9562b0bd6d0bc5d2114776e193d86 (diff)
Fix gcc warning -Wmissing-field-initializers
The approach that was taken here was to add default values to the type definitions rather than specify them whenever they are missing. Now the only remaining warning is '-Wunused-parameter' which @jade said is usually counterproductive and that we can just disable it: https://git.lix.systems/lix-project/lix/issues/456#issuecomment-6617 So this change adds the flags '-Wall', '-Wextra' and '-Wno-unused-parameter', so that all warnings are enabled except for '-Wunused-parameter'. Change-Id: Ic223a964d67ab429e8da804c0721ba5e25d53012
Diffstat (limited to 'src')
-rw-r--r--src/libexpr/parser/state.hh2
-rw-r--r--src/libstore/build-result.hh4
-rw-r--r--src/libstore/build/derivation-goal.hh2
-rw-r--r--src/libstore/build/goal.hh4
-rw-r--r--src/libstore/nar-accessor.cc4
-rw-r--r--src/libstore/path-with-outputs.hh2
-rw-r--r--src/libstore/realisation.hh4
-rw-r--r--src/libstore/store-api.cc2
-rw-r--r--src/libutil/error.hh6
-rw-r--r--src/libutil/processes.hh10
10 files changed, 20 insertions, 20 deletions
diff --git a/src/libexpr/parser/state.hh b/src/libexpr/parser/state.hh
index 1d57e2f5f..3b9b90b94 100644
--- a/src/libexpr/parser/state.hh
+++ b/src/libexpr/parser/state.hh
@@ -9,7 +9,7 @@ namespace nix::parser {
struct StringToken
{
std::string_view s;
- bool hasIndentation;
+ bool hasIndentation = false;
operator std::string_view() const { return s; }
};
diff --git a/src/libstore/build-result.hh b/src/libstore/build-result.hh
index 9634fb944..846c6c9b9 100644
--- a/src/libstore/build-result.hh
+++ b/src/libstore/build-result.hh
@@ -47,7 +47,7 @@ struct BuildResult
* @todo This should be an entire ErrorInfo object, not just a
* string, for richer information.
*/
- std::string errorMsg;
+ std::string errorMsg = {};
std::string toString() const {
auto strStatus = [&]() {
@@ -90,7 +90,7 @@ struct BuildResult
* For derivations, a mapping from the names of the wanted outputs
* to actual paths.
*/
- SingleDrvOutputs builtOutputs;
+ SingleDrvOutputs builtOutputs = {};
/**
* The start/stop times of the build (or one of the rounds, if it
diff --git a/src/libstore/build/derivation-goal.hh b/src/libstore/build/derivation-goal.hh
index 3885afe4a..6dd58afd2 100644
--- a/src/libstore/build/derivation-goal.hh
+++ b/src/libstore/build/derivation-goal.hh
@@ -63,7 +63,7 @@ struct InitialOutputStatus {
struct InitialOutput {
bool wanted;
Hash outputHash;
- std::optional<InitialOutputStatus> known;
+ std::optional<InitialOutputStatus> known = {};
};
/**
diff --git a/src/libstore/build/goal.hh b/src/libstore/build/goal.hh
index de1c92c85..29540dcd3 100644
--- a/src/libstore/build/goal.hh
+++ b/src/libstore/build/goal.hh
@@ -88,8 +88,8 @@ protected:
public:
struct [[nodiscard]] WorkResult {
ExitCode exitCode;
- BuildResult result;
- std::shared_ptr<Error> ex;
+ BuildResult result = {};
+ std::shared_ptr<Error> ex = {};
bool permanentFailure = false;
bool timedOut = false;
bool hashMismatch = false;
diff --git a/src/libstore/nar-accessor.cc b/src/libstore/nar-accessor.cc
index 7600de6e7..f228004a9 100644
--- a/src/libstore/nar-accessor.cc
+++ b/src/libstore/nar-accessor.cc
@@ -20,10 +20,10 @@ struct NarMember
file in the NAR. */
uint64_t start = 0, size = 0;
- std::string target;
+ std::string target = {};
/* If this is a directory, all the children of the directory. */
- std::map<std::string, NarMember> children;
+ std::map<std::string, NarMember> children = {};
};
struct NarAccessor : public FSAccessor
diff --git a/src/libstore/path-with-outputs.hh b/src/libstore/path-with-outputs.hh
index 57e03252d..8e2da1908 100644
--- a/src/libstore/path-with-outputs.hh
+++ b/src/libstore/path-with-outputs.hh
@@ -17,7 +17,7 @@ namespace nix {
struct StorePathWithOutputs
{
StorePath path;
- std::set<std::string> outputs;
+ std::set<std::string> outputs = {};
std::string to_string(const Store & store) const;
diff --git a/src/libstore/realisation.hh b/src/libstore/realisation.hh
index f2b228fa0..baeb7a2c9 100644
--- a/src/libstore/realisation.hh
+++ b/src/libstore/realisation.hh
@@ -50,7 +50,7 @@ struct Realisation {
DrvOutput id;
StorePath outPath;
- StringSet signatures;
+ StringSet signatures = {};
/**
* The realisations that are required for the current one to be valid.
@@ -58,7 +58,7 @@ struct Realisation {
* When importing this realisation, the store will first check that all its
* dependencies exist, and map to the correct output path
*/
- std::map<DrvOutput, StorePath> dependentRealisations;
+ std::map<DrvOutput, StorePath> dependentRealisations = {};
nlohmann::json toJSON() const;
static Realisation fromJSON(const nlohmann::json& json, const std::string& whence);
diff --git a/src/libstore/store-api.cc b/src/libstore/store-api.cc
index d35a0e6a1..18f80eef8 100644
--- a/src/libstore/store-api.cc
+++ b/src/libstore/store-api.cc
@@ -829,7 +829,7 @@ StorePathSet Store::queryValidPaths(const StorePathSet & paths, SubstituteFlag m
{
size_t left;
StorePathSet valid;
- std::exception_ptr exc;
+ std::exception_ptr exc = {};
};
Sync<State> state_(State{paths.size(), StorePathSet()});
diff --git a/src/libutil/error.hh b/src/libutil/error.hh
index 4eff2c2bc..885a2b218 100644
--- a/src/libutil/error.hh
+++ b/src/libutil/error.hh
@@ -70,17 +70,17 @@ inline bool operator<=(const Trace& lhs, const Trace& rhs);
inline bool operator>=(const Trace& lhs, const Trace& rhs);
struct ErrorInfo {
- Verbosity level;
+ Verbosity level = Verbosity::lvlError;
HintFmt msg;
std::shared_ptr<Pos> pos;
- std::list<Trace> traces;
+ std::list<Trace> traces = {};
/**
* Exit status.
*/
unsigned int status = 1;
- Suggestions suggestions;
+ Suggestions suggestions = {};
static std::optional<std::string> programName;
};
diff --git a/src/libutil/processes.hh b/src/libutil/processes.hh
index dc09a9ba4..dd6e2978e 100644
--- a/src/libutil/processes.hh
+++ b/src/libutil/processes.hh
@@ -78,11 +78,11 @@ struct RunOptions
{
Path program;
bool searchPath = true;
- Strings args;
- std::optional<uid_t> uid;
- std::optional<uid_t> gid;
- std::optional<Path> chdir;
- std::optional<std::map<std::string, std::string>> environment;
+ Strings args = {};
+ std::optional<uid_t> uid = {};
+ std::optional<uid_t> gid = {};
+ std::optional<Path> chdir = {};
+ std::optional<std::map<std::string, std::string>> environment = {};
bool captureStdout = false;
bool mergeStderrToStdout = false;
bool isInteractive = false;