diff --git a/src/os/shared/inc/os-shared-filesys.h b/src/os/shared/inc/os-shared-filesys.h index d578e57bf..dab908db8 100644 --- a/src/os/shared/inc/os-shared-filesys.h +++ b/src/os/shared/inc/os-shared-filesys.h @@ -95,7 +95,7 @@ typedef struct typedef struct { - char device_name[OS_MAX_API_NAME]; /**< The name of the underlying block device, if applicable */ + char device_name[OS_FS_DEV_NAME_LEN]; /**< The name of the underlying block device, if applicable */ char volume_name[OS_FS_VOL_NAME_LEN]; char system_mountpt[OS_MAX_LOCAL_PATH_LEN]; /**< The name/prefix where the contents are accessible in the host operating system */ char virtual_mountpt[OS_MAX_PATH_LEN]; /**< The name/prefix in the OSAL Virtual File system exposed to applications */ diff --git a/src/os/shared/src/osapi-filesys.c b/src/os/shared/src/osapi-filesys.c index c2638ad70..cf6724bc9 100644 --- a/src/os/shared/src/osapi-filesys.c +++ b/src/os/shared/src/osapi-filesys.c @@ -443,7 +443,7 @@ int32 OS_FileSysAddFixedMap(uint32 *filesys_id, const char *phys_path, const cha return OS_INVALID_POINTER; } - if (strlen(phys_path) >= OS_MAX_PATH_LEN || + if (strlen(phys_path) >= OS_MAX_LOCAL_PATH_LEN || strlen(virt_path) >= OS_MAX_PATH_LEN) { return OS_ERR_NAME_TOO_LONG; @@ -462,7 +462,7 @@ int32 OS_FileSysAddFixedMap(uint32 *filesys_id, const char *phys_path, const cha ++dev_name; } - if (strlen(dev_name) >= OS_MAX_API_NAME) + if (strlen(dev_name) >= OS_FS_DEV_NAME_LEN) { return OS_ERR_NAME_TOO_LONG; } diff --git a/src/unit-test-coverage/shared/src/coveragetest-filesys.c b/src/unit-test-coverage/shared/src/coveragetest-filesys.c index e84d14ec7..fcf40a969 100644 --- a/src/unit-test-coverage/shared/src/coveragetest-filesys.c +++ b/src/unit-test-coverage/shared/src/coveragetest-filesys.c @@ -51,12 +51,14 @@ void Test_OS_FileSysAddFixedMap(void) OSAPI_TEST_FUNCTION_RC(OS_FileSysAddFixedMap(&id, "/phys", "/virt"), OS_SUCCESS); OSAPI_TEST_FUNCTION_RC(OS_FileSysAddFixedMap(&id, NULL, NULL), OS_INVALID_POINTER); - UT_SetForceFail(UT_KEY(OCS_strlen), 2 + OS_MAX_PATH_LEN); + UT_SetDeferredRetcode(UT_KEY(OCS_strlen), 1, 2 + OS_MAX_LOCAL_PATH_LEN); OSAPI_TEST_FUNCTION_RC(OS_FileSysAddFixedMap(&id, "/phys", "/virt"), OS_ERR_NAME_TOO_LONG); - UT_ClearForceFail(UT_KEY(OCS_strlen)); + UT_SetDeferredRetcode(UT_KEY(OCS_strlen), 2, 2 + OS_MAX_PATH_LEN); + OSAPI_TEST_FUNCTION_RC(OS_FileSysAddFixedMap(&id, "/phys", "/virt"), OS_ERR_NAME_TOO_LONG); + UT_ResetState(UT_KEY(OCS_strlen)); UT_SetForceFail(UT_KEY(OCS_strrchr), -1); - UT_SetDeferredRetcode(UT_KEY(OCS_strlen), 3, 2 + OS_MAX_API_NAME); + UT_SetDeferredRetcode(UT_KEY(OCS_strlen), 3, 2 + OS_FS_DEV_NAME_LEN); OSAPI_TEST_FUNCTION_RC(OS_FileSysAddFixedMap(&id, "/phys", "/virt"), OS_ERR_NAME_TOO_LONG); UT_ResetState(UT_KEY(OCS_strlen)); UT_ResetState(UT_KEY(OCS_strrchr));