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

ES missing branch coverage in CFE_ES_RegisterCDSEx, conditions not independent (already checked) #1927

Open
skliper opened this issue Sep 2, 2021 · 1 comment

Comments

@skliper
Copy link
Contributor

skliper commented Sep 2, 2021

Is your feature request related to a problem? Please describe.
The following check for CFE_SUCCESS isn't independent from the NULL pointer test in CFE_ES_RegisterCDSEx:
384 [ + + ]: 6 : if (RegRecPtr != NULL)
385 : : {
386 : : /* Account for the extra header which will be added /
387 : 5 : NewBlockSize = UserBlockSize;
388 : 5 : NewBlockSize += sizeof(CFE_ES_CDS_BlockHeader_t);
389 : :
390 : : /
If a reallocation is needed, the old block may need to be freed first */
391 [ + - ][ + + ]: 5 : if (Status == CFE_SUCCESS && RegRecPtr->BlockOffset != 0 && NewBlockSize != RegRecPtr->BlockSize)
[ + + ]
here:

if (RegRecPtr != NULL)
{
/* Account for the extra header which will be added */
NewBlockSize = UserBlockSize;
NewBlockSize += sizeof(CFE_ES_CDS_BlockHeader_t);
/* If a reallocation is needed, the old block may need to be freed first */
if (Status == CFE_SUCCESS && RegRecPtr->BlockOffset != 0 && NewBlockSize != RegRecPtr->BlockSize)
{

Describe the solution you'd like
Recommend just checking for CFE_SUCCESS instead of NULL pointer check since it's already tested. We don't have a requirement to check for a NULL pointer within internal functions where it can't be NULL.

Describe alternatives you've considered
None

Additional context
None

Requester Info
Jacob Hageman - NASA/GSFC

@avan989
Copy link
Contributor

avan989 commented Jun 12, 2023

Code coverage is not possible.
The only way to traverse this branch is if Status != CFE_SUCCESS but the only way to set Status != CFE_SUCCESS is if RegRecPtr == NULL which if occurs, this code block will not be executed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants