Skip to content

Refactor to avoid possible uninitialized local variables #783

@skliper

Description

@skliper

Is your feature request related to a problem? Please describe.

OS_common_record_t *OS_ObjectIdGlobalFromToken(const OS_object_token_t *token)
{
static OS_common_record_t fake_record;
int32 status;
OS_common_record_t * recptr;
status = UT_DEFAULT_IMPL(OS_ObjectIdGlobalFromToken);
if (status == 0 &&
UT_Stub_CopyToLocal(UT_KEY(OS_ObjectIdGlobalFromToken), &recptr, sizeof(recptr)) < sizeof(recptr))
{
/* This function should never return null */
recptr = &fake_record;
}
return recptr;
}


Note the only one in non-test code is a false alarm so I'm not marking as a bug and not critical, but easy to squash:

token->obj_idx = OSAL_INDEX_C(local_id);

Describe the solution you'd like
Fix.

Describe alternatives you've considered
None

Additional context
CodeQL warnings

Requester Info
Jacob Hageman - NASA/GSFC

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementsecurityunit-testTickets related to the OSAL unit testing (functional and/or coverage)

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions