Skip to content

Fix based on Coverity and Sonar audits (part 2) - #22330

Merged
stelfrag merged 6 commits into
netdata:masterfrom
stelfrag:cov_fix_202604_part2
May 1, 2026
Merged

Fix based on Coverity and Sonar audits (part 2)#22330
stelfrag merged 6 commits into
netdata:masterfrom
stelfrag:cov_fix_202604_part2

Conversation

@stelfrag

Copy link
Copy Markdown
Collaborator

ktsaou added 3 commits April 30, 2026 09:49
…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).
@stelfrag
stelfrag marked this pull request as ready for review April 30, 2026 14:22
Copilot AI review requested due to automatic review settings April 30, 2026 14:22
@stelfrag
stelfrag requested a review from thiagoftsm as a code owner April 30, 2026 14:22
@stelfrag
stelfrag marked this pull request as draft April 30, 2026 14:23
@stelfrag

Copy link
Copy Markdown
Collaborator Author

@cubic-dev-ai review this PR

@cubic-dev-ai

cubic-dev-ai Bot commented Apr 30, 2026

Copy link
Copy Markdown
Contributor

@cubic-dev-ai review this PR

@stelfrag I have started the AI code review. It will take a few minutes to complete.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread src/exporting/pubsub/pubsub.c Outdated
Comment thread src/exporting/aws_kinesis/aws_kinesis.c Outdated
Comment thread src/exporting/exporting_engine.c Outdated
@stelfrag
stelfrag requested a review from Copilot May 1, 2026 08:31
stelfrag and others added 3 commits May 1, 2026 11:34
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>
@stelfrag
stelfrag marked this pull request as ready for review May 1, 2026 08:34

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
Loading

@sonarqubecloud

sonarqubecloud Bot commented May 1, 2026

Copy link
Copy Markdown

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@stelfrag
stelfrag merged commit b132229 into netdata:master May 1, 2026
157 checks passed
@stelfrag
stelfrag deleted the cov_fix_202604_part2 branch May 1, 2026 10:26
@stelfrag stelfrag mentioned this pull request Jun 22, 2026
Ferroin pushed a commit that referenced this pull request Jul 15, 2026
* 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)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants