Skip to content

Conversation

@Vismalskumar0
Copy link
Contributor

RDK-60308-[tr69hostif, RFC] RDK Coverity Defect Resolution for Device Management

@Vismalskumar0 Vismalskumar0 requested a review from a team as a code owner January 23, 2026 05:06
Copilot AI review requested due to automatic review settings January 23, 2026 05:06
Copy link
Contributor

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 Coverity defects in the Device Management component by fixing memory leaks, adding move semantics optimizations, and improving code quality.

Changes:

  • Added proper cleanup of nested pointers in hashData structure to fix memory leaks
  • Introduced std::move() optimizations to reduce string copying overhead
  • Added default case to switch statement for better code coverage

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 2035 to 2037
break;
default
break;
Copy link

Copilot AI Jan 23, 2026

Choose a reason for hiding this comment

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

Inconsistent indentation: These lines use tabs while surrounding code uses spaces. Consider maintaining consistent indentation style throughout the file.

Copilot uses AI. Check for mistakes.
Comment on lines +1990 to +2001
if(file_dwnl.hashData->hashvalue != nullptr)
{
free(file_dwnl.hashData->hashvalue);
file_dwnl.hashData->hashvalue = nullptr;
}
if(file_dwnl.hashData->hashtime != nullptr)
{
free(file_dwnl.hashData->hashtime);
file_dwnl.hashData->hashtime = nullptr;
}
free(file_dwnl.hashData);
file_dwnl.hashData = nullptr;
Copy link

Copilot AI Jan 23, 2026

Choose a reason for hiding this comment

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

Inconsistent indentation: These lines use tabs while surrounding code uses spaces. Consider maintaining consistent indentation style throughout the file.

Copilot uses AI. Check for mistakes.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@copilot open a new pull request to apply changes based on this feedback

Copy link

Copilot AI commented Jan 23, 2026

@Vismalskumar0 I've opened a new pull request, #159, to work on those changes. Once the pull request is ready, I'll request review from you.

Copilot AI review requested due to automatic review settings January 23, 2026 05:24
Copy link
Contributor

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

Copilot reviewed 1 out of 1 changed files in this pull request and generated 6 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

RDK_LOG(RDK_LOG_INFO, LOG_RFCMGR, "[%s][%d] Clearing DB Value: %s\n", __FUNCTION__,__LINE__,ClearDB.c_str());
set_RFCProperty(name, std::move(ClearDB), clearValue);
RDK_LOG(RDK_LOG_INFO, LOG_RFCMGR, "[%s][%d] Bootstrap Clearing DB Value: %s\n", __FUNCTION__,__LINE__,BootstrapClearDB.c_str());
set_RFCProperty(name, std::move(BootstrapClearDB), clearValue);
Copy link

Copilot AI Jan 23, 2026

Choose a reason for hiding this comment

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

Use-after-move error: The BootstrapClearDB string is logged at line 1300 using .c_str(), but then immediately moved at line 1301. After std::move(), BootstrapClearDB is in an unspecified state and using it is undefined behavior. The logging should occur after the set_RFCProperty call, or the second parameter should not use std::move() since it's still needed by the logging statement.

Suggested change
set_RFCProperty(name, std::move(BootstrapClearDB), clearValue);
set_RFCProperty(name, BootstrapClearDB, clearValue);

Copilot uses AI. Check for mistakes.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings January 23, 2026 05:27
Vismalskumar0 and others added 3 commits January 23, 2026 11:00
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
RDK_LOG(RDK_LOG_INFO, LOG_RFCMGR, "[%s][%d] Bootstrap Clearing DB Value: %s\n", __FUNCTION__,__LINE__,BootstrapClearDB.c_str());
set_RFCProperty(name, BootstrapClearDB, clearValue);
RDK_LOG(RDK_LOG_INFO, LOG_RFCMGR, "[%s][%d] ConfigChangeTime: %s\n", __FUNCTION__,__LINE__,ConfigChangeTime.c_str());
set_RFCProperty(name, ConfigChangeTimeKey, ConfigChangeTime);
Copy link
Contributor

Choose a reason for hiding this comment

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

Coverity Issue - Variable copied when it could be moved

"ConfigChangeTime" is passed-by-value as parameter to "std::__cxx11::basic_string<char, std::char_traits, std::allocator >::basic_string(std::__cxx11::basic_string<char, std::char_traits, std::allocator > const &)", when it could be moved instead.

Low Impact, CWE-none
COPY_INSTEAD_OF_MOVE

How to fix

Use "std::move(""ConfigChangeTime"")" instead of "ConfigChangeTime".

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copy link
Contributor

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

Copilot reviewed 1 out of 1 changed files in this pull request and generated 1 comment.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings January 23, 2026 05:34
Copy link
Contributor

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

Copilot reviewed 1 out of 1 changed files in this pull request and generated 3 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

std::string ConfigSetHashName = "ConfigSetHash";
std::string ConfigSetHash_key = "Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Control.ConfigSetHash";
set_RFCProperty(ConfigSetHashName, ConfigSetHash_key, configSetHash);
set_RFCProperty(std::move(ConfigSetHashName), std::move(ConfigSetHash_key), configSetHash);
Copy link

Copilot AI Jan 23, 2026

Choose a reason for hiding this comment

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

Unnecessary use of std::move on local variables that are only used once. The function signature set_RFCProperty(std::string name, std::string key, std::string value) takes all parameters by value, which means they will be copied regardless of std::move. Since ConfigSetHashName and ConfigSetHash_key are local variables that are not used after this call, the compiler's copy elision and move semantics will automatically optimize this. Using std::move here doesn't provide any benefit and makes the code less readable.

Suggested change
set_RFCProperty(std::move(ConfigSetHashName), std::move(ConfigSetHash_key), configSetHash);
set_RFCProperty(ConfigSetHashName, ConfigSetHash_key, configSetHash);

Copilot uses AI. Check for mistakes.
std::string ConfigSetTimeName = "ConfigSetTime";
std::string ConfigSetTime_Key = "Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Control.ConfigSetTime";
set_RFCProperty(ConfigSetTimeName, ConfigSetTime_Key, timestampString);
set_RFCProperty(std::move(ConfigSetTimeName), std::move(ConfigSetTime_Key), timestampString);
Copy link

Copilot AI Jan 23, 2026

Choose a reason for hiding this comment

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

Unnecessary use of std::move on local variables that are only used once. The function signature set_RFCProperty(std::string name, std::string key, std::string value) takes all parameters by value, which means they will be copied regardless of std::move. Since ConfigSetTimeName and ConfigSetTime_Key are local variables that are not used after this call, the compiler's copy elision and move semantics will automatically optimize this. Using std::move here doesn't provide any benefit and makes the code less readable.

Copilot uses AI. Check for mistakes.
Comment on lines +1990 to +2001
if(file_dwnl.hashData->hashvalue != nullptr)
{
free(file_dwnl.hashData->hashvalue);
file_dwnl.hashData->hashvalue = nullptr;
}
if(file_dwnl.hashData->hashtime != nullptr)
{
free(file_dwnl.hashData->hashtime);
file_dwnl.hashData->hashtime = nullptr;
}
free(file_dwnl.hashData);
file_dwnl.hashData = nullptr;
Copy link

Copilot AI Jan 23, 2026

Choose a reason for hiding this comment

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

Inconsistent indentation: Lines 1990, 1993, and 2001 use tabs while surrounding code uses spaces. This violates the consistent indentation pattern seen throughout the file. Consider maintaining consistent indentation style (appears to be 4 spaces based on surrounding context).

Copilot uses AI. Check for mistakes.
touch_file.close();

RDK_LOG(RDK_LOG_INFO, LOG_RFCMGR, "[%s][%d] Clearing DB Value: %s\n", __FUNCTION__,__LINE__,ClearDB.c_str());
set_RFCProperty(name, ClearDB, clearValue);
Copy link
Contributor

Choose a reason for hiding this comment

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

Coverity Issue - Variable copied when it could be moved

"ClearDB" is passed-by-value as parameter to "std::__cxx11::basic_string<char, std::char_traits, std::allocator >::basic_string(std::__cxx11::basic_string<char, std::char_traits, std::allocator > const &)", when it could be moved instead.

Low Impact, CWE-none
COPY_INSTEAD_OF_MOVE

How to fix

Use "std::move(""ClearDB"")" instead of "ClearDB".


RDK_LOG(RDK_LOG_INFO, LOG_RFCMGR, "[%s][%d] Clearing DB Value: %s\n", __FUNCTION__,__LINE__,ClearDB.c_str());
RDK_LOG(RDK_LOG_INFO, LOG_RFCMGR, "[%s][%d] Bootstrap Clearing DB Value: %s\n", __FUNCTION__,__LINE__,BootstrapClearDB.c_str());
set_RFCProperty(name, BootstrapClearDB, clearValue);
Copy link
Contributor

Choose a reason for hiding this comment

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

Coverity Issue - Variable copied when it could be moved

"BootstrapClearDB" is passed-by-value as parameter to "std::__cxx11::basic_string<char, std::char_traits, std::allocator >::basic_string(std::__cxx11::basic_string<char, std::char_traits, std::allocator > const &)", when it could be moved instead.

Low Impact, CWE-none
COPY_INSTEAD_OF_MOVE

How to fix

Use "std::move(""BootstrapClearDB"")" instead of "BootstrapClearDB".

RDK_LOG(RDK_LOG_INFO, LOG_RFCMGR, "[%s][%d] Reload Cache Key: %s\n", __FUNCTION__,__LINE__,reloadCacheKey.c_str());
set_RFCProperty(name, ClearDBEndKey, clearValue);
set_RFCProperty(name, BootstrapClearDBEndKey, clearValue);
set_RFCProperty(name, reloadCacheKey, clearValue);
Copy link
Contributor

Choose a reason for hiding this comment

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

Coverity Issue - Variable copied when it could be moved

"reloadCacheKey" is passed-by-value as parameter to "std::__cxx11::basic_string<char, std::char_traits, std::allocator >::basic_string(std::__cxx11::basic_string<char, std::char_traits, std::allocator > const &)", when it could be moved instead.

Low Impact, CWE-none
COPY_INSTEAD_OF_MOVE

How to fix

Use "std::move(""reloadCacheKey"")" instead of "reloadCacheKey".

RDK_LOG(RDK_LOG_INFO, LOG_RFCMGR, "[%s][%d] Clearing DBEnd Key Value: %s\n", __FUNCTION__,__LINE__,ClearDBEndKey.c_str());
RDK_LOG(RDK_LOG_INFO, LOG_RFCMGR, "[%s][%d] Bootstrap Clearing DBEnd Key Value: %s\n", __FUNCTION__,__LINE__,BootstrapClearDBEndKey.c_str());
RDK_LOG(RDK_LOG_INFO, LOG_RFCMGR, "[%s][%d] Reload Cache Key: %s\n", __FUNCTION__,__LINE__,reloadCacheKey.c_str());
set_RFCProperty(name, ClearDBEndKey, clearValue);
Copy link
Contributor

Choose a reason for hiding this comment

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

Coverity Issue - Variable copied when it could be moved

"ClearDBEndKey" is passed-by-value as parameter to "std::__cxx11::basic_string<char, std::char_traits, std::allocator >::basic_string(std::__cxx11::basic_string<char, std::char_traits, std::allocator > const &)", when it could be moved instead.

Low Impact, CWE-none
COPY_INSTEAD_OF_MOVE

How to fix

Use "std::move(""ClearDBEndKey"")" instead of "ClearDBEndKey".

RDK_LOG(RDK_LOG_INFO, LOG_RFCMGR, "[%s][%d] Bootstrap Clearing DBEnd Key Value: %s\n", __FUNCTION__,__LINE__,BootstrapClearDBEndKey.c_str());
RDK_LOG(RDK_LOG_INFO, LOG_RFCMGR, "[%s][%d] Reload Cache Key: %s\n", __FUNCTION__,__LINE__,reloadCacheKey.c_str());
set_RFCProperty(name, ClearDBEndKey, clearValue);
set_RFCProperty(name, BootstrapClearDBEndKey, clearValue);
Copy link
Contributor

Choose a reason for hiding this comment

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

Coverity Issue - Variable copied when it could be moved

"BootstrapClearDBEndKey" is passed-by-value as parameter to "std::__cxx11::basic_string<char, std::char_traits, std::allocator >::basic_string(std::__cxx11::basic_string<char, std::char_traits, std::allocator > const &)", when it could be moved instead.

Low Impact, CWE-none
COPY_INSTEAD_OF_MOVE

How to fix

Use "std::move(""BootstrapClearDBEndKey"")" instead of "BootstrapClearDBEndKey".

@nhanasi
Copy link
Contributor

nhanasi commented Jan 23, 2026

@Vismalskumar0 -please fix the coverity failures and share the Dev test lgos

Copy link

Copilot AI commented Jan 27, 2026

@Vismalskumar0 I've opened a new pull request, #160, to work on those changes. Once the pull request is ready, I'll request review from you.

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.

4 participants