From d16258c1845e3814270f509ddfe08223e4308611 Mon Sep 17 00:00:00 2001
From: Alberto Nidasio <alberto.nidasio@skywarder.eu>
Date: Wed, 16 Nov 2022 14:11:40 +0100
Subject: [PATCH] Fixed compile warning and lint errors

---
 sbs                                               | 4 ++--
 scripts/linter.py                                 | 4 ++--
 src/shared/Core/Message/Message.cpp               | 1 +
 src/shared/Core/QCustomPlot/QCustomPlot.cpp       | 4 ++--
 src/shared/Modules/Mavlink/MavlinkVersionHeader.h | 2 ++
 5 files changed, 9 insertions(+), 6 deletions(-)

diff --git a/sbs b/sbs
index 50d9e66d..85483b9b 100755
--- a/sbs
+++ b/sbs
@@ -226,9 +226,9 @@ lint_cppcheck() {
     declare -a opts=()
     [ -n "$jobs" ] && opts+=("-j $jobs")
     
-    cppcheck --language=c++ --std=c++11 --enable=all --inline-suppr \
+    cppcheck --language=c++ --std=c++17 --template=gcc --enable=all --inline-suppr --force \
     --suppress=unmatchedSuppression --suppress=unusedFunction \
-    --suppress=missingInclude --error-exitcode=1 "${opts[@]}" \
+    --suppress=missingInclude --suppress=unknownMacro --error-exitcode=1 "${opts[@]}" \
     "$source_dir/src"
 }
 
diff --git a/scripts/linter.py b/scripts/linter.py
index a0c82973..83277ed9 100755
--- a/scripts/linter.py
+++ b/scripts/linter.py
@@ -272,8 +272,8 @@ def check_cppcheck(directory):
     linter_print(Colors.GREEN + 'cppcheck' + Colors.RESET)
     # Run cppcheck on the directory
     try:
-        result = check_output(['cppcheck', '-q', '--language=c++', '--template=gcc', '--std=c++11', '--enable=all', '--inline-suppr',
-                               '--suppress=unmatchedSuppression', '--suppress=unusedFunction', '--suppress=missingInclude',
+        result = check_output(['cppcheck', '-q', '--language=c++', '--std=c++17', '--template=gcc', '--enable=all', '--inline-suppr', '--force',
+                               '--suppress=unmatchedSuppression', '--suppress=unusedFunction', '--suppress=missingInclude', '--suppress=unknownMacro',
                                directory], stderr=STDOUT)
 
         # Parse results and count errors
diff --git a/src/shared/Core/Message/Message.cpp b/src/shared/Core/Message/Message.cpp
index 08f21073..136726c8 100644
--- a/src/shared/Core/Message/Message.cpp
+++ b/src/shared/Core/Message/Message.cpp
@@ -67,6 +67,7 @@ QString Message::toString() const
         str += "{\n";
 
         for (auto key : fields.keys())
+            // cppcheck-suppress useStlAlgorithm
             str += "    " + key + ": " + fields[key].toString() + "\n";
 
         str.append("}");
diff --git a/src/shared/Core/QCustomPlot/QCustomPlot.cpp b/src/shared/Core/QCustomPlot/QCustomPlot.cpp
index d96e14f5..44e767d1 100644
--- a/src/shared/Core/QCustomPlot/QCustomPlot.cpp
+++ b/src/shared/Core/QCustomPlot/QCustomPlot.cpp
@@ -5795,8 +5795,8 @@ void QCPLineEnding::draw(QCPPainter *painter, const QCPVector2D &pos,
         {
             QCPVector2D widthVecPerp = widthVec.perpendicular();
             QPointF points[4]        = {
-                (pos - widthVecPerp).toPointF(), (pos - widthVec).toPointF(),
-                (pos + widthVecPerp).toPointF(), (pos + widthVec).toPointF()};
+                       (pos - widthVecPerp).toPointF(), (pos - widthVec).toPointF(),
+                       (pos + widthVecPerp).toPointF(), (pos + widthVec).toPointF()};
             painter->setPen(miterPen);
             painter->setBrush(brush);
             painter->drawConvexPolygon(points, 4);
diff --git a/src/shared/Modules/Mavlink/MavlinkVersionHeader.h b/src/shared/Modules/Mavlink/MavlinkVersionHeader.h
index 6a8ebf12..ed377628 100644
--- a/src/shared/Modules/Mavlink/MavlinkVersionHeader.h
+++ b/src/shared/Modules/Mavlink/MavlinkVersionHeader.h
@@ -20,7 +20,9 @@
 
 #pragma GCC diagnostic push
 #pragma GCC diagnostic ignored "-Wcast-align"
+#if __GNUC_PREREQ(9, 0)
 #pragma GCC diagnostic ignored "-Waddress-of-packed-member"
+#endif
 #include <mavlink_lib/pyxis/mavlink.h>
 #pragma GCC diagnostic pop
 
-- 
GitLab