Skip to content

Commit

Permalink
enabled and fixed -Wmissing-field-initializers GCC warnings (#6964)
Browse files Browse the repository at this point in the history
  • Loading branch information
firewave authored Oct 28, 2024
1 parent 55951dd commit 0794699
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 16 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ ifeq (clang++, $(findstring clang++,$(CXX)))
CPPCHK_GLIBCXX_DEBUG=
endif
ifndef CXXFLAGS
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
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
endif

ifeq (g++, $(findstring g++,$(CXX)))
Expand Down
1 change: 0 additions & 1 deletion cmake/compileroptions.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU" OR CMAKE_CXX_COMPILER_ID MATCHES "Clang"
add_compile_options(-Wpacked) #
add_compile_options(-Wredundant-decls) # if anything is declared more than once in the same scope
add_compile_options(-Wundef)
add_compile_options(-Wno-missing-field-initializers)
add_compile_options(-Wno-missing-braces)
add_compile_options(-Wno-sign-compare)
add_compile_options(-Wno-multichar)
Expand Down
6 changes: 3 additions & 3 deletions lib/library.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,7 @@ Library::Error Library::load(const tinyxml2::XMLDocument &doc)
const std::string memorynodename = memorynode->Name();
const auto names = getnames(memorynode->GetText());
if (memorynodename == "alloc" || memorynodename == "realloc") {
AllocFunc temp = {0};
AllocFunc temp;
temp.groupId = allocationId;

temp.initData = memorynode->BoolAttribute("init", true);
Expand Down Expand Up @@ -396,7 +396,7 @@ Library::Error Library::load(const tinyxml2::XMLDocument &doc)
for (const auto& n : names)
map[n] = temp;
} else if (memorynodename == "dealloc") {
AllocFunc temp = {0};
AllocFunc temp;
temp.groupId = allocationId;
temp.arg = memorynode->IntAttribute("arg", 1);
for (const auto& n : names)
Expand Down Expand Up @@ -689,7 +689,7 @@ Library::Error Library::load(const tinyxml2::XMLDocument &doc)
const char * const name = node->Attribute("name");
if (!name)
return Error(ErrorCode::MISSING_ATTRIBUTE, "name");
PodType podType = {0};
PodType podType;
podType.stdtype = PodType::Type::NO;
const char * const stdtype = node->Attribute("stdtype");
if (stdtype) {
Expand Down
20 changes: 10 additions & 10 deletions lib/library.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,14 +78,14 @@ class CPPCHECKLIB Library {
Error load(const char exename[], const char path[], bool debug = false);

struct AllocFunc {
int groupId;
int arg;
int groupId{};
int arg{};
enum class BufferSize : std::uint8_t {none,malloc,calloc,strdup};
BufferSize bufferSize;
int bufferSizeArg1;
int bufferSizeArg2;
int reallocArg;
bool initData;
BufferSize bufferSize{BufferSize::none};
int bufferSizeArg1{};
int bufferSizeArg2{};
int reallocArg{};
bool initData{};
};

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

struct PodType {
unsigned int size;
char sign;
enum class Type : std::uint8_t { NO, BOOL, CHAR, SHORT, INT, LONG, LONGLONG } stdtype;
unsigned int size{};
char sign{};
enum class Type : std::uint8_t { NO, BOOL, CHAR, SHORT, INT, LONG, LONGLONG } stdtype = Type::NO;
};
const PodType *podtype(const std::string &name) const;

Expand Down
1 change: 0 additions & 1 deletion tools/dmake/dmake.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -716,7 +716,6 @@ int main(int argc, char **argv)
"-Wredundant-decls "
"-Wundef "
"-Wno-shadow "
"-Wno-missing-field-initializers "
"-Wno-missing-braces "
"-Wno-sign-compare "
"-Wno-multichar "
Expand Down

0 comments on commit 0794699

Please sign in to comment.