Update rfc_xconf_handler.cpp#185
Conversation
There was a problem hiding this comment.
Pull request overview
This PR updates RuntimeFeatureControlProcessor::clearDB() to pass arguments to set_RFCProperty using std::move, presumably to reduce string copies when writing TR-181/RFC backing-store values.
Changes:
- Replaced three
set_RFCProperty(name, key, value)calls withset_RFCProperty(std::move(...), ...)inclearDB().
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| set_RFCProperty(std::move(name), std::move(ClearDB), std::move(clearValue)); | ||
| set_RFCProperty(std::move(name), std::move(BootstrapClearDB), std::move(clearValue)); | ||
| set_RFCProperty(std::move(name), std::move(ConfigChangeTimeKey), std::move(ConfigChangeTime)); |
There was a problem hiding this comment.
std::move(name) is used in the first set_RFCProperty call and then name is moved again in subsequent calls. After the first move, name is left in a moved-from state (typically empty), so the later set_RFCProperty calls may write to an invalid/empty namespace and fail. Use name normally (no move) or create separate copies for each call / change set_RFCProperty to take const std::string&/std::string_view if you’re trying to avoid copies.
| set_RFCProperty(std::move(name), std::move(ClearDB), std::move(clearValue)); | |
| set_RFCProperty(std::move(name), std::move(BootstrapClearDB), std::move(clearValue)); | |
| set_RFCProperty(std::move(name), std::move(ConfigChangeTimeKey), std::move(ConfigChangeTime)); | |
| set_RFCProperty(name, ClearDB, clearValue); | |
| set_RFCProperty(name, BootstrapClearDB, clearValue); | |
| set_RFCProperty(name, ConfigChangeTimeKey, ConfigChangeTime); |
| set_RFCProperty(std::move(name), std::move(ClearDB), std::move(clearValue)); | ||
| set_RFCProperty(std::move(name), std::move(BootstrapClearDB), std::move(clearValue)); | ||
| set_RFCProperty(std::move(name), std::move(ConfigChangeTimeKey), std::move(ConfigChangeTime)); | ||
|
|
||
| RDK_LOG(RDK_LOG_INFO, LOG_RFCMGR, "[%s][%d] Clearing DB Value: %s\n", __FUNCTION__,__LINE__,ClearDB.c_str()); |
There was a problem hiding this comment.
ClearDB, BootstrapClearDB, ConfigChangeTimeKey, and ConfigChangeTime are moved into set_RFCProperty and then immediately used afterwards in log statements. This will typically log empty strings (moved-from state) and makes debugging harder. Either avoid moving these variables or log before moving / keep separate variables for logging.
Coverity Issue - Using a moved object"ConfigChangeTime" is used after it has been already moved. High Impact, CWE-457 Issue locationThis issue was discovered outside the diff for this Pull Request. You can find it at: |
| set_RFCProperty(std::move(name), std::move(BootstrapClearDB), std::move(clearValue)); | ||
| set_RFCProperty(std::move(name), std::move(ConfigChangeTimeKey), std::move(ConfigChangeTime)); | ||
|
|
||
| RDK_LOG(RDK_LOG_INFO, LOG_RFCMGR, "[%s][%d] Clearing DB Value: %s\n", __FUNCTION__,__LINE__,ClearDB.c_str()); |
There was a problem hiding this comment.
Coverity issue no longer present as of: undefined
Show issue
Coverity Issue - Using a moved object
"ClearDB" is used after it has been already moved.
High Impact, CWE-457
USE_AFTER_MOVE
| set_RFCProperty(name, BootstrapClearDB, clearValue); | ||
| set_RFCProperty(name, ConfigChangeTimeKey, ConfigChangeTime); | ||
| set_RFCProperty(std::move(name), std::move(ClearDB), std::move(clearValue)); | ||
| set_RFCProperty(std::move(name), std::move(BootstrapClearDB), std::move(clearValue)); |
There was a problem hiding this comment.
Coverity issue no longer present as of: undefined
Show issue
Coverity Issue - Using a moved object
"name" is used after it has been already moved.
High Impact, CWE-457
USE_AFTER_MOVE
| set_RFCProperty(std::move(name), std::move(ConfigChangeTimeKey), std::move(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()); |
There was a problem hiding this comment.
Coverity issue no longer present as of: undefined
Show issue
Coverity Issue - Using a moved object
"BootstrapClearDB" is used after it has been already moved.
High Impact, CWE-457
USE_AFTER_MOVE
| set_RFCProperty(name, BootstrapClearDB, clearValue); | ||
| set_RFCProperty(name, ConfigChangeTimeKey, ConfigChangeTime); | ||
| set_RFCProperty(std::move(name), std::move(ClearDB), std::move(clearValue)); | ||
| set_RFCProperty(std::move(name), std::move(BootstrapClearDB), std::move(clearValue)); |
There was a problem hiding this comment.
Coverity issue no longer present as of: undefined
Show issue
Coverity Issue - Using a moved object
"clearValue" is used after it has been already moved.
High Impact, CWE-457
USE_AFTER_MOVE
| std::string clearValue_mv(std::move(clearValue)); | ||
|
|
||
| set_RFCProperty(name_mv, std::move(ClearDB), clearValue_mv); | ||
| set_RFCProperty(name_mv, std::move(BootstrapClearDB), clearValue_mv); |
There was a problem hiding this comment.
Coverity issue no longer present as of: undefined
Show issue
Coverity Issue - Variable copied when it could be moved
"clearValue_mv" 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(""clearValue_mv"")" instead of "clearValue_mv".
|
|
||
| set_RFCProperty(name_mv, std::move(ClearDB), clearValue_mv); | ||
| set_RFCProperty(name_mv, std::move(BootstrapClearDB), clearValue_mv); | ||
| set_RFCProperty(name_mv, std::move(ConfigChangeTimeKey), std::move(ConfigChangeTime)); |
There was a problem hiding this comment.
Coverity issue no longer present as of: undefined
Show issue
Coverity Issue - Variable copied when it could be moved
"name_mv" 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(""name_mv"")" instead of "name_mv".
There was a problem hiding this comment.
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.
| set_RFCProperty(name, ClearDB, clearValue); | ||
| set_RFCProperty(name, BootstrapClearDB, clearValue); | ||
| set_RFCProperty(name, ConfigChangeTimeKey, ConfigChangeTime); | ||
| set_RFCProperty(name, ClearDB, std::move(clearValue)); |
There was a problem hiding this comment.
Indentation on this line uses a tab while surrounding lines use spaces, which makes formatting inconsistent. Align indentation with the existing spacing style in this function/file.
| set_RFCProperty(name, ClearDB, std::move(clearValue)); | |
| set_RFCProperty(name, ClearDB, std::move(clearValue)); |
| set_RFCProperty(name, BootstrapClearDB, clearValue); | ||
| set_RFCProperty(name, ConfigChangeTimeKey, ConfigChangeTime); | ||
| set_RFCProperty(name, ClearDB, std::move(clearValue)); | ||
| set_RFCProperty(name, BootstrapClearDB, std::move(clearValue)); |
There was a problem hiding this comment.
Coverity Issue - Using a moved object
"clearValue" is used after it has been already moved.
High Impact, CWE-457
USE_AFTER_MOVE
No description provided.