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

Fix #1930, add code coverage for null check #2377

Merged
merged 1 commit into from
Oct 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions modules/es/fsw/src/cfe_es_generic_pool.h
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,39 @@ int32 CFE_ES_GenPoolInitialize(CFE_ES_GenPoolRecord_t *PoolRecPtr, size_t StartO
*/
int32 CFE_ES_GenPoolGetBlock(CFE_ES_GenPoolRecord_t *PoolRecPtr, size_t *BlockOffsetPtr, size_t ReqSize);

/*---------------------------------------------------------------------------------------*/
/**
* \brief Create a new block of the given size.
*
* \note Internal helper routine only, not part of API.
*
* \param[inout] PoolRecPtr Pointer to pool structure
* \param[in] BucketId Bucket ID
* \param[in] NewSize Size of block
* \param[out] BlockOffsetPtr Location to output new block offset
*
* \return #CFE_SUCCESS, or error code #CFE_ES_BUFFER_NOT_IN_POOL #CFE_ES_ERR_MEM_BLOCK_SIZE
* \ref CFEReturnCodes
*/
int32 CFE_ES_GenPoolCreatePoolBlock(CFE_ES_GenPoolRecord_t *PoolRecPtr, uint16 BucketId, size_t NewSize,
size_t *BlockOffsetPtr);

/*---------------------------------------------------------------------------------------*/
/**
* \brief Find and re-allocate a previously returned block
*
* \note Internal helper routine only, not part of API.
*
* \param[inout] PoolRecPtr Pointer to pool structure
* \param[in] BucketId Bucket ID
* \param[in] NewSize Size of block
* \param[out] BlockOffsetPtr Location to output new block offset
*
* \return #CFE_SUCCESS, or error code #CFE_ES_BUFFER_NOT_IN_POOL \ref CFEReturnCodes
*/
int32 CFE_ES_GenPoolRecyclePoolBlock(CFE_ES_GenPoolRecord_t *PoolRecPtr, uint16 BucketId, size_t NewSize,
size_t *BlockOffsetPtr);

/*---------------------------------------------------------------------------------------*/
/**
* \brief Returns a block to the pool
Expand Down
10 changes: 10 additions & 0 deletions modules/es/ut-coverage/es_UT.c
Original file line number Diff line number Diff line change
Expand Up @@ -2457,6 +2457,16 @@ void TestGenericPool(void)
/* Reset the structure so it will rebuild */
Pool1.TailPosition = 0;
CFE_UtAssert_SUCCESS(CFE_ES_GenPoolRebuild(&Pool1));

/* Branch coverage for no buffer in pool */
ES_ResetUnitTest();
UtAssert_INT32_EQ(CFE_ES_GenPoolCreatePoolBlock(&Pool1, 0, Pool1.Buckets[0].BlockSize, &Offset1),
CFE_ES_BUFFER_NOT_IN_POOL);

ES_ResetUnitTest();
UtAssert_INT32_EQ(CFE_ES_GenPoolRecyclePoolBlock(&Pool1, 0, Pool1.Buckets[0].BlockSize, &Offset1),
CFE_ES_BUFFER_NOT_IN_POOL);

}

void TestTask(void)
Expand Down