Skip to content

Commit

Permalink
Add basic cppcheck checks, fix possible uninitialized pointer reuse i…
Browse files Browse the repository at this point in the history
…n API, ignore sqrt() NaN definition warning.
  • Loading branch information
anarkiwi committed May 17, 2023
1 parent 1583601 commit f73c852
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 deletions.
8 changes: 8 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
name: test
on: [push, pull_request]
jobs:
cppcheck-test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: install dependencies
run: |
sudo apt-get -y update && sudo apt-get install -y cppcheck && \
cppcheck . --force --inline-suppr
build-test-latest:
runs-on: ubuntu-latest
steps:
Expand Down
2 changes: 1 addition & 1 deletion src/cjson.c
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ CJSON_PUBLIC(double) cJSON_GetNumberValue(const cJSON * const item)
{
if (!cJSON_IsNumber(item))
{
return (double) NAN;
return (double) NAN; // cppcheck-suppress invalidFunctionArg
}

return item->valuedouble;
Expand Down
7 changes: 5 additions & 2 deletions src/iperf_api.c
Original file line number Diff line number Diff line change
Expand Up @@ -4487,12 +4487,15 @@ iperf_add_stream(struct iperf_test *test, struct iperf_stream *sp)
// and changing it would break multi-stream tests between old
// and new iperf3 versions.
i = 2;
prev = NULL;
SLIST_FOREACH(n, &test->streams, streams) {
prev = n;
++i;
}
SLIST_INSERT_AFTER(prev, sp, streams);
sp->id = i;
if (prev) {
SLIST_INSERT_AFTER(prev, sp, streams);
sp->id = i;
}
}
}

Expand Down

0 comments on commit f73c852

Please sign in to comment.