Skip to content
43 changes: 28 additions & 15 deletions rfcMgr/rfc_xconf_handler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1295,13 +1295,12 @@ void RuntimeFeatureControlProcessor::clearDB(void)
std::ofstream touch_file(TR181STOREFILE);
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".

set_RFCProperty(name, BootstrapClearDB, clearValue);
set_RFCProperty(name, ConfigChangeTimeKey, ConfigChangeTime);

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] 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".


#else
RDK_LOG(RDK_LOG_INFO, LOG_RFCMGR, "[%s][%d] Clearing tr181 store\n", __FUNCTION__,__LINE__);
Expand Down Expand Up @@ -1370,14 +1369,14 @@ void RuntimeFeatureControlProcessor::clearDBEnd(void){
std::string ClearDBEndKey = "Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Control.ClearDBEnd";
std::string BootstrapClearDBEndKey = "Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Bootstrap.Control.ClearDBEnd";
std::string reloadCacheKey = "RFC_CONTROL_RELOADCACHE";

set_RFCProperty(name, ClearDBEndKey, clearValue);
set_RFCProperty(name, BootstrapClearDBEndKey, clearValue);
set_RFCProperty(name, reloadCacheKey, clearValue);

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".

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".

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".


}

void RuntimeFeatureControlProcessor::updateHashInDB(std::string configSetHash)
Expand All @@ -1387,7 +1386,7 @@ void RuntimeFeatureControlProcessor::updateHashInDB(std::string configSetHash)
#if !defined(RDKB_SUPPORT)
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.
#else
const std::string RFC_RAM_PATH = "/tmp/RFC";
std::string filePath = RFC_RAM_PATH + "/.hashValue";
Expand Down Expand Up @@ -1415,7 +1414,7 @@ void RuntimeFeatureControlProcessor::updateTimeInDB(std::string timestampString)
#if !defined(RDKB_SUPPORT)
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.
#else
const std::string RFC_RAM_PATH = "/tmp/RFC";
std::string filePath = RFC_RAM_PATH + "/.timeValue";
Expand Down Expand Up @@ -1466,15 +1465,15 @@ void RuntimeFeatureControlProcessor::updateHashAndTimeInDB(char *curlHeaderResp)
// Output the value
RDK_LOG(RDK_LOG_INFO, LOG_RFCMGR, "configSetHash value: %s\n", configSetHashValue.c_str());

updateHashInDB(configSetHashValue);
updateHashInDB(std::move(configSetHashValue));
} else {
RDK_LOG(RDK_LOG_ERROR, LOG_RFCMGR, "configSetHash not found in httpHeader!");
}


std::time_t timestamp = std::time(nullptr); // Get current timestamp
std::string timestampString = std::to_string(timestamp);
updateTimeInDB(timestampString);
updateTimeInDB(std::move(timestampString));

std::fstream fs;
fs.open(RFC_SYNC_DONE, std::ios::out);
Expand Down Expand Up @@ -1988,7 +1987,18 @@ int RuntimeFeatureControlProcessor::DownloadRuntimeFeatutres(DownloadData *pDwnL
}
if(file_dwnl.hashData != nullptr)
{
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;
Comment on lines +1990 to +2001
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

Comment on lines +1990 to +2001
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.
}

if (_url_validation_in_progress)
Expand Down Expand Up @@ -2021,7 +2031,10 @@ int RuntimeFeatureControlProcessor::DownloadRuntimeFeatutres(DownloadData *pDwnL
case 83:
case 90:
case 91:
NotifyTelemetry2ErrorCode(curl_ret_code);
NotifyTelemetry2ErrorCode(curl_ret_code);
break;
default:
break;
}

if((curl_ret_code == 0) && (httpCode == 404))
Expand Down Expand Up @@ -2480,7 +2493,7 @@ void RuntimeFeatureControlProcessor::processXconfResponseConfigDataPart(JSON *fe
}
std::string data = "TR181: " + newKey + " " + newValue;

paramList.push_back(data);
paramList.push_back(std::move(data));
}

updateTR181File(TR181_FILE_LIST, paramList);
Expand Down Expand Up @@ -2887,7 +2900,7 @@ int RuntimeFeatureControlProcessor::ProcessXconfUrl(const char *XconfUrl)
std::string FQDN = _xconf_server_url;
_xconf_server_url = std::string(XconfUrl) + "/featureControl/getSettings";
std::stringstream url = CreateXconfHTTPUrl();
_xconf_server_url = FQDN;
_xconf_server_url = std::move(FQDN);

DownloadData DwnLoc, HeaderDwnLoc;
InitDownloadData(&DwnLoc);
Expand Down
Loading