Remove unnecessary NULL checks before free() in rbuscli discovery commands #402
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Addresses code review feedback on PR fixing Coverity RESOURCE_LEAK defects. The NULL checks added in the error paths were unnecessary and inconsistent with the rest of the codebase.
Changes
free()calls in three discovery functions:execute_discover_component_cmd()(line 1003)execute_discover_elements_cmd()(line 1050)execute_discover_wildcard_dests_cmd()(line 1096)The C standard guarantees
free(NULL)is safe, and the rest ofrbuscli.ccallsfree()directly without NULL checks (lines 953, 955, 991, 993, 1041, 1043, 1090, 1092).Before:
After:
This reduces code from 5 lines to 1 line per cleanup block while maintaining the same safety guarantees.
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.