FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Fix based on Coverity and Sonar audits (part 6) by stelfrag · Pull Request #22334 · netdata/netdata · GitHub

Fix based on Coverity and Sonar audits (part 6) - #22334

Merged
stelfrag merged 1 commit into
netdata:masterfrom
stelfrag:cov_fix_202604_part6
May 1, 2026
Merged

Fix based on Coverity and Sonar audits (part 6)#22334
stelfrag merged 1 commit into
netdata:masterfrom
stelfrag:cov_fix_202604_part6

Conversation

Copy link
Copy Markdown
Collaborator

Sonar c:S876: chart_by_reason() iterated with `size_t i` and passed
`-i` to stream_handshake_error_to_string(STREAM_HANDSHAKE). The unary
minus on the unsigned counter wrapped to a huge unsigned value that
then narrowed to int through implementation-defined conversion (C99
6.3.1.3). It happens to produce the correct -i on two's-complement
platforms but is fragile and unportable.

Change the loop variable to `int`. The loop bound
STREAM_HANDSHAKE_NEGATIVE_MAX is 40, well within int range, and the
b->rd[] array has more than enough entries for the same index. The
negation is now well-defined signed arithmetic.

Copy link
Copy Markdown

Copy link
Copy Markdown
Collaborator Author

@cubic-dev-ai review this PR

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.

stelfrag marked this pull request as ready for review May 1, 2026 07:24
Copilot AI review requested due to automatic review settings May 1, 2026 07:24
stelfrag marked this pull request as draft May 1, 2026 07:24

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.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Pull request overview

Updates pulse chart generation to avoid unsigned negation issues when mapping handshake error codes to labels, aligning with Coverity/Sonar audit-driven cleanup work.

Changes:

  • Switch loop index from size_t to int when iterating STREAM_HANDSHAKE_NEGATIVE_MAX so -i produces valid negative handshake codes.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

stelfrag marked this pull request as ready for review May 1, 2026 08:01
stelfrag merged commit 2dbbfd6 into netdata:master May 1, 2026
162 checks passed
stelfrag deleted the cov_fix_202604_part6 branch May 1, 2026 08:17
stelfrag mentioned this pull request Jun 22, 2026
Ferroin pushed a commit that referenced this pull request Jul 15, 2026
pulse: use int loop variable when negating to STREAM_HANDSHAKE enum

Sonar c:S876: chart_by_reason() iterated with `size_t i` and passed
`-i` to stream_handshake_error_to_string(STREAM_HANDSHAKE). The unary
minus on the unsigned counter wrapped to a huge unsigned value that
then narrowed to int through implementation-defined conversion (C99
6.3.1.3). It happens to produce the correct -i on two's-complement
platforms but is fragile and unportable.

Change the loop variable to `int`. The loop bound
STREAM_HANDSHAKE_NEGATIVE_MAX is 40, well within int range, and the
b->rd[] array has more than enough entries for the same index. The
negation is now well-defined signed arithmetic.

Co-authored-by: Costa Tsaousis <costa@netdata.cloud>
(cherry picked from commit 2dbbfd6)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
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


Back | FazBrowse Home | New Git URL