diff --git a/.github/workflows/static-analysis.yml b/.github/workflows/static-analysis.yml index 9c279a0..85dccf2 100644 --- a/.github/workflows/static-analysis.yml +++ b/.github/workflows/static-analysis.yml @@ -1,6 +1,5 @@ name: Static Analysis -# Run on all push and pull requests on: push: branches: @@ -16,4 +15,6 @@ on: jobs: static-analysis: name: Static Analysis - uses: nasa/cFS/.github/workflows/app-static-analysis-reusable.yml@dev \ No newline at end of file + uses: nasa/cFS/.github/workflows/static-analysis-reusable.yml@dev + with: + source-dir: 'source/fsw' \ No newline at end of file diff --git a/fsw/inc/fm_internal_cfg.h b/fsw/inc/fm_internal_cfg.h index 1f8491b..80cda79 100644 --- a/fsw/inc/fm_internal_cfg.h +++ b/fsw/inc/fm_internal_cfg.h @@ -121,7 +121,7 @@ * or equal to zero. */ #define FM_MISSION_REV FM_INTERNAL_CFGVAL(MISSION_REV) -#define DEFAULT_FM_INTERNAL_MISSION_REV 0 +#define DEFAULT_FM_INTERNAL_MISSION_REV 0xFF /** * \brief Child file stat sleep diff --git a/fsw/src/fm_cmds.c b/fsw/src/fm_cmds.c index 1cb8440..9af8634 100644 --- a/fsw/src/fm_cmds.c +++ b/fsw/src/fm_cmds.c @@ -861,8 +861,14 @@ CFE_Status_t FM_MonitorFilesystemSpaceCmd(const FM_MonitorFilesystemSpaceCmd_t * /* Acquire pointer to file system free space table, also locks table */ Status = CFE_TBL_GetAddress((void *)&FM_AppData.MonitorTablePtr, FM_AppData.MonitorTableHandle); - /* Verify that we have a pointer to the file system table data */ - if (Status == CFE_TBL_ERR_NEVER_LOADED) + /* + ** Per cfe_tbl.h, CFE_TBL_GetAddress leaves the table pointer undefined on + ** any non-success return. Only CFE_SUCCESS and CFE_TBL_INFO_UPDATED set + ** the pointer. Prior versions only handled CFE_TBL_ERR_NEVER_LOADED and + ** would dereference an undefined pointer on _INVALID_HANDLE / _NO_ACCESS / + ** CFE_ES_ERR_RESOURCEID_NOT_VALID / CFE_TBL_BAD_ARGUMENT. + */ + if (Status != CFE_SUCCESS && Status != CFE_TBL_INFO_UPDATED) { /* Make sure we don't try to use the empty table buffer */ FM_AppData.MonitorTablePtr = NULL; @@ -974,7 +980,14 @@ CFE_Status_t FM_SetTableStateCmd(const FM_SetTableStateCmd_t *Msg) /* Acquire pointer to file system free space table */ Status = CFE_TBL_GetAddress((void *)&FM_AppData.MonitorTablePtr, FM_AppData.MonitorTableHandle); - if (Status == CFE_TBL_ERR_NEVER_LOADED) + /* + ** Per cfe_tbl.h, CFE_TBL_GetAddress leaves the table pointer undefined on + ** any non-success return. Only CFE_SUCCESS and CFE_TBL_INFO_UPDATED set + ** the pointer. Prior versions only handled CFE_TBL_ERR_NEVER_LOADED and + ** would dereference an undefined pointer on _INVALID_HANDLE / _NO_ACCESS / + ** CFE_ES_ERR_RESOURCEID_NOT_VALID / CFE_TBL_BAD_ARGUMENT. + */ + if (Status != CFE_SUCCESS && Status != CFE_TBL_INFO_UPDATED) { /* Make sure we don't try to use the empty table buffer */ FM_AppData.MonitorTablePtr = NULL; diff --git a/fsw/src/fm_table_utils.c b/fsw/src/fm_table_utils.c index 90c3577..d270982 100644 --- a/fsw/src/fm_table_utils.c +++ b/fsw/src/fm_table_utils.c @@ -55,7 +55,9 @@ CFE_Status_t FM_TableInit(void) if (Status == CFE_SUCCESS) { /* Make an attempt to load the default table data - OK if this fails */ - CFE_TBL_Load(FM_AppData.MonitorTableHandle, CFE_TBL_SRC_FILE, FM_TABLE_DEF_NAME); + /* SAD: Suppress Ignored Return Value warning from CodeSonar. CFE_TBL_Load() will send event message if + * there is any error */ + (void)CFE_TBL_Load(FM_AppData.MonitorTableHandle, CFE_TBL_SRC_FILE, FM_TABLE_DEF_NAME); /* Allow cFE a chance to dump, update, etc. */ FM_AcquireTablePointers(); @@ -211,9 +213,16 @@ void FM_AcquireTablePointers(void) /* Acquire pointer to file system free space table */ Status = CFE_TBL_GetAddress((void *)&FM_AppData.MonitorTablePtr, FM_AppData.MonitorTableHandle); - if (Status == CFE_TBL_ERR_NEVER_LOADED) + /* + ** Per cfe_tbl.h, CFE_TBL_GetAddress leaves the table pointer undefined on + ** any non-success return (CFE_TBL_ERR_NEVER_LOADED, _INVALID_HANDLE, + ** _NO_ACCESS, CFE_ES_ERR_RESOURCEID_NOT_VALID, CFE_TBL_BAD_ARGUMENT). + ** Only CFE_SUCCESS and CFE_TBL_INFO_UPDATED set the pointer. NULL out + ** the local copy on any other return so callers see a clean NULL rather + ** than a stale or undefined pointer. + */ + if (Status != CFE_SUCCESS && Status != CFE_TBL_INFO_UPDATED) { - /* Make sure we don't try to use the empty table buffer */ FM_AppData.MonitorTablePtr = NULL; } }