Add missing-field-initialization warning flag (#1113)

This commit is contained in:
andrejtonev 2023-07-29 17:59:11 +02:00 committed by GitHub
parent 110ca3968c
commit 58c0c4cebb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 51 additions and 41 deletions

View File

@ -196,7 +196,7 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall \
-Werror=switch -Werror=switch-bool -Werror=return-type \
-Werror=return-stack-address \
-Wno-c99-designator \
-Wno-c99-designator -Wmissing-field-initializers \
-DBOOST_ASIO_USE_TS_EXECUTOR_AS_DEFAULT")
# Don't omit frame pointer in RelWithDebInfo, for additional callchain debug.

View File

@ -1,4 +1,4 @@
// Copyright 2022 Memgraph Ltd.
// Copyright 2023 Memgraph Ltd.
//
// Use of this software is governed by the Business Source License
// included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source
@ -86,8 +86,8 @@ struct ConsumerInfo {
std::string bootstrap_servers;
std::chrono::milliseconds batch_interval;
int64_t batch_size;
std::unordered_map<std::string, std::string> public_configs;
std::unordered_map<std::string, std::string> private_configs;
std::unordered_map<std::string, std::string> public_configs{};
std::unordered_map<std::string, std::string> private_configs{};
};
/// Memgraphs Kafka consumer wrapper.

View File

@ -43,14 +43,14 @@ struct EvaluationContext {
/// it as if the lifetime is only valid during the Pull.
utils::MemoryResource *memory{utils::NewDeleteResource()};
int64_t timestamp{-1};
Parameters parameters;
Parameters parameters{};
/// All properties indexable via PropertyIx
std::vector<storage::PropertyId> properties;
std::vector<storage::PropertyId> properties{};
/// All labels indexable via LabelIx
std::vector<storage::LabelId> labels;
std::vector<storage::LabelId> labels{};
/// All counters generated by `counter` function, mutable because the function
/// modifies the values
mutable std::unordered_map<std::string, int64_t> counters;
mutable std::unordered_map<std::string, int64_t> counters{};
};
inline std::vector<storage::PropertyId> NamesToProperties(const std::vector<std::string> &property_names,

View File

@ -270,15 +270,15 @@ struct FilterInfo {
/// The original filter expression which must be satisfied.
Expression *expression;
/// Set of used symbols by the filter @c expression.
std::unordered_set<Symbol> used_symbols;
std::unordered_set<Symbol> used_symbols{};
/// Labels for Type::Label filtering.
std::vector<LabelIx> labels;
std::vector<LabelIx> labels{};
/// Property information for Type::Property filtering.
std::optional<PropertyFilter> property_filter;
std::optional<PropertyFilter> property_filter{};
/// Information for Type::Id filtering.
std::optional<IdFilter> id_filter;
std::optional<IdFilter> id_filter{};
/// Matchings for filters that include patterns
std::vector<FilterMatching> matchings;
std::vector<FilterMatching> matchings{};
};
/// Stores information on filters used inside the @c Matching of a @c QueryPart.

View File

@ -218,7 +218,7 @@ static PyMethodDef PyVerticesIteratorMethods[] = {
"Get the current vertex pointed to by the iterator or return None."},
{"next", reinterpret_cast<PyCFunction>(PyVerticesIteratorNext), METH_NOARGS,
"Advance the iterator to the next vertex and return it."},
{nullptr},
{nullptr, {}, {}, {}},
};
// clang-format off
@ -290,7 +290,7 @@ static PyMethodDef PyEdgesIteratorMethods[] = {
"Get the current edge pointed to by the iterator or return None."},
{"next", reinterpret_cast<PyCFunction>(PyEdgesIteratorNext), METH_NOARGS,
"Advance the iterator to the next edge and return it."},
{nullptr},
{nullptr, {}, {}, {}},
};
// clang-format off
@ -406,7 +406,7 @@ static PyMethodDef PyGraphMethods[] = {
{"iter_vertices", reinterpret_cast<PyCFunction>(PyGraphIterVertices), METH_NOARGS, "Return _mgp.VerticesIterator."},
{"must_abort", reinterpret_cast<PyCFunction>(PyGraphMustAbort), METH_NOARGS,
"Check whether the running procedure should abort"},
{nullptr},
{nullptr, {}, {}, {}},
};
// clang-format off
@ -560,7 +560,7 @@ static PyMethodDef PyQueryProcMethods[] = {
"Add a result field to a procedure."},
{"add_deprecated_result", reinterpret_cast<PyCFunction>(PyQueryProcAddDeprecatedResult), METH_VARARGS,
"Add a result field to a procedure and mark it as deprecated."},
{nullptr},
{nullptr, {}, {}, {}},
};
// clang-format off
@ -585,7 +585,7 @@ static PyMethodDef PyMagicFuncMethods[] = {
"Add a required argument to a function."},
{"add_opt_arg", reinterpret_cast<PyCFunction>(PyMagicFuncAddOptArg), METH_VARARGS,
"Add an optional argument with a default value to a function."},
{nullptr},
{nullptr, {}, {}, {}},
};
// clang-format off
@ -737,7 +737,7 @@ static PyMethodDef PyMessageMethods[] = {
{"key", reinterpret_cast<PyCFunction>(PyMessageGetKey), METH_NOARGS, "Get message key."},
{"timestamp", reinterpret_cast<PyCFunction>(PyMessageGetTimestamp), METH_NOARGS, "Get message timestamp."},
{"offset", reinterpret_cast<PyCFunction>(PyMessageGetOffset), METH_NOARGS, "Get message offset."},
{nullptr},
{nullptr, {}, {}, {}},
};
void PyMessageDealloc(PyMessage *self) {
@ -816,7 +816,7 @@ static PyMethodDef PyMessagesMethods[] = {
"Get number of messages available"},
{"message_at", reinterpret_cast<PyCFunction>(PyMessagesGetMessageAt), METH_VARARGS,
"Get message at index idx from messages"},
{nullptr},
{nullptr, {}, {}, {}},
};
// NOLINTNEXTLINE
@ -1372,7 +1372,7 @@ static PyMethodDef PyQueryModuleMethods[] = {
"Register a transformation with this module."},
{"add_function", reinterpret_cast<PyCFunction>(PyQueryModuleAddFunction), METH_O,
"Register a function with this module."},
{nullptr},
{nullptr, {}, {}, {}},
};
// clang-format off
@ -1466,7 +1466,7 @@ static PyMethodDef PyMgpModuleMethods[] = {
{"type_local_time", PyMgpModuleTypeLocalTime, METH_NOARGS, "Get the type representing a LocalTime."},
{"type_local_date_time", PyMgpModuleTypeLocalDateTime, METH_NOARGS, "Get the type representing a LocalDateTime."},
{"type_duration", PyMgpModuleTypeDuration, METH_NOARGS, "Get the type representing a Duration."},
{nullptr},
{nullptr, {}, {}, {}},
};
// clang-format off
@ -1541,7 +1541,7 @@ static PyMethodDef PyPropertiesIteratorMethods[] = {
"Get the current proprety pointed to by the iterator or return None."},
{"next", reinterpret_cast<PyCFunction>(PyPropertiesIteratorNext), METH_NOARGS,
"Advance the iterator to the next property and return it."},
{nullptr},
{nullptr, {}, {}, {}},
};
// clang-format off
@ -1699,7 +1699,7 @@ static PyMethodDef PyEdgeMethods[] = {
"Return edge property with given name."},
{"set_property", reinterpret_cast<PyCFunction>(PyEdgeSetProperty), METH_VARARGS,
"Set the value of the property on the edge."},
{nullptr},
{nullptr, {}, {}, {}},
};
PyObject *PyEdgeRichCompare(PyObject *self, PyObject *other, int op);
@ -1987,7 +1987,7 @@ static PyMethodDef PyVertexMethods[] = {
"Return vertex property with given name."},
{"set_property", reinterpret_cast<PyCFunction>(PyVertexSetProperty), METH_VARARGS,
"Set the value of the property on the vertex."},
{nullptr},
{nullptr, {}, {}, {}},
};
PyObject *PyVertexRichCompare(PyObject *self, PyObject *other, int op);
@ -2141,7 +2141,7 @@ static PyMethodDef PyPathMethods[] = {
"Return the vertex from a path at given index."},
{"edge_at", reinterpret_cast<PyCFunction>(PyPathEdgeAt), METH_VARARGS,
"Return the edge from a path at given index."},
{nullptr},
{nullptr, {}, {}, {}},
};
// clang-format off
@ -2259,7 +2259,7 @@ static PyMethodDef PyLoggerMethods[] = {
"Logs a message with level TRACE on this logger."},
{"debug", reinterpret_cast<PyCFunction>(PyLoggerLogDebug), METH_VARARGS,
"Logs a message with level DEBUG on this logger."},
{nullptr},
{nullptr, {}, {}, {}},
};
// clang-format off

View File

@ -138,7 +138,8 @@ static void Distinct(benchmark::State &state) {
TMemory per_pull_memory;
memgraph::query::EvaluationContext evaluation_context{per_pull_memory.get()};
while (state.KeepRunning()) {
memgraph::query::ExecutionContext execution_context{&dba, symbol_table, evaluation_context};
memgraph::query::ExecutionContext execution_context{
.db_accessor = &dba, .symbol_table = symbol_table, .evaluation_context = evaluation_context};
TMemory memory;
memgraph::query::Frame frame(symbol_table.max_position(), memory.get());
auto cursor = plan_and_cost.first->MakeCursor(memory.get());
@ -184,7 +185,8 @@ static void ExpandVariable(benchmark::State &state) {
TMemory per_pull_memory;
memgraph::query::EvaluationContext evaluation_context{per_pull_memory.get()};
while (state.KeepRunning()) {
memgraph::query::ExecutionContext execution_context{&dba, symbol_table, evaluation_context};
memgraph::query::ExecutionContext execution_context{
.db_accessor = &dba, .symbol_table = symbol_table, .evaluation_context = evaluation_context};
TMemory memory;
memgraph::query::Frame frame(symbol_table.max_position(), memory.get());
auto cursor = expand_variable.MakeCursor(memory.get());
@ -223,7 +225,8 @@ static void ExpandBfs(benchmark::State &state) {
TMemory per_pull_memory;
memgraph::query::EvaluationContext evaluation_context{per_pull_memory.get()};
while (state.KeepRunning()) {
memgraph::query::ExecutionContext execution_context{&dba, symbol_table, evaluation_context};
memgraph::query::ExecutionContext execution_context{
.db_accessor = &dba, .symbol_table = symbol_table, .evaluation_context = evaluation_context};
TMemory memory;
memgraph::query::Frame frame(symbol_table.max_position(), memory.get());
auto cursor = expand_variable.MakeCursor(memory.get());
@ -258,7 +261,8 @@ static void ExpandShortest(benchmark::State &state) {
TMemory per_pull_memory;
memgraph::query::EvaluationContext evaluation_context{per_pull_memory.get()};
while (state.KeepRunning()) {
memgraph::query::ExecutionContext execution_context{&dba, symbol_table, evaluation_context};
memgraph::query::ExecutionContext execution_context{
.db_accessor = &dba, .symbol_table = symbol_table, .evaluation_context = evaluation_context};
TMemory memory;
memgraph::query::Frame frame(symbol_table.max_position(), memory.get());
auto cursor = expand_variable.MakeCursor(memory.get());
@ -299,7 +303,8 @@ static void ExpandWeightedShortest(benchmark::State &state) {
TMemory per_pull_memory;
memgraph::query::EvaluationContext evaluation_context{per_pull_memory.get()};
while (state.KeepRunning()) {
memgraph::query::ExecutionContext execution_context{&dba, symbol_table, evaluation_context};
memgraph::query::ExecutionContext execution_context{
.db_accessor = &dba, .symbol_table = symbol_table, .evaluation_context = evaluation_context};
TMemory memory;
memgraph::query::Frame frame(symbol_table.max_position(), memory.get());
auto cursor = expand_variable.MakeCursor(memory.get());
@ -344,7 +349,8 @@ static void Accumulate(benchmark::State &state) {
TMemory per_pull_memory;
memgraph::query::EvaluationContext evaluation_context{per_pull_memory.get()};
while (state.KeepRunning()) {
memgraph::query::ExecutionContext execution_context{&dba, symbol_table, evaluation_context};
memgraph::query::ExecutionContext execution_context{
.db_accessor = &dba, .symbol_table = symbol_table, .evaluation_context = evaluation_context};
TMemory memory;
memgraph::query::Frame frame(symbol_table.max_position(), memory.get());
auto cursor = accumulate.MakeCursor(memory.get());
@ -393,7 +399,8 @@ static void Aggregate(benchmark::State &state) {
TMemory per_pull_memory;
memgraph::query::EvaluationContext evaluation_context{per_pull_memory.get()};
while (state.KeepRunning()) {
memgraph::query::ExecutionContext execution_context{&dba, symbol_table, evaluation_context};
memgraph::query::ExecutionContext execution_context{
.db_accessor = &dba, .symbol_table = symbol_table, .evaluation_context = evaluation_context};
TMemory memory;
memgraph::query::Frame frame(symbol_table.max_position(), memory.get());
auto cursor = aggregate.MakeCursor(memory.get());
@ -443,7 +450,8 @@ static void OrderBy(benchmark::State &state) {
TMemory per_pull_memory;
memgraph::query::EvaluationContext evaluation_context{per_pull_memory.get()};
while (state.KeepRunning()) {
memgraph::query::ExecutionContext execution_context{&dba, symbol_table, evaluation_context};
memgraph::query::ExecutionContext execution_context{
.db_accessor = &dba, .symbol_table = symbol_table, .evaluation_context = evaluation_context};
TMemory memory;
memgraph::query::Frame frame(symbol_table.max_position(), memory.get());
auto cursor = order_by.MakeCursor(memory.get());
@ -481,7 +489,8 @@ static void Unwind(benchmark::State &state) {
TMemory per_pull_memory;
memgraph::query::EvaluationContext evaluation_context{per_pull_memory.get()};
while (state.KeepRunning()) {
memgraph::query::ExecutionContext execution_context{&dba, symbol_table, evaluation_context};
memgraph::query::ExecutionContext execution_context{
.db_accessor = &dba, .symbol_table = symbol_table, .evaluation_context = evaluation_context};
TMemory memory;
memgraph::query::Frame frame(symbol_table.max_position(), memory.get());
frame[list_sym] = memgraph::query::TypedValue(std::vector<memgraph::query::TypedValue>(state.range(1)));
@ -517,7 +526,8 @@ static void Foreach(benchmark::State &state) {
TMemory per_pull_memory;
memgraph::query::EvaluationContext evaluation_context{per_pull_memory.get()};
while (state.KeepRunning()) {
memgraph::query::ExecutionContext execution_context{&dba, symbol_table, evaluation_context};
memgraph::query::ExecutionContext execution_context{
.db_accessor = &dba, .symbol_table = symbol_table, .evaluation_context = evaluation_context};
TMemory memory;
memgraph::query::Frame frame(symbol_table.max_position(), memory.get());
frame[list_sym] = memgraph::query::TypedValue(std::vector<memgraph::query::TypedValue>(state.range(1)));

View File

@ -294,7 +294,7 @@ class Database {
std::vector<std::string> edge_types, bool known_sink, FilterLambdaType filter_lambda_type) {
auto storage_dba = db->Access();
memgraph::query::DbAccessor dba(storage_dba.get());
memgraph::query::ExecutionContext context{&dba};
memgraph::query::ExecutionContext context{.db_accessor = &dba};
memgraph::query::Symbol blocked_sym = context.symbol_table.CreateSymbol("blocked", true);
memgraph::query::Symbol source_sym = context.symbol_table.CreateSymbol("source", true);
memgraph::query::Symbol sink_sym = context.symbol_table.CreateSymbol("sink", true);
@ -458,7 +458,7 @@ class Database {
FineGrainedTestType fine_grained_test_type) {
auto storage_dba = db->Access();
memgraph::query::DbAccessor db_accessor(storage_dba.get());
memgraph::query::ExecutionContext context{&db_accessor};
memgraph::query::ExecutionContext context{.db_accessor = &db_accessor};
memgraph::query::Symbol blocked_symbol = context.symbol_table.CreateSymbol("blocked", true);
memgraph::query::Symbol source_symbol = context.symbol_table.CreateSymbol("source", true);
memgraph::query::Symbol sink_symbol = context.symbol_table.CreateSymbol("sink", true);

View File

@ -35,7 +35,7 @@ using Bound = ScanAllByLabelPropertyRange::Bound;
ExecutionContext MakeContext(const AstStorage &storage, const SymbolTable &symbol_table,
memgraph::query::DbAccessor *dba) {
ExecutionContext context{dba};
ExecutionContext context{.db_accessor = dba};
context.symbol_table = symbol_table;
context.evaluation_context.properties = NamesToProperties(storage.properties_, dba);
context.evaluation_context.labels = NamesToLabels(storage.labels_, dba);
@ -45,7 +45,7 @@ ExecutionContext MakeContext(const AstStorage &storage, const SymbolTable &symbo
ExecutionContext MakeContextWithFineGrainedChecker(const AstStorage &storage, const SymbolTable &symbol_table,
memgraph::query::DbAccessor *dba,
memgraph::glue::FineGrainedAuthChecker *auth_checker) {
ExecutionContext context{dba};
ExecutionContext context{.db_accessor = dba};
context.symbol_table = symbol_table;
context.evaluation_context.properties = NamesToProperties(storage.properties_, dba);
context.evaluation_context.labels = NamesToLabels(storage.labels_, dba);