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 #2588, Split up CFE_TBL_Load and remove early returns #2589

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

thnkslprpt
Copy link
Contributor

Checklist

Describe the contribution

  • Fixes Split up CFE_TBL_Load() and remove early returns #2588
    • Splits the functionality of CFE_TBL_Load() into 4 helper functions
    • Removes all except the first 2 early returns (by introducing a new boolean status guard StillProcessing) - allowing us to move CFE_TBL_TxnFinish() to the end of the function
    • CFE_TBL_Load() reduced from 223 -> 123 lines (and cyclomatic complexity roughly halved)

Testing performed
GitHub CI actions all passing successfully (incl. Build + Run, Unit/Functional Tests etc.) + some basic sanity checking with a cFS suite run, loading of a table etc.

Expected behavior changes
This PR minimises complexity of CFE_TBL_Load() thereby easing future maintenance/testing/refactoring. Logic is largely unchanged here, other than the points mentioned above.

System(s) tested on
Debian GNU/Linux 12 (bookworm)
Current main branch of cFS bundle.

Contributor Info
Avi Weiss   @thnkslprpt

@@ -398,7 +398,7 @@
* See description in header file for argument/return detail
*
*-----------------------------------------------------------------*/
CFE_TBL_LoadBuff_t *CFE_TBL_GetSelectedBuffer(CFE_TBL_RegistryRec_t * RegRecPtr,
CFE_TBL_LoadBuff_t *CFE_TBL_GetSelectedBuffer(CFE_TBL_RegistryRec_t *RegRecPtr,

Check notice

Code scanning / CodeQL

Long function without assertion Note

All functions of more than 10 lines should have at least one assertion.
* See description in header file for argument/return detail
*
*-----------------------------------------------------------------*/
CFE_Status_t CFE_TBL_LoadDumpOnlyTable(CFE_TBL_RegistryRec_t *RegRecPtr, const char *AppName, const void *SrcDataPtr)

Check notice

Code scanning / CodeQL

Long function without assertion Note

All functions of more than 10 lines should have at least one assertion.
* See description in header file for argument/return detail
*
*-----------------------------------------------------------------*/
CFE_Status_t CFE_TBL_LoadWorkingBuffer(const CFE_TBL_SrcEnum_t SrcType, const char *AppName,

Check notice

Code scanning / CodeQL

Long function without assertion Note

All functions of more than 10 lines should have at least one assertion.
*
*-----------------------------------------------------------------*/

CFE_Status_t CFE_TBL_ValidateWorkingBufferContents(CFE_TBL_RegistryRec_t *RegRecPtr,

Check notice

Code scanning / CodeQL

Long function without assertion Note

All functions of more than 10 lines should have at least one assertion.
CFE_Status_t CFE_TBL_ValidateWorkingBufferContents(CFE_TBL_RegistryRec_t *RegRecPtr,
CFE_TBL_LoadBuff_t *WorkingBufferPtr, const char *AppName)
{
CFE_Status_t Status = (RegRecPtr->ValidationFuncPtr)(WorkingBufferPtr->BufferPtr);

Check notice

Code scanning / CodeQL

Use of non-constant function pointer Note

This call does not go through a const function pointer.
* See description in header file for argument/return detail
*
*-----------------------------------------------------------------*/
CFE_Status_t CFE_TBL_PerformUpdate(CFE_TBL_RegistryRec_t *RegRecPtr, const CFE_TBL_Handle_t TblHandle,

Check notice

Code scanning / CodeQL

Long function without assertion Note

All functions of more than 10 lines should have at least one assertion.
{
/* The Application is allowed to call Load once when the address */
/* of the dump only table is being defined by the application. */
RegRecPtr->Buffers[0].BufferPtr = (void *)SrcDataPtr;

Check warning

Code scanning / CodeQL

Local variable address stored in non-local memory Warning

A stack address which arrived via a
parameter
may be assigned to a non-local variable.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Split up CFE_TBL_Load() and remove early returns
1 participant