test: fix coverity RESOURCE_LEAK in testValue_InitGetSetByType#404
Open
svc-rdkeportal01 wants to merge 2 commits intodevelopfrom
Open
test: fix coverity RESOURCE_LEAK in testValue_InitGetSetByType#404svc-rdkeportal01 wants to merge 2 commits intodevelopfrom
svc-rdkeportal01 wants to merge 2 commits intodevelopfrom
Conversation
Fixes Coverity defects CID 117-135 (not GitHub issues) Fix generated by RDKDevPilot AI Bot with pattern validation Root Cause: Coverity static analysis cannot track resource cleanup through variadic functions like rbusProperty_Releases(). The function properly releases all resources, but Coverity's data flow analysis loses track of which specific arguments are released inside the variadic function. This is a known limitation of static analysis tools - they cannot reliably trace va_arg() calls to specific function parameters. Changes: - Replace rbusProperty_Releases(17, ...) with 17 individual rbusProperty_Release() calls - Replace rbusObject_Releases(2, ...) with 2 individual rbusObject_Release() calls - Add explanatory comment about Coverity limitation Impact: - Functionally equivalent (same cleanup behavior) - Makes resource cleanup explicit for static analysis - Fixes all 19 Coverity RESOURCE_LEAK issues (CID 117-135) Technical Details: The variadic rbusProperty_Releases() implementation uses va_arg() to iterate through arguments. Static analyzers cannot determine which specific variables map to which va_arg() calls, causing false positive resource leak warnings. Coverity CIDs: 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135 All at line 388, function testValue_InitGetSetByType() Validation scores: Pipeline 95/100, Pattern 100/100
Contributor
There was a problem hiding this comment.
Pull request overview
This PR replaces variadic resource cleanup functions with individual release calls to eliminate 19 Coverity RESOURCE_LEAK false positives in the test suite. The changes address a known limitation where static analysis tools cannot track resource cleanup through variadic functions.
- Replaces
rbusProperty_Releases(17, ...)with 17 individualrbusProperty_Release()calls - Replaces
rbusObject_Releases(2, ...)with 2 individualrbusObject_Release()calls - Adds explanatory comments documenting the reason for the change
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
test/rbus/consumer/propertyAPI.c
Outdated
| rbusProperty_Release(vobj); | ||
| rbusProperty_Release(prop); | ||
| rbusProperty_Release(prop2); | ||
|
|
There was a problem hiding this comment.
This line contains trailing whitespace. Remove the trailing spaces to maintain code cleanliness.
Suggested change
Addresses Copilot feedback on line 405
Author
|
✅ Fixed in commit adc389a Removed trailing whitespace. |
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
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.
Fix Coverity RESOURCE_LEAK in testValue_InitGetSetByType
Coverity Issues Fixed
This PR fixes 19 Coverity RESOURCE_LEAK defects in
test/rbus/consumer/propertyAPI.c:Coverity CIDs: 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135
Root Cause
Coverity static analysis limitation with variadic functions:
The original code used variadic cleanup functions:
These functions properly release all resources, but Coverity's data flow analysis cannot track resource cleanup through variadic functions (
...).Why this happens:
va_arg()to iterate through argumentsva_arg()callsThe implementation (from
src/rbus/rbus_property.c):Coverity cannot trace which of the 17 parameters are released by which
va_arg()call.Changes Made
Replaced variadic calls with individual release calls:
Before:
After:
Impact
Why 19 Issues?
rbusProperty_tobjectsrbusObject_tobjectsEach resource was flagged separately because Coverity couldn't verify it was released.
Technical Note: This is not a bug in the original code - the variadic functions work correctly. This change is purely to satisfy static analysis tools that cannot trace variadic function arguments.
Coverity Defect Details:
test/rbus/consumer/propertyAPI.c