Skip to content

[tests] Fix for a warning about using the variable in input and output #5013

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

emasab
Copy link
Contributor

@emasab emasab commented Apr 2, 2025

No description provided.

@Copilot Copilot bot review requested due to automatic review settings April 2, 2025 17:06
@emasab emasab requested a review from a team as a code owner April 2, 2025 17:06
@confluent-cla-assistant
Copy link

🎉 All Contributor License Agreements have been signed. Ready to merge.
Please push an empty commit if you would like to re-run the checks to verify CLA status for all contributors.

Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR addresses a warning about using the same variable for both input and output by refactoring how the debug string is built.

  • Introduces an index variable to track the current position in the output buffer
  • Adds an extra bound check in the while loop to avoid buffer overruns
Comments suppressed due to low confidence (1)

tests/test.c:1108

  • [nitpick] Consider renaming 'i' to a more descriptive name, such as 'current_pos', to improve code readability.
size_t i = rd_snprintf(debug_with_contexts, sizeof(debug_with_contexts), "%s", test_debug ? test_debug : "");

tests/test.c Outdated
/* Add all debug contexts and set debug configuration */
while (*debug_contexts) {
while (*debug_contexts && i < sizeof(debug_with_contexts) - 2) {
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
while (*debug_contexts && i < sizeof(debug_with_contexts) - 2) {
while (strlen(*debug_contexts) + i <= sizeof(debug_with_contexts) - 2) {

@emasab emasab changed the title Fix for a warning about using the variable in input and output [tests] Fix for a warning about using the variable in input and output Apr 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants