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

Coercion Alters Value - static analysis warnings #788

Closed
skliper opened this issue Feb 10, 2021 · 0 comments · Fixed by #789 or #774
Closed

Coercion Alters Value - static analysis warnings #788

skliper opened this issue Feb 10, 2021 · 0 comments · Fixed by #789 or #774
Assignees
Milestone

Comments

@skliper
Copy link
Contributor

skliper commented Feb 10, 2021

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

@skliper skliper added this to the 6.0.0 milestone Feb 10, 2021
@skliper skliper self-assigned this Feb 10, 2021
skliper added a commit to skliper/osal that referenced this issue Feb 10, 2021
@skliper skliper changed the title Coercion Alters Value - static analysis warnings Minor static analysis warnings Feb 10, 2021
@skliper skliper changed the title Minor static analysis warnings Coercion Alters Value - static analysis warnings Feb 10, 2021
astrogeco added a commit that referenced this issue Feb 12, 2021
Fix #788, Resolve coercion alters value warnings
@skliper skliper mentioned this issue Feb 16, 2021
jphickey pushed a commit to jphickey/osal that referenced this issue Aug 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants