Skip to content

Commit 0e18acc

Browse files
authored
Merge pull request #4378 from rouault/cppcheck_master_fix
Cppcheck master fixes
2 parents 3f91fd4 + 3b5f383 commit 0e18acc

File tree

5 files changed

+51
-9
lines changed

5 files changed

+51
-9
lines changed

.github/workflows/code_checks.yml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,39 @@ jobs:
3232
- name: Run cppcheck test
3333
run: ./scripts/cppcheck.sh
3434

35+
cppcheck_master:
36+
runs-on: ubuntu-latest
37+
steps:
38+
- name: Checkout
39+
uses: actions/checkout@v4
40+
41+
- name: Install Requirements
42+
run: |
43+
sudo apt update
44+
sudo apt install -y --no-install-recommends git cmake g++ make
45+
46+
- name: Build cppcheck
47+
run: |
48+
git clone https://github.com/danmar/cppcheck
49+
cd cppcheck
50+
mkdir build
51+
cd build
52+
cmake .. -DCMAKE_BUILD_TYPE=Release
53+
make -j$(nproc)
54+
sudo make install
55+
cd ../..
56+
57+
- name: Run cppcheck test (on push events)
58+
if: ${{ github.event_name == 'push' }}
59+
run: |
60+
./scripts/cppcheck.sh
61+
62+
- name: Run cppcheck test, but ignore failures (on pull request)
63+
if: ${{ github.event_name == 'pull_request' }}
64+
run: |
65+
# Do not fail the job. This is just used as a tool to monitor how we are regarding recent cppcheck
66+
./scripts/cppcheck.sh || /bin/true
67+
3568
other_checks:
3669
runs-on: ubuntu-24.04
3770
steps:

scripts/cppcheck.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,11 @@ grep -v "unmatchedSuppression" ${LOG_FILE} \
5959
| grep -v -e "molodensky.*unreadVariable,Variable 'point.*' is assigned a value that is never used" \
6060
| grep -v -e "vgridshift.*unreadVariable,Variable 'point.*' is assigned a value that is never used" \
6161
| grep -v -e "defines member function with name.*also defined in its parent" \
62+
| grep -v "passedByValueCallback,Function parameter 'lpz' should be passed by const reference" \
63+
| grep -v "passedByValueCallback,Function parameter 'xyz' should be passed by const reference" \
64+
| grep -v "passedByValueCallback,Function parameter 'geod' should be passed by const reference" \
65+
| grep -v "passedByValueCallback,Function parameter 'cart' should be passed by const reference" \
66+
| grep -v "passedByValueCallback,Function parameter 'in' should be passed by const reference" \
6267
> ${LOG_FILE}.tmp
6368
mv ${LOG_FILE}.tmp ${LOG_FILE}
6469

src/ctx.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ pj_ctx::pj_ctx(const pj_ctx &other)
173173
// BEGIN ini file settings
174174
iniFileLoaded(other.iniFileLoaded), endpoint(other.endpoint),
175175
networking(other.networking), ca_bundle_path(other.ca_bundle_path),
176-
gridChunkCache(other.gridChunkCache),
176+
native_ca(other.native_ca), gridChunkCache(other.gridChunkCache),
177177
defaultTmercAlgo(other.defaultTmercAlgo),
178178
// END ini file settings
179179
projStringParserCreateFromPROJStringRecursionCounter(0),

src/projections/s2.cpp

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -146,23 +146,26 @@ static double STtoUV(double s, S2ProjectionType s2_projection) {
146146
}
147147

148148
static double UVtoST(double u, S2ProjectionType s2_projection) {
149+
double ret = u;
149150
switch (s2_projection) {
150151
case Linear:
151-
return 0.5 * (u + 1);
152+
ret = 0.5 * (u + 1);
152153
break;
153154
case Quadratic:
154155
if (u >= 0)
155-
return 0.5 * std::sqrt(1 + 3 * u);
156+
ret = 0.5 * std::sqrt(1 + 3 * u);
156157
else
157-
return 1 - 0.5 * std::sqrt(1 - 3 * u);
158+
ret = 1 - 0.5 * std::sqrt(1 - 3 * u);
158159
break;
159160
case Tangent: {
160161
volatile double a = std::atan(u);
161-
return (2 * M_1_PI) * (a + M_PI_4);
162-
} break;
163-
default:
164-
return u;
162+
ret = (2 * M_1_PI) * (a + M_PI_4);
163+
break;
164+
}
165+
case NoUVtoST:
166+
break;
165167
}
168+
return ret;
166169
}
167170

168171
inline PJ_XYZ FaceUVtoXYZ(int face, double u, double v) {

src/transformations/deformation.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,8 @@ static PJ_XYZ pj_deformation_get_grid_shift(PJ *P, const PJ_XYZ &cartesian) {
202202
}
203203

204204
/********************************************************************************/
205-
static PJ_XYZ pj_deformation_reverse_shift(PJ *P, PJ_XYZ input, double dt) {
205+
static PJ_XYZ pj_deformation_reverse_shift(PJ *P, const PJ_XYZ &input,
206+
double dt) {
206207
/********************************************************************************
207208
Iteratively determine the reverse grid shift correction values.
208209
*********************************************************************************/

0 commit comments

Comments
 (0)