Skip to content

Conversation

@svc-rdkeportal01
Copy link

@svc-rdkeportal01 svc-rdkeportal01 commented Dec 2, 2025

Fix REVERSE_INULL in rtMessage_Retain_test1

Issues Fixed

  • Coverity CID 139: REVERSE_INULL in unittests/rbus_unit_test_server.cpp at line 1320

Root Cause

The code was checking if msg is NULL after already dereferencing it in rtMessage_Retain(msg). This is a logic error - if msg was NULL, the code would crash at line 1317 before reaching the NULL check at line 1320.

Changes Made

Removed redundant NULL check:

Before:

rtMessage_Create(&msg);
err = rtMessage_Retain(msg);  // Line 1317: Dereferences msg
EXPECT_EQ(err, RT_OK);
rtMessage_Release(msg);
if(msg)  // Line 1320: Checks NULL (too late!)
   rtMessage_Release(msg);

After:

rtMessage_Create(&msg);
err = rtMessage_Retain(msg);
EXPECT_EQ(err, RT_OK);
rtMessage_Release(msg);
rtMessage_Release(msg);  // No redundant check needed

Why This Fix is Correct

  • rtMessage_Create() guarantees msg is non-NULL
  • If msg was NULL, the test would fail at EXPECT_EQ(err, RT_OK)
  • The NULL check at line 1320 was redundant and misleading
  • Second rtMessage_Release() is intentional (testing double release behavior)

Coverity issue ID: 139 (REVERSE_INULL)
Fix generated by RDKDevPilot AI Bot following pattern from PR #382

The code was checking if msg is NULL after already dereferencing it
in rtMessage_Retain(msg). This is a logic error - if msg was NULL,
it would crash before reaching the NULL check.

Fix: Removed redundant NULL check since rtMessage_Create() guarantees
msg is non-NULL or the test would fail earlier.

Co-authored-by: rdkdevpilot <bot@rdkcentral.com>
@svc-rdkeportal01 svc-rdkeportal01 requested a review from a team as a code owner December 2, 2025 17:46
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.

1 participant