Skip to content

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

*
*-----------------------------------------------------------------*/
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

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

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

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

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

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

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

A stack address which arrived via a [parameter](1) may be assigned to a non-local variable.
@jphickey
Copy link
Contributor

The TBL Load function is totally reworked in the upcoming release (not on github yet unfortunately) so this is likely overridden by that. Probably will not be able to merge this one (or at least will need to re-evaluate after we drop the new code)

@thnkslprpt
Copy link
Contributor Author

The TBL Load function is totally reworked in the upcoming release (not on github yet unfortunately) so this is likely overridden by that. Probably will not be able to merge this one (or at least will need to re-evaluate after we drop the new code)

No worries - I'll check once that's uploaded if there's anything useful left from here.

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

2 participants