Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

osal Integration candidate: Caelum-rc4+dev4 #1226

Merged
merged 9 commits into from
Feb 25, 2022
5 changes: 4 additions & 1 deletion src/os/shared/src/osapi-file.c
Original file line number Diff line number Diff line change
Expand Up @@ -532,7 +532,10 @@ int32 OS_FDGetInfo(osal_id_t filedes, OS_file_prop_t *fd_prop)
{
record = OS_OBJECT_TABLE_GET(OS_global_stream_table, token);

strncpy(fd_prop->Path, record->name_entry, sizeof(fd_prop->Path) - 1);
if (record->name_entry != NULL)
{
strncpy(fd_prop->Path, record->name_entry, sizeof(fd_prop->Path) - 1);
}
fd_prop->User = record->creator;
fd_prop->IsValid = true;

Expand Down
4 changes: 4 additions & 0 deletions src/unit-test-coverage/shared/src/coveragetest-file.c
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,10 @@ void Test_OS_FDGetInfo(void)
OSAPI_TEST_FUNCTION_RC(OS_FDGetInfo(UT_OBJID_1, &file_prop), OS_SUCCESS);
UtAssert_True(strcmp(file_prop.Path, "ABC") == 0, "file_prop.Path (%s) == ABC", file_prop.Path);

OS_UT_SetupBasicInfoTest(OS_OBJECT_TYPE_OS_STREAM, UT_INDEX_1, NULL, UT_OBJID_OTHER);
OSAPI_TEST_FUNCTION_RC(OS_FDGetInfo(UT_OBJID_1, &file_prop), OS_SUCCESS);
UtAssert_STRINGBUF_EQ(file_prop.Path, 1, "", 1);

OSAPI_TEST_FUNCTION_RC(OS_FDGetInfo(UT_OBJID_1, NULL), OS_INVALID_POINTER);

UT_SetDefaultReturnValue(UT_KEY(OS_ObjectIdGetById), OS_ERR_INVALID_ID);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ void OS_UT_SetupBasicInfoTest(osal_objtype_t obj_type, osal_index_t test_idx, co
rptr += test_idx;
memset(rptr, 0, sizeof(*rptr));
rptr->creator = UT_OBJID_OTHER;
rptr->name_entry = "ABC";
rptr->name_entry = name;

OS_UT_SetupTestTargetIndex(obj_type, test_idx);
}