Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* If not stated otherwise in this file or this component's Licenses.txt file the

Check failure on line 2 in source/scripts/init/src/apply_system_defaults/apply_system_defaults.c

View workflow job for this annotation

GitHub Actions / call-fossid-workflow / Fossid Annotate PR

FossID License Issue Detected

Source code with 'BSD-Intel' license found in local file 'source/scripts/init/src/apply_system_defaults/apply_system_defaults.c' (Match: rdkb/components/opensource/ccsp/Utopia/rdkb/components/opensource/ccsp/Utopia/1, 3565 lines, url: https://code.rdkcentral.com/r/plugins/gitiles/rdkb/components/opensource/ccsp/Utopia/+archive/RDKB-TEST-RELEASE-1.tar.gz, file: source/scripts/init/src/apply_system_defaults/apply_system_defaults.c)

Check failure on line 2 in source/scripts/init/src/apply_system_defaults/apply_system_defaults.c

View workflow job for this annotation

GitHub Actions / call-fossid-workflow / Fossid Annotate PR

FossID License Issue Detected

Source code with 'BSD-Intel' license found in local file 'source/scripts/init/src/apply_system_defaults/apply_system_defaults.c' (Match: rdkb/components/opensource/ccsp/Utopia/rdkb/components/opensource/ccsp/Utopia/1, 3565 lines, url: https://code.rdkcentral.com/r/plugins/gitiles/rdkb/components/opensource/ccsp/Utopia/+archive/RDKB-RELEASE-TEST-DUNFELL-1.tar.gz, file: source/scripts/init/src/apply_system_defaults/apply_system_defaults.c)

Check failure on line 2 in source/scripts/init/src/apply_system_defaults/apply_system_defaults.c

View workflow job for this annotation

GitHub Actions / call-fossid-workflow / Fossid Annotate PR

FossID License Issue Detected

Source code with 'BSD-Intel' license found in local file 'source/scripts/init/src/apply_system_defaults/apply_system_defaults.c' (Match: rdkb/components/opensource/ccsp/Utopia/rdkb/components/opensource/ccsp/Utopia/2, 3565 lines, url: https://code.rdkcentral.com/r/plugins/gitiles/rdkb/components/opensource/ccsp/Utopia/+archive/RDKB-RELEASE-TEST-DUNFELL-2.tar.gz, file: source/scripts/init/src/apply_system_defaults/apply_system_defaults.c)
* following copyright and licenses apply:
*
* Copyright 2015 RDK Management
Expand Down Expand Up @@ -3317,6 +3317,50 @@
}
#endif

#if defined (_ONESTACK_PRODUCT_REQ_)

#define DEV_PROP_FILE "/etc/device.properties"
static const char *g_dev_prop_params[] = {
"IS_BCI=yes",
NULL
};

static int addPartnerDefaultsToDevPropFile()
{
FILE *fp = NULL;
Comment on lines +3328 to +3330
Copy link

Copilot AI Jan 27, 2026

Choose a reason for hiding this comment

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

This new no-argument function is declared as addPartnerDefaultsToDevPropFile() instead of addPartnerDefaultsToDevPropFile(void). The rest of this file uses the explicit (void) style for no-arg functions (e.g., set_defaults(void) at apply_system_defaults.c:558), so aligning this signature avoids old-style C function declarations.

Copilot uses AI. Check for mistakes.
//check file for existence
if (access(DEV_PROP_FILE, F_OK) != 0)
{
APPLY_PRINT("[Utopia - %s]File %s does not exist\n",__FUNCTION__,DEV_PROP_FILE);
return 1;
}

//open for writing
fp = fopen(DEV_PROP_FILE, "a");
if (fp == NULL)
{
APPLY_PRINT("[Utopia - %s]File %s could not open for writing\n",__FUNCTION__,DEV_PROP_FILE);
Copy link

Copilot AI Jan 27, 2026

Choose a reason for hiding this comment

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

Log message grammar: "File %s could not open for writing" should be phrased as "could not be opened for writing" (or similar) for clarity in logs.

Suggested change
APPLY_PRINT("[Utopia - %s]File %s could not open for writing\n",__FUNCTION__,DEV_PROP_FILE);
APPLY_PRINT("[Utopia - %s]File %s could not be opened for writing\n",__FUNCTION__,DEV_PROP_FILE);

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

int i = 0;
for (i = 0; g_dev_prop_params[i] != NULL; i++)
{
if (fprintf(fp, "%s\n", g_dev_prop_params[i]) < 0)
{
APPLY_PRINT("[Utopia - %s]File %s write failed\n",__FUNCTION__,DEV_PROP_FILE);
fclose(fp);
return 1;
}
}

APPLY_PRINT("[Utopia - %s]File %s write successful\n",__FUNCTION__,DEV_PROP_FILE);

fclose(fp);

Comment on lines +3330 to +3360
Copy link

Copilot AI Jan 27, 2026

Choose a reason for hiding this comment

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

Appending "IS_BCI=yes" unconditionally makes this change non-idempotent: every time apply_system_defaults runs (e.g., across reboots) it will add another duplicate line, and it also won’t correct an existing "IS_BCI" key set to a different value. Consider parsing /etc/device.properties to detect an existing IS_BCI entry and either skip the append if already set to "yes" or rewrite the file (temp file + rename) to update/replace the key.

Suggested change
FILE *fp = NULL;
//check file for existence
if (access(DEV_PROP_FILE, F_OK) != 0)
{
APPLY_PRINT("[Utopia - %s]File %s does not exist\n",__FUNCTION__,DEV_PROP_FILE);
return 1;
}
//open for writing
fp = fopen(DEV_PROP_FILE, "a");
if (fp == NULL)
{
APPLY_PRINT("[Utopia - %s]File %s could not open for writing\n",__FUNCTION__,DEV_PROP_FILE);
return 1;
}
int i = 0;
for (i = 0; g_dev_prop_params[i] != NULL; i++)
{
if (fprintf(fp, "%s\n", g_dev_prop_params[i]) < 0)
{
APPLY_PRINT("[Utopia - %s]File %s write failed\n",__FUNCTION__,DEV_PROP_FILE);
fclose(fp);
return 1;
}
}
APPLY_PRINT("[Utopia - %s]File %s write successful\n",__FUNCTION__,DEV_PROP_FILE);
fclose(fp);
FILE *in_fp = NULL;
FILE *out_fp = NULL;
char tmp_path[256];
char line[512];
bool is_bci_present = false;
/* check file for existence */
if (access(DEV_PROP_FILE, F_OK) != 0)
{
APPLY_PRINT("[Utopia - %s]File %s does not exist\n", __FUNCTION__, DEV_PROP_FILE);
return 1;
}
/* open original file for reading */
in_fp = fopen(DEV_PROP_FILE, "r");
if (in_fp == NULL)
{
APPLY_PRINT("[Utopia - %s]File %s could not open for reading\n", __FUNCTION__, DEV_PROP_FILE);
return 1;
}
/* create temporary file for writing updated content */
if (snprintf(tmp_path, sizeof(tmp_path), "%s.tmp", DEV_PROP_FILE) >= (int)sizeof(tmp_path))
{
APPLY_PRINT("[Utopia - %s]Temporary path buffer too small for %s\n", __FUNCTION__, DEV_PROP_FILE);
fclose(in_fp);
return 1;
}
out_fp = fopen(tmp_path, "w");
if (out_fp == NULL)
{
APPLY_PRINT("[Utopia - %s]File %s could not open for writing\n", __FUNCTION__, tmp_path);
fclose(in_fp);
return 1;
}
/* copy existing lines, normalizing any IS_BCI entry to IS_BCI=yes */
while (fgets(line, sizeof(line), in_fp) != NULL)
{
if (strncmp(line, "IS_BCI=", 7) == 0)
{
if (fputs("IS_BCI=yes\n", out_fp) == EOF)
{
APPLY_PRINT("[Utopia - %s]File %s write failed while updating IS_BCI\n", __FUNCTION__, tmp_path);
fclose(in_fp);
fclose(out_fp);
unlink(tmp_path);
return 1;
}
is_bci_present = true;
}
else
{
if (fputs(line, out_fp) == EOF)
{
APPLY_PRINT("[Utopia - %s]File %s write failed while copying\n", __FUNCTION__, tmp_path);
fclose(in_fp);
fclose(out_fp);
unlink(tmp_path);
return 1;
}
}
}
/* append any additional parameters, avoiding duplicate IS_BCI entries */
int i = 0;
for (i = 0; g_dev_prop_params[i] != NULL; i++)
{
const char *param = g_dev_prop_params[i];
if (strncmp(param, "IS_BCI=", 7) == 0)
{
if (is_bci_present)
{
/* already present and normalized, skip to keep idempotent */
continue;
}
is_bci_present = true;
}
if (fprintf(out_fp, "%s\n", param) < 0)
{
APPLY_PRINT("[Utopia - %s]File %s write failed\n", __FUNCTION__, tmp_path);
fclose(in_fp);
fclose(out_fp);
unlink(tmp_path);
return 1;
}
}
fclose(in_fp);
if (fclose(out_fp) == EOF)
{
APPLY_PRINT("[Utopia - %s]File %s close failed\n", __FUNCTION__, tmp_path);
unlink(tmp_path);
return 1;
}
if (rename(tmp_path, DEV_PROP_FILE) != 0)
{
APPLY_PRINT("[Utopia - %s]Failed to replace %s with %s\n", __FUNCTION__, DEV_PROP_FILE, tmp_path);
unlink(tmp_path);
return 1;
}
APPLY_PRINT("[Utopia - %s]File %s write successful\n", __FUNCTION__, DEV_PROP_FILE);

Copilot uses AI. Check for mistakes.
return 0;
}
#endif
/*
* main()
*/
Expand Down Expand Up @@ -3531,6 +3575,16 @@

sysevent_close(global_fd, global_id);

#if defined (_ONESTACK_PRODUCT_REQ_)
if (0 == strcasecmp (PartnerID, "comcast-business"))
{
if ( 1 == addPartnerDefaultsToDevPropFile())
Copy link

Copilot AI Jan 27, 2026

Choose a reason for hiding this comment

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

The caller checks 1 == addPartnerDefaultsToDevPropFile(), which silently ignores failures if the function ever returns any non-1 error code. Since this function follows the common 0 == success convention, it’s safer to check != 0 (or < 0/> 0 consistently) and treat any non-zero as failure (similar to the nearby if (0 != ApplyPartnersObjectItemsIntoSysevents(...))).

Suggested change
if ( 1 == addPartnerDefaultsToDevPropFile())
if ( 0 != addPartnerDefaultsToDevPropFile())

Copilot uses AI. Check for mistakes.
{
APPLY_PRINT("%s - Failed to write default props to '%s'\n", __FUNCTION__, DEV_PROP_FILE);
}
}
#endif

return(0);
}

Loading