Skip to content

Feature/singlebld#38

Open
GoutamD2905 wants to merge 3 commits intodevelopfrom
feature/singlebld
Open

Feature/singlebld#38
GoutamD2905 wants to merge 3 commits intodevelopfrom
feature/singlebld

Conversation

@GoutamD2905
Copy link
Contributor

No description provided.

@GoutamD2905 GoutamD2905 requested review from a team as code owners January 23, 2026 03:36
Copilot AI review requested due to automatic review settings January 23, 2026 03:36
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 pull request introduces a new OneStack utility that retrieves partner ID information from multiple sources with a fallback mechanism. The utility is designed to query partner information from HAL APIs, file systems, and system configuration in order of priority.

Changes:

  • Added OneStack partner ID utility with multi-source fallback logic (HAL API → file → syscfg)
  • Implemented RDK logging infrastructure for the OneStack module
  • Integrated build system support with conditional compilation via --enable-onestack flag

Reviewed changes

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

Show a summary per file
File Description
source/onestack/onestack_log.h Header defining logging macros and initialization functions for OneStack module
source/onestack/onestack_log.c Implementation of RDK logger initialization/deinitialization for OneStack
source/onestack/onestack.h Public API header declaring partner ID retrieval function
source/onestack/onestack.c Core implementation with fallback logic and main utility program
source/onestack/Makefile.am Build configuration for OneStack utility with required library dependencies
source/Makefile.am Integration of OneStack subdirectory into build system
configure.ac Autoconf configuration for OneStack feature flag (enabled by default)

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


bool onestack_log_init(void)
{
if (rdk_logger_init(DEBUG_INI_PATH) != 0)
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.

The return value comparison is inconsistent with codebase conventions. In source/ServiceCtrl/servicecontrol_log.c:10, the pattern is to compare rdk_logger_init return value against RDK_SUCCESS, not against 0. The current comparison may work but doesn't follow the established pattern where RDK_SUCCESS is the symbolic constant used for success checks.

Copilot uses AI. Check for mistakes.
{
ONESTACK_DEBUG("%s: Deinitializing logging\n", __FUNCTION__);

if (rdk_logger_deinit() != 0)
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.

The return value comparison is inconsistent with codebase conventions. In source/ServiceCtrl/servicecontrol_log.c:27, the pattern is to compare rdk_logger_deinit return value against RDK_SUCCESS, not against 0. The current comparison may work but doesn't follow the established pattern where RDK_SUCCESS is the symbolic constant used for success checks.

Copilot uses AI. Check for mistakes.
Comment on lines +73 to +84
if (fgets(buffer, sizeof(buffer), fp))
{
trim_newline(buffer);

if (buffer[0] != '\0')
{
strncpy(pValue, buffer, size - 1);
pValue[size - 1] = '\0';
fclose(fp);
ONESTACK_INFO("%s: Partner ID retrieved from file: %s\n", __FUNCTION__, pValue);
return 0;
}
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.

The file read operation doesn't validate the content length before copying. If the file contains data longer than BUFLEN_256 (256 bytes), fgets will read up to 255 bytes plus null terminator, which is safe. However, the subsequent strncpy to pValue uses 'size - 1' which could be smaller than the buffer content. While this is handled correctly with null termination, there's no validation that the partner ID read from the file is within expected bounds or contains only valid characters. Consider adding validation to ensure the partner ID contains only expected characters (alphanumeric, hyphens, underscores) to prevent potential issues with downstream consumers.

Copilot uses AI. Check for mistakes.
for (retry = 0; retry < MAX_RETRY; retry++)
{
ONESTACK_DEBUG("%s: Attempting HAL API call (attempt %d/%d)\n", __FUNCTION__, retry + 1, MAX_RETRY);
if (platform_hal_getFactoryPartnerId(pValue) == 0 && pValue[0] != '\0')
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.

The platform_hal_getFactoryPartnerId function is called without validating if the buffer size is sufficient. The function is passed pValue which could have a size smaller than what the HAL function expects or writes. The HAL function doesn't receive the size parameter, so it cannot perform bounds checking. If the HAL function writes more data than the buffer can hold, this could result in a buffer overflow. Consider checking the minimum required buffer size for platform_hal_getFactoryPartnerId or ensuring that pValue is always large enough.

Copilot uses AI. Check for mistakes.
return -1;
}

int main(int argc, char *argv[])
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.

The argc and argv parameters in main are unused when ONESTACK_PRODUCT_REQ is defined. While this is not technically an error, consider marking them as unused with (void)argc; (void)argv; or using compiler-specific attributes to suppress warnings, as this is a common practice seen in other utilities like source/FwBankInfo/FwBank_Info.c which doesn't use its main parameters at all.

Copilot uses AI. Check for mistakes.
Comment on lines +133 to +140
onestack_log_deinit();
return 0;
}

ONESTACK_ERROR("Failed to retrieve Partner ID\n");
fprintf(stderr, "\n[FAILED] Unable to retrieve Partner ID\n");

onestack_log_deinit();
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.

The main function does not check the return value of onestack_log_deinit before returning. If deinitalization fails at line 133 or 140, the failure is silently ignored, which could lead to resource cleanup issues. Consider logging a warning if deinitalization fails.

Suggested change
onestack_log_deinit();
return 0;
}
ONESTACK_ERROR("Failed to retrieve Partner ID\n");
fprintf(stderr, "\n[FAILED] Unable to retrieve Partner ID\n");
onestack_log_deinit();
if (!onestack_log_deinit())
{
fprintf(stderr, "Warning: Logging deinitialization failed\n");
}
return 0;
}
ONESTACK_ERROR("Failed to retrieve Partner ID\n");
fprintf(stderr, "\n[FAILED] Unable to retrieve Partner ID\n");
if (!onestack_log_deinit())
{
fprintf(stderr, "Warning: Logging deinitialization failed\n");
}

Copilot uses AI. Check for mistakes.
yes) ONESTACK_ENABLE=true ;;
no) ONESTACK_ENABLE=false ;;
*) AC_MSG_ERROR([bad value ${enableval} for --enable-onestack]) ;;
esac],[ONESTACK_ENABLE=true])
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.

The OneStack utility defaults to enabled (ONESTACK_ENABLE=true) while most other optional features in configure.ac default to disabled (false). For example, dhcp_manager (line 136), socketExampleEnable (line 113), and wbCfgTestAppEnable (line 94) all default to false. Unless there's a specific reason for OneStack to be enabled by default, consider changing this to false for consistency with other optional utilities.

Copilot uses AI. Check for mistakes.
endif

if ONESTACK_ENABLE
ONESTACK = onestack
Copy link
Contributor

Choose a reason for hiding this comment

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

rename to something else like set_device_stackmode, apply_device_stackmode etc.

for (retry = 0; retry < MAX_RETRY; retry++)
{
ONESTACK_DEBUG("%s: Attempting HAL API call (attempt %d/%d)\n", __FUNCTION__, retry + 1, MAX_RETRY);
if (platform_hal_getFactoryPartnerId(pValue) == 0 && pValue[0] != '\0')
Copy link
Contributor

Choose a reason for hiding this comment

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

In our test devices, this may always return comcast eventhough activate partnerid is set to someother. Please check /nvram/.partnerID if not exists go with the HAL


// 3. Fallback to syscfg
ONESTACK_DEBUG("%s: Attempting syscfg_get for PartnerID\n", __FUNCTION__);
if (syscfg_get(NULL, "PartnerID", pValue, size) == 0 && pValue[0] != '\0')
Copy link
Contributor

Choose a reason for hiding this comment

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

This util expected to run even before syscfg. so this won't work.

#include <stdbool.h>
#include "rdk_debug.h"

#define LOG_MODULE "LOG.RDK.ONESTACK"
Copy link
Contributor

Choose a reason for hiding this comment

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

We don't need a separate log file, similar to apply system defaults, log to consolelog.txt.

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