From 26c35fd1ea004959eb28159f59b506dc7bd70a3e Mon Sep 17 00:00:00 2001 From: Even Rouault Date: Sun, 12 Jan 2025 21:51:39 +0100 Subject: [PATCH 1/3] pj_ctx: copy constructor: copy master-added native_ca member --- src/ctx.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ctx.cpp b/src/ctx.cpp index bc1b6f8a4c..958b129994 100644 --- a/src/ctx.cpp +++ b/src/ctx.cpp @@ -173,7 +173,7 @@ pj_ctx::pj_ctx(const pj_ctx &other) // BEGIN ini file settings iniFileLoaded(other.iniFileLoaded), endpoint(other.endpoint), networking(other.networking), ca_bundle_path(other.ca_bundle_path), - gridChunkCache(other.gridChunkCache), + native_ca(other.native_ca), gridChunkCache(other.gridChunkCache), defaultTmercAlgo(other.defaultTmercAlgo), // END ini file settings projStringParserCreateFromPROJStringRecursionCounter(0), From 0b5659c2b9d0799dc1dea237036f8808f4856df5 Mon Sep 17 00:00:00 2001 From: Even Rouault Date: Sun, 12 Jan 2025 21:52:09 +0100 Subject: [PATCH 2/3] Fixes to make cppcheck master happy --- src/projections/s2.cpp | 17 ++++++++++------- src/transformations/deformation.cpp | 3 ++- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/src/projections/s2.cpp b/src/projections/s2.cpp index a90a4f79b7..1f00d1c736 100644 --- a/src/projections/s2.cpp +++ b/src/projections/s2.cpp @@ -146,23 +146,26 @@ static double STtoUV(double s, S2ProjectionType s2_projection) { } static double UVtoST(double u, S2ProjectionType s2_projection) { + double ret = u; switch (s2_projection) { case Linear: - return 0.5 * (u + 1); + ret = 0.5 * (u + 1); break; case Quadratic: if (u >= 0) - return 0.5 * std::sqrt(1 + 3 * u); + ret = 0.5 * std::sqrt(1 + 3 * u); else - return 1 - 0.5 * std::sqrt(1 - 3 * u); + ret = 1 - 0.5 * std::sqrt(1 - 3 * u); break; case Tangent: { volatile double a = std::atan(u); - return (2 * M_1_PI) * (a + M_PI_4); - } break; - default: - return u; + ret = (2 * M_1_PI) * (a + M_PI_4); + break; + } + case NoUVtoST: + break; } + return ret; } inline PJ_XYZ FaceUVtoXYZ(int face, double u, double v) { diff --git a/src/transformations/deformation.cpp b/src/transformations/deformation.cpp index f49203d699..6d11b85d1e 100644 --- a/src/transformations/deformation.cpp +++ b/src/transformations/deformation.cpp @@ -202,7 +202,8 @@ static PJ_XYZ pj_deformation_get_grid_shift(PJ *P, const PJ_XYZ &cartesian) { } /********************************************************************************/ -static PJ_XYZ pj_deformation_reverse_shift(PJ *P, PJ_XYZ input, double dt) { +static PJ_XYZ pj_deformation_reverse_shift(PJ *P, const PJ_XYZ &input, + double dt) { /******************************************************************************** Iteratively determine the reverse grid shift correction values. *********************************************************************************/ From 3b5f38329320d7694a5a8f162535f54d37dad0d8 Mon Sep 17 00:00:00 2001 From: Even Rouault Date: Sun, 12 Jan 2025 21:52:32 +0100 Subject: [PATCH 3/3] CI: add a cppcheck master config (which may only fails on push, not pull requests) --- .github/workflows/code_checks.yml | 33 +++++++++++++++++++++++++++++++ scripts/cppcheck.sh | 5 +++++ 2 files changed, 38 insertions(+) diff --git a/.github/workflows/code_checks.yml b/.github/workflows/code_checks.yml index 31b0f23c80..5d52bc922a 100644 --- a/.github/workflows/code_checks.yml +++ b/.github/workflows/code_checks.yml @@ -32,6 +32,39 @@ jobs: - name: Run cppcheck test run: ./scripts/cppcheck.sh + cppcheck_master: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Install Requirements + run: | + sudo apt update + sudo apt install -y --no-install-recommends git cmake g++ make + + - name: Build cppcheck + run: | + git clone https://github.com/danmar/cppcheck + cd cppcheck + mkdir build + cd build + cmake .. -DCMAKE_BUILD_TYPE=Release + make -j$(nproc) + sudo make install + cd ../.. + + - name: Run cppcheck test (on push events) + if: ${{ github.event_name == 'push' }} + run: | + ./scripts/cppcheck.sh + + - name: Run cppcheck test, but ignore failures (on pull request) + if: ${{ github.event_name == 'pull_request' }} + run: | + # Do not fail the job. This is just used as a tool to monitor how we are regarding recent cppcheck + ./scripts/cppcheck.sh || /bin/true + other_checks: runs-on: ubuntu-24.04 steps: diff --git a/scripts/cppcheck.sh b/scripts/cppcheck.sh index f93ffe1ac2..60a3928b48 100755 --- a/scripts/cppcheck.sh +++ b/scripts/cppcheck.sh @@ -59,6 +59,11 @@ grep -v "unmatchedSuppression" ${LOG_FILE} \ | grep -v -e "molodensky.*unreadVariable,Variable 'point.*' is assigned a value that is never used" \ | grep -v -e "vgridshift.*unreadVariable,Variable 'point.*' is assigned a value that is never used" \ | grep -v -e "defines member function with name.*also defined in its parent" \ + | grep -v "passedByValueCallback,Function parameter 'lpz' should be passed by const reference" \ + | grep -v "passedByValueCallback,Function parameter 'xyz' should be passed by const reference" \ + | grep -v "passedByValueCallback,Function parameter 'geod' should be passed by const reference" \ + | grep -v "passedByValueCallback,Function parameter 'cart' should be passed by const reference" \ + | grep -v "passedByValueCallback,Function parameter 'in' should be passed by const reference" \ > ${LOG_FILE}.tmp mv ${LOG_FILE}.tmp ${LOG_FILE}