Fix based on Coverity and Sonar audits (part 2) - #22330
Conversation
…NG branch Sonar c:S935 (CRITICAL): aws_kinesis_connector_worker() is declared void *, but the conditional test-only early exit inside #ifdef UNIT_TESTING used a bare `return;`. Per C99/C11 6.8.6.4, a return without an expression is only permitted in a function whose return type is void. Production builds skip this block, but enabling UNIT_TESTING fails to compile. Change the bare return to `return NULL;` so test builds satisfy the function signature; production control flow is unchanged.
…anch Sonar c:S935 (CRITICAL): pubsub_connector_worker() is declared void *, but the conditional test-only early exit inside #ifdef UNIT_TESTING used a bare `return;`. Per C99/C11 6.8.6.4, a return without an expression is only permitted in a function whose return type is void. Production builds skip this block, but enabling UNIT_TESTING fails to compile. Same pattern as aws_kinesis.c:214 fixed in the previous commit.
…TING branch Sonar c:S935 (CRITICAL): exporting_main() is declared void, but the conditional test-only early exit inside #ifdef UNIT_TESTING used `return NULL;`, which is invalid for a void-returning function per C99/C11 6.8.6.4. Production builds skip the block, but enabling UNIT_TESTING fails to compile. Change the conditional return to a bare `return;`, and remove the stale "@return It always returns NULL" line from the function's docstring (left behind from when the signature was void *). Together with the previous two commits, this closes the c:S935 trio across the exporting subsystem (aws_kinesis, pubsub, exporting_engine).
|
@cubic-dev-ai review this PR |
@stelfrag I have started the AI code review. It will take a few minutes to complete. |
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
No issues found across 3 files
Confidence score: 5/5
- Automated review surfaced no issues in the provided summaries.
- No files require special attention.
Architecture diagram
sequenceDiagram
participant TR as Unit Test Runner
participant EE as Exporting Engine
participant KW as Kinesis Worker
participant PW as PubSub Worker
Note over TR,PW: Unit Testing Control Flow (Static Analysis Fixes)
TR->>EE: Invoke exporting_main (void)
EE->>EE: Perform main rusage tracking
alt UNIT_TESTING
EE-->>TR: CHANGED: return (void)
end
TR->>KW: Invoke aws_kinesis_connector_worker (void*)
KW->>KW: netdata_mutex_unlock()
alt UNIT_TESTING
KW-->>TR: CHANGED: return NULL (void*)
end
TR->>PW: Invoke pubsub_connector_worker (void*)
PW->>PW: netdata_mutex_unlock()
alt UNIT_TESTING
PW->>PW: CHANGED: break loop
PW-->>TR: Return control/NULL
end
|
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 3 out of 3 changed files in this pull request and generated no new comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
* exporting: fix bare return in aws_kinesis_connector_worker UNIT_TESTING branch Sonar c:S935 (CRITICAL): aws_kinesis_connector_worker() is declared void *, but the conditional test-only early exit inside #ifdef UNIT_TESTING used a bare `return;`. Per C99/C11 6.8.6.4, a return without an expression is only permitted in a function whose return type is void. Production builds skip this block, but enabling UNIT_TESTING fails to compile. Change the bare return to `return NULL;` so test builds satisfy the function signature; production control flow is unchanged. * exporting: fix bare return in pubsub_connector_worker UNIT_TESTING branch Sonar c:S935 (CRITICAL): pubsub_connector_worker() is declared void *, but the conditional test-only early exit inside #ifdef UNIT_TESTING used a bare `return;`. Per C99/C11 6.8.6.4, a return without an expression is only permitted in a function whose return type is void. Production builds skip this block, but enabling UNIT_TESTING fails to compile. Same pattern as aws_kinesis.c:214 fixed in the previous commit. * exporting: fix value-returning bare return in exporting_main UNIT_TESTING branch Sonar c:S935 (CRITICAL): exporting_main() is declared void, but the conditional test-only early exit inside #ifdef UNIT_TESTING used `return NULL;`, which is invalid for a void-returning function per C99/C11 6.8.6.4. Production builds skip the block, but enabling UNIT_TESTING fails to compile. Change the conditional return to a bare `return;`, and remove the stale "@return It always returns NULL" line from the function's docstring (left behind from when the signature was void *). Together with the previous two commits, this closes the c:S935 trio across the exporting subsystem (aws_kinesis, pubsub, exporting_engine). * Update src/exporting/pubsub/pubsub.c Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update src/exporting/aws_kinesis/aws_kinesis.c Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update src/exporting/exporting_engine.c Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --------- Co-authored-by: Costa Tsaousis <costa@netdata.cloud> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> (cherry picked from commit b132229)



Summary