Skip to content
New issue

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

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

Already on GitHub? # to your account

Coercion alters value caused by incorrect type - static analysis warning #1200

Closed
skliper opened this issue Mar 2, 2021 · 0 comments · Fixed by #1232 or #1243
Closed

Coercion alters value caused by incorrect type - static analysis warning #1200

skliper opened this issue Mar 2, 2021 · 0 comments · Fixed by #1232 or #1243
Milestone

Comments

@skliper
Copy link
Contributor

skliper commented Mar 2, 2021

Is your feature request related to a problem? Please describe.
CFE_TBL_FindTableInRegistery returns int16, RegIndex is defined as uint32 and only checked for error (negative)

uint32 RegIndex;
int32 Status;
/* Make sure all strings are null terminated before attempting to process them */
CFE_SB_MessageStringGet(TableName, (char *)CmdPtr->TableName, NULL,
sizeof(TableName), sizeof(CmdPtr->TableName));
/* Before doing anything, lets make sure the table is no longer in the registry */
/* This would imply that the owning application has been terminated and that it */
/* is safe to delete the associated critical table image in the CDS. */
RegIndex = CFE_TBL_FindTableInRegistry(TableName);
if (RegIndex == CFE_TBL_NOT_FOUND)

The last parameter passed to CFE_ES_FileWriteByteCntErr for both uses is Status (int32), yet it expects size_t... seems like this isn't defined correctly?

CFE_ES_FileWriteByteCntErr(Filename, LastReqSize, Status);

CFE_ES_FileWriteByteCntErr(State->DataFileName, BlockSize, Status);

void CFE_ES_FileWriteByteCntErr(const char *Filename,size_t Requested,size_t Actual);

Not a bug, just an inconsistency warnings

Describe the solution you'd like
Correct type

Describe alternatives you've considered
None

Additional context
Static analysis warning

Requester Info
Jacob Hageman - NASA/GSFC

@skliper skliper added this to the 7.0.0 milestone Mar 2, 2021
skliper added a commit to skliper/cFE that referenced this issue Mar 17, 2021
skliper added a commit to skliper/cFE that referenced this issue Mar 17, 2021
astrogeco added a commit that referenced this issue Mar 18, 2021
Fix #1200, Resolve type issues with CFE_ES_FileWriteByteCntErr and CFE_TBL_FindTableInRegistry
# for free to join this conversation on GitHub. Already have an account? # to comment
Projects
None yet
1 participant