Skip to content

Commit

Permalink
Merge pull request #1519 from anarkiwi/cppcheck
Browse files Browse the repository at this point in the history
Add basic cppcheck checks, fix possible uninitialized pointer reuse in API, ignore sqrt() NaN definition warning.
  • Loading branch information
bmah888 authored Jul 5, 2023
2 parents cc10897 + f73c852 commit 96accbf
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 @@ -4488,12 +4488,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 96accbf

Please sign in to comment.