Bläddra i källkod

New compiler warnings

Kajetan Johannes Hammerle 3 månader sedan
förälder
incheckning
ce18e12f82

+ 81 - 76
CMakeLists.txt

@@ -66,96 +66,101 @@ set(SRC_PERFORMANCE
 add_library(core STATIC ${SRC})
 target_include_directories(core PUBLIC ".")
 target_compile_options(core PUBLIC
-    -Wdeprecated-enum-float-conversion
-    -Wctad-maybe-unsupported
-    -Werror
-    -Wdeprecated-enum-enum-conversion
-    -Winvalid-imported-macros
-    -Wextra
-    -Wzero-as-null-pointer-constant
-    -Wframe-larger-than=8388608
-    -Wundef
-    -Wunused-const-variable=2
-    -Wconditionally-supported
-    -Wwrite-strings
-    -Wlarger-than=1073741824
-    -Wimplicit-fallthrough=5
-    -Wduplicated-cond
-    -Wdisabled-optimization
-    -Wsuggest-final-methods
-    -Wformat-signedness
-    -Wtrivial-auto-var-init
-    -Wmissing-include-dirs
-    -Winfinite-recursion
-    -Wdeprecated-copy-dtor
+    -fdiagnostics-color=always
+    -fno-exceptions
+    -fno-rtti
+    -fno-threadsafe-statics
+    -nostdinc++
+    -pedantic
+    -pedantic-errors
+    -Waligned-new=all
+    -Wall
+    -Walloca
+    -Walloc-zero
     -Wanalyzer-too-complex
-    -Wduplicated-branches
-    -Wstrict-null-sentinel
-    -Wmissing-declarations
-    -Wformat-truncation=2
-    -Wmultiple-inheritance
-    -Wstack-usage=8388608
-    -Winit-self
-    -Wsynth
-    -Wvirtual-inheritance
-    -Wstringop-overflow=4
+    -Warith-conversion
+    -Warray-bounds=2
+    -Warray-parameter
+    -Wattribute-alias=2
+    -Wbidi-chars=any
+    -Wcast-align=strict
     -Wcast-qual
-    -Wshadow
-    -Wsuggest-final-types
-    -Woverloaded-virtual
+    -Wcatch-value=3
+    -Wcomma-subscript
+    -Wconditionally-supported
     -Wconversion
-    -Walloca
-    -Woverlength-strings
+    -Wctad-maybe-unsupported
     -Wctor-dtor-privacy
-    -Wswitch-enum
-    -pedantic
-    -Wstrict-overflow=2
-    -Wcast-align=strict
+    -Wdate-time
+    -Wdeprecated-copy-dtor
+    -Wdeprecated-enum-enum-conversion
+    -Wdeprecated-enum-float-conversion
+    -Wdisabled-optimization
+    -Wdouble-promotion
+    -Wduplicated-branches
+    -Wduplicated-cond
+    -Weffc++
+    -Wenum-compare
+    -Wenum-conversion
+    -Werror
+    -Wextra
+    -Wextra-semi
     -Wfloat-equal
     -Wformat=2
-    -Wattribute-alias=2
     -Wformat-overflow=2
+    -Wformat-signedness
+    -Wformat-truncation=2
+    -Wframe-larger-than=8388608
+    -Wimplicit-fallthrough=5
+    -Winfinite-recursion
+    -Winit-self
+    -Winvalid-imported-macros
     -Winvalid-pch
-    -Wvolatile
-    -Wshift-overflow=2
-    -Warith-conversion
-    -Wcatch-value=3
-    -Wnoexcept
-    -Wuse-after-free=3
-    -Wdouble-promotion
-    -Wunused-macros
-    -Wregister
-    -Wsuggest-override
-    -Wnull-dereference
-    -Wtrampolines
+    -Wlarger-than=1073741824
     -Wlogical-op
+    -Wmismatched-tags
+    -Wmissing-braces
+    -Wmissing-declarations
+    -Wmissing-include-dirs
+    -Wmultichar
+    -Wmultiple-inheritance
+    -Wnoexcept
     -Wnon-virtual-dtor
-    -pedantic-errors
-    -Wbidi-chars=any
-    -Wdate-time
-    -Warray-parameter
-    -Waligned-new=all
+    -Wnormalized=nfkc
+    -Wnull-dereference
     -Wold-style-cast
-    -Wmultichar
-    -Wstack-protector
-    -Wmissing-braces
-    -Warray-bounds=2
-    -Walloc-zero
+    -Woverlength-strings
+    -Woverloaded-virtual
     -Wplacement-new=2
-    -Wmismatched-tags
-    -Wcomma-subscript
-    -Wall
-    -Wbidi-chars
-    -Wredundant-tags
-    -Wenum-conversion
-    -Wall
     -Wredundant-decls
+    -Wredundant-tags
+    -Wregister
+    -Wshadow
+    -Wshift-overflow=2
     -Wsign-conversion
-    -fdiagnostics-color=always
-    -nostdinc++
-    -fno-exceptions
-    -fno-rtti
-    -fno-threadsafe-statics
+    -Wsign-promo
+    -Wstack-protector
+    -Wstack-usage=8388608
+    -Wstrict-null-sentinel
+    -Wstrict-overflow=5
+    -Wstringop-overflow=4
+    -Wsuggest-final-methods
+    -Wsuggest-final-types
+    -Wsuggest-override
+    -Wswitch-enum
+    -Wsynth
+    -Wtrampolines
+    -Wtrivial-auto-var-init
+    -Wundef
+    -Wunreachable-code
+    -Wunused-const-variable=2
+    -Wunused-macros
+    -Wuse-after-free=3
+    -Wvirtual-inheritance
+    -Wvla
+    -Wvolatile
+    -Wwrite-strings
+    -Wzero-as-null-pointer-constant
 )
 target_compile_definitions(core PUBLIC CORE_LOG_LEVEL=4)
 target_link_libraries(core PUBLIC -nodefaultlibs c m)

+ 3 - 3
data/Components.hpp

@@ -8,9 +8,9 @@ namespace Core {
 
     template<typename T>
     class Components final {
-        HashMap<Entity, int> entityToIndex;
-        List<Entity> indexToEntity;
-        List<T> components;
+        HashMap<Entity, int> entityToIndex{};
+        List<Entity> indexToEntity{};
+        List<T> components{};
 
     public:
         template<typename R>

+ 2 - 2
data/HashMap.hpp

@@ -113,8 +113,8 @@ namespace Core {
             IteratorAdapter<const HashMap, ConstKeyIterator>;
 
     private:
-        LinkedList<Node> nodes;
-        List<NodePointerList> nodePointers;
+        LinkedList<Node> nodes{};
+        List<NodePointerList> nodePointers{};
 
     public:
         check_return Error copyFrom(const HashMap& other) {

+ 1 - 1
data/ProbingHashMap.hpp

@@ -125,7 +125,7 @@ namespace Core {
         int entries;
 
     public:
-        ProbingHashMap() : values(nullptr), entries(0) {
+        ProbingHashMap() : keys(), values(nullptr), entries(0) {
         }
 
         ProbingHashMap(const ProbingHashMap& other) = delete;

+ 1 - 1
data/Stack.hpp

@@ -8,7 +8,7 @@ namespace Core {
     namespace Internal {
         template<typename T, typename S>
         class BaseStack final {
-            S data;
+            S data{};
 
         public:
             template<typename... Args>

+ 1 - 1
io/FileReader.cpp

@@ -4,7 +4,7 @@
 
 #include "utils/Logger.hpp"
 
-Core::FileReader::FileReader() : file(nullptr) {
+Core::FileReader::FileReader() : file(nullptr), path() {
 }
 
 Core::FileReader::FileReader(FileReader&& other) : FileReader() {

+ 1 - 1
math/Box.cpp

@@ -4,7 +4,7 @@ Core::Box::Box(const Vector3& min_, const Vector3& max_)
     : min(min_), max(max_) {
 }
 
-Core::Box::Box(const Vector3& size) {
+Core::Box::Box(const Vector3& size) : min(), max() {
     for(int i = 0; i < 3; i++) {
         if(size[i] < 0.0f) {
             min[i] = size[i];

+ 2 - 1
math/Frustum.cpp

@@ -1,7 +1,8 @@
 #include "math/Frustum.hpp"
 
 Core::Frustum::Frustum(float fieldOfView, float nearClip_, float farClip_)
-    : tan(Core::Math::tan(Core::Math::degreeToRadian(fieldOfView) * 0.5f)),
+    : projection(), planes(),
+      tan(Core::Math::tan(Core::Math::degreeToRadian(fieldOfView) * 0.5f)),
       nearClip(nearClip_), farClip(farClip_) {
     float diff = 1.0f / (nearClip - farClip);
     projection.set(1, Vector4(0.0f, 1.0f / tan, 0.0f, 0.0f));

+ 1 - 1
math/MatrixStack.hpp

@@ -10,7 +10,7 @@ namespace Core {
         ArrayList<Matrix, N> stack;
 
     public:
-        MatrixStack() {
+        MatrixStack() : stack() {
             (void)stack.add(Matrix());
         }
 

+ 1 - 1
math/Plane.cpp

@@ -1,6 +1,6 @@
 #include "math/Plane.hpp"
 
-Core::Plane::Plane() : d(0) {
+Core::Plane::Plane() : abc(), d(0) {
 }
 
 Core::Plane::Plane(const Vector3& a, const Vector3& b, const Vector3& c)

+ 3 - 2
math/Quaternion.cpp

@@ -1,9 +1,10 @@
 #include "math/Quaternion.hpp"
 
-Core::Quaternion::Quaternion() : w(1.0f) {
+Core::Quaternion::Quaternion() : xyz(), w(1.0f) {
 }
 
-Core::Quaternion::Quaternion(const Vector3& axis, float angle) : xyz(axis) {
+Core::Quaternion::Quaternion(const Vector3& axis, float angle)
+    : xyz(axis), w(1.0f) {
     xyz.normalize();
     float factor = 0.0f;
     Core::Math::sinCos(Core::Math::degreeToRadian(angle) * 0.5f, factor, w);

+ 4 - 4
math/View.hpp

@@ -5,10 +5,10 @@
 
 namespace Core {
     class View final {
-        Matrix view;
-        Vector3 right;
-        Vector3 up;
-        Vector3 back;
+        Matrix view{};
+        Vector3 right{};
+        Vector3 up{};
+        Vector3 back{};
 
     public:
         void updateDirections(float lengthAngle, float widthAngle);

+ 1 - 1
performance/Main.cpp

@@ -9,7 +9,7 @@ using Millis = Core::Clock::Nanos;
 struct Timer {
     Core::Clock::Nanos nanos;
 
-    Timer() {
+    Timer() : nanos(0) {
         CORE_TEST_ERROR(Core::Clock::getNanos(nanos));
     }
 

+ 1 - 1
thread/Thread.hpp

@@ -7,7 +7,7 @@
 
 namespace Core {
     class Thread {
-        AlignedData<8, 8> thread;
+        AlignedData<8, 8> thread{};
 
     public:
         using Function = int (*)(void*);

+ 1 - 1
utils/UniquePointer.hpp

@@ -31,7 +31,7 @@ namespace Core {
                 other.t = nullptr;
             }
             return *this;
-        };
+        }
 
         T* operator->() {
             return t;