Skip to content

Feature/getprof rrd#450

Open
Abhinavpv28 wants to merge 12 commits into
developfrom
feature/getprof_rrd
Open

Feature/getprof rrd#450
Abhinavpv28 wants to merge 12 commits into
developfrom
feature/getprof_rrd

Conversation

@Abhinavpv28

Copy link
Copy Markdown
Contributor

No description provided.

@Abhinavpv28
Abhinavpv28 requested a review from a team as a code owner April 7, 2026 02:13
Copilot AI review requested due to automatic review settings April 7, 2026 02:13

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Adds support for selecting Remote Debugger “profile data” category via a new TR-181 parameter, and updates the existing getProfileData implementation to return filtered JSON based on that selection.

Changes:

  • Introduces setProfileData TR-181 parameter for Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Feature.RDKRemoteDebugger.
  • Adds a setter to store the requested category and updates getProfileData to return filtered results accordingly.
  • Updates the generic data model XML to expose the new parameter.

Reviewed changes

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

File Description
src/hostif/profiles/DeviceInfo/Device_DeviceInfo.h Adds new Remote Debugger parameter defines and static state for category selection.
src/hostif/profiles/DeviceInfo/Device_DeviceInfo.cpp Implements setProfileData handling and refactors getProfileData JSON filtering.
src/hostif/parodusClient/waldb/data-model/data-model-generic.xml Exposes setProfileData as a readWrite string parameter in the data model.
src/hostif/handlers/src/hostIf_DeviceClient_ReqHandler.cpp Adds request routing for the new parameter (currently in the GET path).

Comment on lines +502 to +505
else if (strcasecmp(stMsgData->paramName,"Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Feature.RDKRemoteDebugger.setProfileData") == 0)
{
ret = pIface->set_Device_DeviceInfo_X_RDKCENTRAL_COM_RDKRemoteDebuggersetProfileData(stMsgData);
}

Copilot AI Apr 7, 2026

Copy link

Choose a reason for hiding this comment

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

handleGetMsg is dispatching the readWrite parameter ...RDKRemoteDebugger.setProfileData by calling the setter. A GET for this parameter would unexpectedly mutate internal state (e.g., setting the category to an empty string) and bypass the normal SET path. This branch should be removed from handleGetMsg and handled via handleSetMsg (it already routes RFC params through set_xRDKCentralComRFC).

Suggested change
else if (strcasecmp(stMsgData->paramName,"Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Feature.RDKRemoteDebugger.setProfileData") == 0)
{
ret = pIface->set_Device_DeviceInfo_X_RDKCENTRAL_COM_RDKRemoteDebuggersetProfileData(stMsgData);
}

Copilot uses AI. Check for mistakes.
Comment on lines +4413 to +4444
// Check if setProfileData was called to determine response format
if (strcasecmp(m_rdkRemoteDebuggerProfileCategory.c_str(), "all") == 0) {
// Return filtered profile data for all categories - exclude Commands and Timeout fields
response = cJSON_CreateObject();
if (!response) {
free(fileBuf);
cJSON_Delete(root);
return retStatus;
}
cJSON *arr = cJSON_CreateArray();
if (!arr)
{

cJSON *category = NULL;
cJSON_ArrayForEach(category, root) {
if (cJSON_IsObject(category)) {
cJSON *issueTypesArray = cJSON_CreateArray();
if (!issueTypesArray) {
free(fileBuf);
cJSON_Delete(root);
cJSON_Delete(response);
return retStatus;
}

cJSON *issueType = NULL;
cJSON_ArrayForEach(issueType, category) {
// Only add the issue type name, ignore Commands/Timeout/DebugCommands/DebugTimeout
if (cJSON_IsObject(issueType) && issueType->string) {
cJSON_AddItemToArray(issueTypesArray, cJSON_CreateString(issueType->string));
}
}

if (cJSON_GetArraySize(issueTypesArray) > 0) {
cJSON_AddItemToObject(response, category->string, issueTypesArray);
} else {

Copilot AI Apr 7, 2026

Copy link

Choose a reason for hiding this comment

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

When building the JSON response, cJSON_AddItemToObject(response, category->string, ...) assumes category->string is non-null. If /etc/rrd/remote_debugger.json ever contains an array (or any non-object root/child), category->string can be null and this will crash. Please validate root is an object and guard category->string before using it as an object key.

Copilot uses AI. Check for mistakes.
return retStatus;
}

bytesRead = fread(fileBuf, 1U, (size_t)fileSz, fp);

Copilot AI Apr 7, 2026

Copy link

Choose a reason for hiding this comment

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

fread's return value isn’t validated against the expected file size and ferror(fp) isn’t checked. A short read can lead to parsing truncated JSON and returning misleading data. Consider treating bytesRead != (size_t)fileSz as an error (or loop until EOF) and handle ferror explicitly.

Suggested change
bytesRead = fread(fileBuf, 1U, (size_t)fileSz, fp);
bytesRead = fread(fileBuf, 1U, (size_t)fileSz, fp);
if (bytesRead != (size_t)fileSz) {
if (ferror(fp)) {
RDK_LOG(RDK_LOG_ERROR, LOG_TR69HOSTIF, "[%s] fread failed for %s\n", __FUNCTION__, filename);
} else {
RDK_LOG(RDK_LOG_ERROR, LOG_TR69HOSTIF, "[%s] Short read for %s: expected %ld bytes, got %zu bytes\n",
__FUNCTION__, filename, fileSz, bytesRead);
}
fclose(fp);
fp = nullptr;
free(fileBuf);
fileBuf = nullptr;
return retStatus;
}

Copilot uses AI. Check for mistakes.
char *outStr = nullptr;
size_t outLen = 0;

RDK_LOG(RDK_LOG_TRACE1, LOG_TR69HOSTIF, "[%s] Entering …\n", __FUNCTION__);

Copilot AI Apr 7, 2026

Copy link

Choose a reason for hiding this comment

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

The log message contains a Unicode ellipsis character (). Some embedded toolchains/log pipelines assume ASCII and can fail or garble logs; prefer plain ... in source strings for portability.

Suggested change
RDK_LOG(RDK_LOG_TRACE1, LOG_TR69HOSTIF, "[%s] Entering \n", __FUNCTION__);
RDK_LOG(RDK_LOG_TRACE1, LOG_TR69HOSTIF, "[%s] Entering ...\n", __FUNCTION__);

Copilot uses AI. Check for mistakes.
Comment on lines +4541 to 4543

RDK_LOG(RDK_LOG_INFO, LOG_TR69HOSTIF, "[%s] Returning profile data: %s\n", __FUNCTION__, outStr);
retStatus = OK;

Copilot AI Apr 7, 2026

Copy link

Choose a reason for hiding this comment

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

Logging the full generated JSON (outStr) at INFO level can be noisy and potentially large, impacting storage/performance on embedded targets. Consider logging only the selected category and output length (or downgrade to DEBUG).

Copilot uses AI. Check for mistakes.

#ifdef USE_REMOTE_DEBUGGER
static string m_rdkRemoteDebuggerProfileCategory;
static string m_rdkRemoteDebuggerProfileData;

Copilot AI Apr 7, 2026

Copy link

Choose a reason for hiding this comment

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

m_rdkRemoteDebuggerProfileData is declared/defined but not referenced anywhere in the codebase. Keeping unused static state increases confusion and maintenance cost; consider removing it or wiring it into the implementation.

Suggested change
static string m_rdkRemoteDebuggerProfileData;

Copilot uses AI. Check for mistakes.
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.

2 participants