Skip to content

Commit 0794699

Browse files
authored
enabled and fixed -Wmissing-field-initializers GCC warnings (#6964)
1 parent 55951dd commit 0794699

File tree

5 files changed

+14
-16
lines changed

5 files changed

+14
-16
lines changed

Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ ifeq (clang++, $(findstring clang++,$(CXX)))
136136
CPPCHK_GLIBCXX_DEBUG=
137137
endif
138138
ifndef CXXFLAGS
139-
CXXFLAGS=-pedantic -Wall -Wextra -Wcast-qual -Wfloat-equal -Wmissing-declarations -Wmissing-format-attribute -Wno-long-long -Wpacked -Wredundant-decls -Wundef -Wno-shadow -Wno-missing-field-initializers -Wno-missing-braces -Wno-sign-compare -Wno-multichar -Woverloaded-virtual $(CPPCHK_GLIBCXX_DEBUG) -g
139+
CXXFLAGS=-pedantic -Wall -Wextra -Wcast-qual -Wfloat-equal -Wmissing-declarations -Wmissing-format-attribute -Wno-long-long -Wpacked -Wredundant-decls -Wundef -Wno-shadow -Wno-missing-braces -Wno-sign-compare -Wno-multichar -Woverloaded-virtual $(CPPCHK_GLIBCXX_DEBUG) -g
140140
endif
141141

142142
ifeq (g++, $(findstring g++,$(CXX)))

cmake/compileroptions.cmake

-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU" OR CMAKE_CXX_COMPILER_ID MATCHES "Clang"
4747
add_compile_options(-Wpacked) #
4848
add_compile_options(-Wredundant-decls) # if anything is declared more than once in the same scope
4949
add_compile_options(-Wundef)
50-
add_compile_options(-Wno-missing-field-initializers)
5150
add_compile_options(-Wno-missing-braces)
5251
add_compile_options(-Wno-sign-compare)
5352
add_compile_options(-Wno-multichar)

lib/library.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -359,7 +359,7 @@ Library::Error Library::load(const tinyxml2::XMLDocument &doc)
359359
const std::string memorynodename = memorynode->Name();
360360
const auto names = getnames(memorynode->GetText());
361361
if (memorynodename == "alloc" || memorynodename == "realloc") {
362-
AllocFunc temp = {0};
362+
AllocFunc temp;
363363
temp.groupId = allocationId;
364364

365365
temp.initData = memorynode->BoolAttribute("init", true);
@@ -396,7 +396,7 @@ Library::Error Library::load(const tinyxml2::XMLDocument &doc)
396396
for (const auto& n : names)
397397
map[n] = temp;
398398
} else if (memorynodename == "dealloc") {
399-
AllocFunc temp = {0};
399+
AllocFunc temp;
400400
temp.groupId = allocationId;
401401
temp.arg = memorynode->IntAttribute("arg", 1);
402402
for (const auto& n : names)
@@ -689,7 +689,7 @@ Library::Error Library::load(const tinyxml2::XMLDocument &doc)
689689
const char * const name = node->Attribute("name");
690690
if (!name)
691691
return Error(ErrorCode::MISSING_ATTRIBUTE, "name");
692-
PodType podType = {0};
692+
PodType podType;
693693
podType.stdtype = PodType::Type::NO;
694694
const char * const stdtype = node->Attribute("stdtype");
695695
if (stdtype) {

lib/library.h

+10-10
Original file line numberDiff line numberDiff line change
@@ -78,14 +78,14 @@ class CPPCHECKLIB Library {
7878
Error load(const char exename[], const char path[], bool debug = false);
7979

8080
struct AllocFunc {
81-
int groupId;
82-
int arg;
81+
int groupId{};
82+
int arg{};
8383
enum class BufferSize : std::uint8_t {none,malloc,calloc,strdup};
84-
BufferSize bufferSize;
85-
int bufferSizeArg1;
86-
int bufferSizeArg2;
87-
int reallocArg;
88-
bool initData;
84+
BufferSize bufferSize{BufferSize::none};
85+
int bufferSizeArg1{};
86+
int bufferSizeArg2{};
87+
int reallocArg{};
88+
bool initData{};
8989
};
9090

9191
/** get allocation info for function */
@@ -416,9 +416,9 @@ class CPPCHECKLIB Library {
416416
const SmartPointer* detectSmartPointer(const Token* tok, bool withoutStd = false) const;
417417

418418
struct PodType {
419-
unsigned int size;
420-
char sign;
421-
enum class Type : std::uint8_t { NO, BOOL, CHAR, SHORT, INT, LONG, LONGLONG } stdtype;
419+
unsigned int size{};
420+
char sign{};
421+
enum class Type : std::uint8_t { NO, BOOL, CHAR, SHORT, INT, LONG, LONGLONG } stdtype = Type::NO;
422422
};
423423
const PodType *podtype(const std::string &name) const;
424424

tools/dmake/dmake.cpp

-1
Original file line numberDiff line numberDiff line change
@@ -716,7 +716,6 @@ int main(int argc, char **argv)
716716
"-Wredundant-decls "
717717
"-Wundef "
718718
"-Wno-shadow "
719-
"-Wno-missing-field-initializers "
720719
"-Wno-missing-braces "
721720
"-Wno-sign-compare "
722721
"-Wno-multichar "

0 commit comments

Comments
 (0)