Skip to content
Merged
Show file tree
Hide file tree
Changes from 8 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
2 changes: 1 addition & 1 deletion source/TR-181/integration_src.shared/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ libCcspCMAgent_integration_src_shared_la_CPPFLAGS = \
-I$(top_srcdir)/source/Custom

libCcspCMAgent_integration_src_shared_la_SOURCES = cosa_x_cisco_com_cablemodem_apis.c cosa_device_info_apis.c cosa_x_rdkcentral_com_cablemodem_apis.c
libCcspCMAgent_integration_src_shared_la_LDFLAGS = -lccsp_common -lcm_mgnt -lsysevent -lsecure_wrapper
libCcspCMAgent_integration_src_shared_la_LDFLAGS = -lccsp_common -lcm_mgnt -lsysevent -lsecure_wrapper -lfw_download_chk
Copy link

Copilot AI Jan 21, 2026

Choose a reason for hiding this comment

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

The library "-lfw_download_chk" is added as a dependency but there's no verification that this library exists or is available in the build environment. Consider adding appropriate configuration checks (e.g., PKG_CHECK_MODULES or AC_CHECK_LIB in configure.ac) to ensure the library is available before attempting to link against it.

Suggested change
libCcspCMAgent_integration_src_shared_la_LDFLAGS = -lccsp_common -lcm_mgnt -lsysevent -lsecure_wrapper -lfw_download_chk
libCcspCMAgent_integration_src_shared_la_LDFLAGS = -lccsp_common -lcm_mgnt -lsysevent -lsecure_wrapper @FW_DOWNLOAD_CHK_LIBS@

Copilot uses AI. Check for mistakes.
if CORE_NET_LIB_FEATURE_SUPPORT
libCcspCMAgent_integration_src_shared_la_LDFLAGS += -lnet
endif
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* If not stated otherwise in this file or this component's LICENSE file the
* following copyright and licenses apply:

Check failure on line 3 in source/TR-181/integration_src.shared/cosa_device_info_apis.c

View workflow job for this annotation

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

FossID License Issue Detected

Source code with 'Apache-2.0' license found in local file 'source/TR-181/integration_src.shared/cosa_device_info_apis.c' (Match: rdkb/components/opensource/ccsp/CcspCMAgent/rdkb/components/opensource/ccsp/CcspCMAgent/1, 653 lines, url: https://code.rdkcentral.com/r/plugins/gitiles/rdkb/components/opensource/ccsp/CcspCMAgent/+archive/RDKB-RELEASE-TEST-DUNFELL-1.tar.gz, file: source/TR-181/integration_src.shared/cosa_device_info_apis.c)

Check failure on line 3 in source/TR-181/integration_src.shared/cosa_device_info_apis.c

View workflow job for this annotation

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

FossID License Issue Detected

Source code with 'Apache-2.0' license found in local file 'source/TR-181/integration_src.shared/cosa_device_info_apis.c' (Match: rdkb/components/opensource/ccsp/CcspCMAgent/rdkb/components/opensource/ccsp/CcspCMAgent/2102, 688 lines, url: https://code.rdkcentral.com/r/plugins/gitiles/rdkb/components/opensource/ccsp/CcspCMAgent/+archive/rdk-dev-2102.tar.gz, file: source/TR-181/integration_src.shared/cosa_device_info_apis.c)
*
* Copyright 2015 RDK Management
*
Expand Down Expand Up @@ -77,6 +77,7 @@
#include "safec_lib_common.h"
#include <syscfg/syscfg.h>
#include "secure_wrapper.h"
#include <ccsp/fw_download_check.h>

#define CM_HTTPURL_LEN 512
#define VALID_fW_LEN 128
Expand Down Expand Up @@ -379,7 +380,6 @@
}
#endif


ANSC_STATUS CosaDmlDIDownloadNow(ANSC_HANDLE hContext)
{
PCOSA_DATAMODEL_DEVICEINFO pMyObject = (PCOSA_DATAMODEL_DEVICEINFO)hContext;
Expand Down Expand Up @@ -491,6 +491,12 @@
}

} */

if(can_proceed_fw_download() == 0){
Copy link

Copilot AI Jan 21, 2026

Choose a reason for hiding this comment

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

The function can_proceed_fw_download() is called but its implementation is not found in the codebase. This will cause linker errors unless it's provided by the external library. The function should be declared in the fw_download_check.h header file with clear documentation of its expected return values (the code assumes 0 means insufficient memory, non-zero means sufficient memory).

Copilot uses AI. Check for mistakes.
Copy link

Copilot AI Jan 21, 2026

Choose a reason for hiding this comment

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

The return value convention of can_proceed_fw_download() is unclear and potentially confusing. The function returns 0 to indicate failure (not enough memory), which is contrary to common C conventions where 0 typically indicates success. Consider using a more explicit return type (e.g., a boolean or named enum) or reversing the logic to align with standard conventions, and add a comment explaining the return value semantics.

Suggested change
if(can_proceed_fw_download() == 0){
/* can_proceed_fw_download() returns non-zero when it is safe to proceed,
* and 0 on failure (e.g. not enough memory). */
if (!can_proceed_fw_download()){

Copilot uses AI. Check for mistakes.
Copy link

Copilot AI Jan 21, 2026

Choose a reason for hiding this comment

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

The memory check is performed after several other validation steps and resource allocations. If the intent is to prevent firmware download when memory is insufficient, this check should be moved earlier in the function (before cm_hal_Set_HTTP_Download_Url and cm_hal_Set_HTTP_Download_Interface calls) to avoid unnecessary operations when the download will fail anyway.

Copilot uses AI. Check for mistakes.
CcspTraceError(("CosaDmlDIDownloadNow : Not enough memory to proceed firmware download\n"));
Copy link

Copilot AI Jan 21, 2026

Choose a reason for hiding this comment

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

The error message lacks specific information about how much memory is available versus how much is required. Consider enhancing the error message to include actual memory values, which would be more helpful for debugging and troubleshooting in production environments.

Copilot uses AI. Check for mistakes.
return ANSC_STATUS_FAILURE;
}
Copy link

Copilot AI Jan 21, 2026

Choose a reason for hiding this comment

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

Tests exist for CosaDmlDIDownloadNow() but there is no test coverage for the new memory check failure path. Add tests to verify the behavior when can_proceed_fw_download() returns 0, ensuring the function properly returns ANSC_STATUS_FAILURE and logs the appropriate error message.

Copilot uses AI. Check for mistakes.
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 new memory check for firmware downloads lacks test coverage. The existing test cases for CosaDmlDIDownloadNow (lines 785 and 852 in CcspCMAgentDeviceInfoDmlTest.cpp) do not mock or test the can_proceed_fw_download() function. Add test cases to verify that the function correctly fails when can_proceed_fw_download() returns 0, and succeeds when it returns non-zero.

Copilot uses AI. Check for mistakes.

pthread_t FWDL_Thread;
res = pthread_create(&FWDL_Thread, NULL, FWDL_ThreadFunc, "FWDL_ThreadFunc");
if(res != 0)
Expand Down
Loading