Skip to content

Commit

Permalink
Merge pull request #4378 from rouault/cppcheck_master_fix
Browse files Browse the repository at this point in the history
Cppcheck master fixes
  • Loading branch information
rouault authored Jan 13, 2025
2 parents 3f91fd4 + 3b5f383 commit 0e18acc
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 9 deletions.
33 changes: 33 additions & 0 deletions .github/workflows/code_checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
5 changes: 5 additions & 0 deletions scripts/cppcheck.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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}

Expand Down
2 changes: 1 addition & 1 deletion src/ctx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
17 changes: 10 additions & 7 deletions src/projections/s2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
3 changes: 2 additions & 1 deletion src/transformations/deformation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*********************************************************************************/
Expand Down

0 comments on commit 0e18acc

Please sign in to comment.