Skip to content

Conversation

@jphickey
Copy link
Contributor

Checklist (Please check before submitting)

Describe the contribution
Pointers are punned to different (incorrect) types throughout CS. This addresses only the most egregious violations, in particular the case where an argument is defined as a pointer to a table and in reality it is a pointer-to-pointer (even qualified with const when it was updating it). The pointer mismatches are the reason for the strange "memcpy" in these spots.

This does some other code cleanup but only scratches the surface of what needs to be done.

There should be a follow-on task to better structure the data within the global, this would clean up a lot of APIs. In particular the CS_TableInit is a particularly ugly call with many arguments, this can be greatly simplified with a better data structure.

Fixes #118

Testing performed
Build and run CS and check operation, run all tests

Expected behavior changes
N/A

System(s) tested on
Linux

Contributor Info - All information REQUIRED for consideration of pull request
Joseph Hickey, Vantage Systems, Inc.

Pointers are punned to different (incorrect) types throughout CS.  This
addresses only the most egregious violations, in particular the case
where an argument is defined as a pointer to a table and in reality it
is a pointer-to-pointer (even qualified with const when it was updating
it).  The pointer mismatches are the reason for the strange "memcpy" in
these spots.

This does some other code cleanup but only scratches the surface of what
needs to be done.

There should be a follow-on task to better structure the data within the
global, this would clean up a lot of APIs.  In particular the
CS_TableInit is a particularly ugly call with many arguments, this can
be greatly simplified with a better data structure.
/* Call respective table update handler function (helper) */
/* */
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
void CS_CallTableUpdateHandler(uint32 Table, const void *DefinitionPtr, void *ResultsPtr, size_t NumEntries)

Check notice

Code scanning / CodeQL

Long function without assertion Note

All functions of more than 10 lines should have at least one assertion.
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
void CS_ProcessNewEepromMemoryDefinitionTable(const CS_Def_EepromMemory_Table_Entry_t *DefinitionTblPtr,
const CS_Res_EepromMemory_Table_Entry_t *ResultsTblPtr, uint16 NumEntries,
void CS_ProcessNewEepromMemoryDefinitionTable(const CS_Def_EepromMemory_Table_Entry_t *StartOfDefTable,

Check notice

Code scanning / CodeQL

Long function without assertion Note

All functions of more than 10 lines should have at least one assertion.
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
void CS_ProcessNewEepromMemoryDefinitionTable(const CS_Def_EepromMemory_Table_Entry_t *DefinitionTblPtr,
const CS_Res_EepromMemory_Table_Entry_t *ResultsTblPtr, uint16 NumEntries,
void CS_ProcessNewEepromMemoryDefinitionTable(const CS_Def_EepromMemory_Table_Entry_t *StartOfDefTable,

Check notice

Code scanning / CodeQL

Function too long Note

CS_ProcessNewEepromMemoryDefinitionTable has too many lines (72, while 60 are allowed).
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
void CS_ProcessNewTablesDefinitionTable(const CS_Def_Tables_Table_Entry_t *DefinitionTblPtr,
const CS_Res_Tables_Table_Entry_t *ResultsTblPtr)
void CS_ProcessNewTablesDefinitionTable(const CS_Def_Tables_Table_Entry_t *StartOfDefTable,

Check notice

Code scanning / CodeQL

Long function without assertion Note

All functions of more than 10 lines should have at least one assertion.
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
void CS_ProcessNewTablesDefinitionTable(const CS_Def_Tables_Table_Entry_t *DefinitionTblPtr,
const CS_Res_Tables_Table_Entry_t *ResultsTblPtr)
void CS_ProcessNewTablesDefinitionTable(const CS_Def_Tables_Table_Entry_t *StartOfDefTable,

Check notice

Code scanning / CodeQL

Function too long Note

CS_ProcessNewTablesDefinitionTable has too many lines (182, while 60 are allowed).
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
void CS_ProcessNewAppDefinitionTable(const CS_Def_App_Table_Entry_t *DefinitionTblPtr,
const CS_Res_App_Table_Entry_t *ResultsTblPtr)
void CS_ProcessNewAppDefinitionTable(const CS_Def_App_Table_Entry_t *StartOfDefTable,

Check notice

Code scanning / CodeQL

Long function without assertion Note

All functions of more than 10 lines should have at least one assertion.
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
void CS_ProcessNewAppDefinitionTable(const CS_Def_App_Table_Entry_t *DefinitionTblPtr,
const CS_Res_App_Table_Entry_t *ResultsTblPtr)
void CS_ProcessNewAppDefinitionTable(const CS_Def_App_Table_Entry_t *StartOfDefTable,

Check notice

Code scanning / CodeQL

Function too long Note

CS_ProcessNewAppDefinitionTable has too many lines (61, while 60 are allowed).
/* */
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
CFE_Status_t CS_HandleTableUpdate(void *DefinitionTblPtr, void *ResultsTblPtr, CFE_TBL_Handle_t DefinitionTableHandle,
CFE_Status_t CS_HandleTableUpdate(void **DefinitionTblPtr, void **ResultsTblPtr, CFE_TBL_Handle_t DefinitionTableHandle,

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 CS_HandleTableUpdate(void *DefinitionTblPtr, void *ResultsTblPtr, CFE_TBL_Handle_t DefinitionTableHandle,
CFE_Status_t CS_HandleTableUpdate(void **DefinitionTblPtr, void **ResultsTblPtr, CFE_TBL_Handle_t DefinitionTableHandle,

Check notice

Code scanning / CodeQL

Function too long Note

CS_HandleTableUpdate has too many lines (67, while 60 are allowed).
/* Gets a table type ID value as a printable string */
/* */
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
const char *CS_GetTableTypeAsString(uint32 TableId)

Check notice

Code scanning / CodeQL

Long function without assertion Note

All functions of more than 10 lines should have at least one assertion.
@dzbaker dzbaker merged commit 8dcce61 into nasa:main Nov 3, 2025
16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

memcpy with size of a pointer confusing (or a bug)

3 participants