-
Notifications
You must be signed in to change notification settings - Fork 46
test: fix coverity RESOURCE_LEAK in testValue_InitGetSetByType #404
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
base: develop
Are you sure you want to change the base?
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
There was a problem hiding this 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 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); | ||
|
|
Copilot
AI
Nov 29, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This line contains trailing whitespace. Remove the trailing spaces to maintain code cleanliness.
Addresses Copilot feedback on line 405
|
✅ Fixed in commit adc389a Removed trailing whitespace. |
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