Skip to content

Fix compiler and linter warnings #406

Description

@DanRStevens

Building with Clang may emit the following warnings (when enabled by flags):

make show-warnings

make --output-sync all CXX=clang++ CXXFLAGS_WARN="-Weverything -Wno-c++98-compat-pedantic -Wno-pre-c++17-compat" 2>&1 >/dev/null | grep -o "[-W.*]" | sort | uniq
[-Wdeprecated-copy]
[-Wdeprecated-copy-with-dtor]
[-Wdeprecated-redundant-constexpr-static-def]
[-Wextra-semi]
[-Wimplicit-int-conversion]
[-Winconsistent-missing-destructor-override]
[-Wmissing-field-initializers]
[-Wold-style-cast]
[-Wpadded]
[-Wshadow]
[-Wshadow-field-in-constructor]
[-Wsign-conversion]
[-Wsigned-enum-bitfield]
[-Wunaligned-access]
[-Wundef]
[-Wunknown-pragmas]
[-Wunsafe-buffer-usage]
[-Wweak-vtables]


There are some cppclean warnings, though some may appear to be false positives:

make cppclean

cppclean --quiet "src"
src/Bitmap/BmpHeader.h:34: 'operator==' declared but not defined
src/Bitmap/BmpHeader.h:35: 'operator!=' declared but not defined
src/Bitmap/ImageHeader.h:101: 'operator==' declared but not defined
src/Bitmap/ImageHeader.h:102: 'operator!=' declared but not defined
src/Sprite/ArtFile.h:3: 'PaletteHeader.h' does not need to be #included
src/Sprite/ArtFile.h:6: '../Bitmap/Color.h' does not need to be #included
src/Sprite/ArtFile.h:7: '../Tag.h' does not need to be #included
src/Sprite/PaletteHeader.h:9: 'OP2Utility::Color' forward declared, but needs to be #included
src/Sprite/SpriteLoader.h:3: 'ArtFile.h' does not need to be #included; use a forward declaration instead


There are some cppcheck warnings about uninitialized values:

make cppcheck 

cppcheck --quiet "src"
src/Archive/VolFile.cpp:273:35: warning: Uninitialized variable: indexEntry.dataBlockOffset [uninitvar]
volInfo.indexEntries.push_back(indexEntry);
^
src/Archive/VolFile.cpp:273:35: error: Uninitialized struct member: indexEntry.dataBlockOffset [uninitStructMember]
volInfo.indexEntries.push_back(indexEntry);
^
src/Map/MapReader.cpp:151:3: error: Uninitialized variables: savedGameUnits.objectCount1, savedGameUnits.objectCount2, savedGameUnits.nextUnitIndex, savedGameUnits.prevUnitIndex [uninitvar]
savedGameUnits.CheckSizeOfUnit();
^
src/Archive/VolFile.cpp:239:3: error: Using argument volInfo that points at uninitialized variable volInfo [ctuuninitvar]
volInfo.fileStreamReaders.clear();
^
src/Archive/VolFile.cpp:254:20: note: Calling function OpenAllInputFiles, 1st argument is uninitialized
OpenAllInputFiles(volInfo, volumeFilename);
^
src/Archive/VolFile.cpp:239:3: note: Using argument volInfo
volInfo.fileStreamReaders.clear();
^


Related:

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions