Skip to content

Coercion Alters Value - static analysis warnings #788

@skliper

Description

@skliper

Is your feature request related to a problem? Please describe.
A few locations where a type is incorrect (just listing an example here, see PR for all fixes):

int32 OS_GetErrorName(int32 error_num, os_err_name_t *err_name)
{
uint32 return_code;
const OS_ErrorTable_Entry_t *Error;
OS_CHECK_POINTER(err_name);
Error = OS_GLOBAL_ERROR_NAME_TABLE;
while (Error->Name != NULL && Error->Number != error_num)
{
++Error;
}
if (Error->Number != error_num)
{
Error = OS_IMPL_ERROR_NAME_TABLE;
while (Error->Name != NULL && Error->Number != error_num)
{
++Error;
}
}
if (Error->Number == error_num && Error->Name != NULL)
{
strncpy(*err_name, Error->Name, OS_ERROR_NAME_LENGTH - 1);
return_code = OS_SUCCESS;
}
else
{
snprintf(*err_name, OS_ERROR_NAME_LENGTH, "OS_UNKNOWN(%d)", (int)error_num);
return_code = OS_ERROR;

Note returns status which is int32, but return_code is uint32. No real bugs identified yet, but cleaning up warnings makes it easier to spot real issues in the future.

Describe the solution you'd like
Fix types where needed.

Describe alternatives you've considered
None

Additional context
None

Requester Info
Jacob Hageman - NASA/GSFC

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions