diff options
author | Dan Goodliffe <dan@randomdan.homeip.net> | 2021-11-27 00:36:19 +0000 |
---|---|---|
committer | Dan Goodliffe <dan@randomdan.homeip.net> | 2021-11-27 00:36:25 +0000 |
commit | 7827b06edf6a0629eb659540595c347965abfb88 (patch) | |
tree | 3b52612ae8f591f23e2b179fe817f4d4c948a7ce | |
parent | Enable all Jason Turner recommended warnings (diff) | |
download | ilt-7827b06edf6a0629eb659540595c347965abfb88.tar.bz2 ilt-7827b06edf6a0629eb659540595c347965abfb88.tar.xz ilt-7827b06edf6a0629eb659540595c347965abfb88.zip |
Fix up lots of static analyzer warnings
-rw-r--r-- | gfx/gl/shader-source.h | 8 | ||||
-rw-r--r-- | lib/jsonParse-persistence.cpp | 2 | ||||
-rw-r--r-- | lib/maths.h | 4 | ||||
-rw-r--r-- | lib/persistence.cpp | 5 | ||||
-rw-r--r-- | lib/persistence.h | 12 | ||||
-rw-r--r-- | test/test-maths.cpp | 4 |
6 files changed, 19 insertions, 16 deletions
diff --git a/gfx/gl/shader-source.h b/gfx/gl/shader-source.h index 9403e80..f22cc3b 100644 --- a/gfx/gl/shader-source.h +++ b/gfx/gl/shader-source.h @@ -17,9 +17,11 @@ struct GLsource { constexpr auto constexpr_strlen(const GLchar * const s) { - auto e {s}; - while (*++e) { } - return e - s; + std::size_t ch {}; + while (s[ch]) { + ch++; + } + return ch; } #endif diff --git a/lib/jsonParse-persistence.cpp b/lib/jsonParse-persistence.cpp index a9b9a83..fe8bf8d 100644 --- a/lib/jsonParse-persistence.cpp +++ b/lib/jsonParse-persistence.cpp @@ -92,7 +92,7 @@ namespace Persistence { wrv(std::ostream & strm, char ch) { strm.put(ch); - }; + } static inline void wrh(std::ostream & strm, char ch) { diff --git a/lib/maths.h b/lib/maths.h index 18332b7..ad2f3e5 100644 --- a/lib/maths.h +++ b/lib/maths.h @@ -108,14 +108,14 @@ template<typename T> inline constexpr auto mph_to_ms(T v) { - return v / 2.237; + return v / 2.237L; } template<typename T> inline constexpr auto kph_to_ms(T v) { - return v / 3.6; + return v / 3.6L; } // ... literals are handy for now, probably go away when we load stuff externally diff --git a/lib/persistence.cpp b/lib/persistence.cpp index 405c7ec..5338738 100644 --- a/lib/persistence.cpp +++ b/lib/persistence.cpp @@ -70,7 +70,7 @@ namespace Persistence { PersistenceWrite::selHandler() { this->sel->write(out); - }; + } void PersistenceWrite::setType(const std::string_view tn, const Persistable * p) @@ -97,7 +97,8 @@ namespace Persistence { throw std::runtime_error("Unexpected bool"); } - void Selection::setValue(std::nullptr_t) + void + Selection::setValue(std::nullptr_t) { throw std::runtime_error("Unexpected null"); } diff --git a/lib/persistence.h b/lib/persistence.h index 0faa24d..5468cd3 100644 --- a/lib/persistence.h +++ b/lib/persistence.h @@ -176,11 +176,11 @@ namespace Persistence { void write(const Writer & out) const override { - for (glm::length_t idx = 0; idx < L; idx += 1) { - if (idx) { + for (glm::length_t n = 0; n < L; n += 1) { + if (n) { out.nextValue(); } - SelectionT<T> {this->v[idx]}.write(out); + SelectionT<T> {this->v[n]}.write(out); } } }; @@ -217,11 +217,11 @@ namespace Persistence { void write(const Writer & out) const override { - for (std::size_t idx = 0; idx < this->v.size(); idx += 1) { - if (idx) { + for (auto & member : this->v) { + if (&member != &this->v.front()) { out.nextValue(); } - SelectionT<T> {this->v[idx]}.write(out); + SelectionT<T> {member}.write(out); } } }; diff --git a/test/test-maths.cpp b/test/test-maths.cpp index decebcc..edc3e60 100644 --- a/test/test-maths.cpp +++ b/test/test-maths.cpp @@ -169,7 +169,7 @@ BOOST_AUTO_TEST_CASE(test_find_arcs_radius) } struct TestLinkStraight : public LinkStraight { - TestLinkStraight(glm::vec3 v) : + explicit TestLinkStraight(glm::vec3 v) : Link {{std::make_shared<Node>(origin), vector_yaw(v)}, {std::make_shared<Node>(v), vector_yaw(-v)}, glm::length(v)} { @@ -200,7 +200,7 @@ BOOST_DATA_TEST_CASE(straight1, } struct TestLinkCurve : public LinkCurve { - TestLinkCurve(glm::vec3 e0, glm::vec3 e1, glm::vec3 ctr) : + explicit TestLinkCurve(glm::vec3 e0, glm::vec3 e1, glm::vec3 ctr) : Link {{std::make_shared<Node>(e0), normalize(vector_yaw(ctr - e0) - half_pi)}, {std::make_shared<Node>(e1), normalize(vector_yaw(ctr - e1) - half_pi)}, glm::length(e1 - e0)}, LinkCurve(ctr, glm::length(e0 - ctr), {ctr, e0, e1}) |