| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
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.
|
Sorry, something went wrong.
|
@cubic-dev-ai review this PR |
Sorry, something went wrong.
@stelfrag I have started the AI code review. It will take a few minutes to complete. |
Sorry, something went wrong.
There was a problem hiding this comment.
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:
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Sorry, something went wrong.
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)
| Back | FazBrowse Home | New Git URL |
Summary