Skip to content

Commit a53428c

Browse files
committed
Fix #972, Update FSW for cppcheck issues
This updates the cppcheck static analysis rule to run via a script which takes into account the new directory structure. Oddly this reported new (valid) issues in FSW code which have also been corrected. Notably the wrapper script also contains a special provision to run static analysis on TIME only with SERVER mode enabled. The default logic of cppcheck would run all combos and it is not valid to have both of these defined.
1 parent c7788a7 commit a53428c

File tree

12 files changed

+26
-20
lines changed

12 files changed

+26
-20
lines changed
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#!/bin/bash
2+
3+
cppcheck_common_opts="--force --inline-suppr --std=c99 --language=c --enable=warning,performance,portability,style --suppress=variableScope --inconclusive"
4+
5+
# When checking time, only the "server" config option is enabled for now.
6+
# Otherwise cppcheck attempts to check with both branches enabled and generates false errors
7+
cppcheck_time_opts="-UCFE_PLATFORM_TIME_CFG_CLIENT -DCFE_PLATFORM_TIME_CFG_SERVER"
8+
9+
for mod in ${*}
10+
do
11+
cppcheck ${cppcheck_common_opts} $(eval echo \$cppcheck_${mod}_opts) ./modules/${mod}/fsw
12+
done
13+

.github/workflows/static-analysis.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,8 @@ jobs:
3838
- name: cfe strict cppcheck
3939
if: ${{matrix.cppcheck =='cfe'}}
4040
run: |
41-
cppcheck --force --inline-suppr --std=c99 --language=c --enable=warning,performance,portability,style --suppress=variableScope --inconclusive ./fsw/cfe-core/src ./modules 2> ./${{matrix.cppcheck}}_cppcheck_err.txt
41+
all_fsw_modules="core_api core_private es evs fs msg resourceid sb sbr tbl time"
42+
/bin/bash ./.github/workflows/run_fsw_cppcheck.sh ${all_fsw_modules} 2> ${{matrix.cppcheck}}_cppcheck_err.txt
4243
4344
- name: Archive Static Analysis Artifacts
4445
uses: actions/upload-artifact@v2

modules/es/fsw/src/cfe_es_apps.c

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -491,7 +491,6 @@ int32 CFE_ES_LoadModule(CFE_ResourceId_t ParentResourceId, const char *ModuleNam
491491
int32 CFE_ES_GetTaskFunction(CFE_ES_TaskEntryFuncPtr_t *FuncPtr)
492492
{
493493
CFE_ES_TaskRecord_t *TaskRecPtr;
494-
CFE_ES_AppId_t AppId;
495494
CFE_ES_TaskEntryFuncPtr_t EntryFunc;
496495
int32 ReturnCode;
497496
int32 Timeout;
@@ -501,7 +500,6 @@ int32 CFE_ES_GetTaskFunction(CFE_ES_TaskEntryFuncPtr_t *FuncPtr)
501500
*/
502501
ReturnCode = CFE_ES_ERR_APP_REGISTER;
503502
Timeout = CFE_PLATFORM_ES_STARTUP_SCRIPT_TIMEOUT_MSEC;
504-
AppId = CFE_ES_APPID_UNDEFINED;
505503
EntryFunc = NULL;
506504

507505
while(true)
@@ -512,9 +510,8 @@ int32 CFE_ES_GetTaskFunction(CFE_ES_TaskEntryFuncPtr_t *FuncPtr)
512510
TaskRecPtr = CFE_ES_GetTaskRecordByContext();
513511
if (TaskRecPtr != NULL)
514512
{
515-
AppId = TaskRecPtr->AppId;
516513
EntryFunc = TaskRecPtr->EntryFunc;
517-
if (CFE_RESOURCEID_TEST_DEFINED(AppId) && EntryFunc != 0)
514+
if (CFE_RESOURCEID_TEST_DEFINED(TaskRecPtr->AppId) && EntryFunc != 0)
518515
{
519516
ReturnCode = CFE_SUCCESS;
520517
}
@@ -1441,8 +1438,6 @@ int32 CFE_ES_CleanUpApp(CFE_ES_AppId_t AppId)
14411438
* of resources are freed.
14421439
*/
14431440
CFE_ES_AppRecordSetUsed(AppRecPtr, CFE_RESOURCEID_RESERVED);
1444-
1445-
ReturnCode = CFE_SUCCESS;
14461441
}
14471442
else
14481443
{

modules/es/fsw/src/cfe_es_start.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -379,7 +379,6 @@ void CFE_ES_SetupResetVariables(uint32 StartType, uint32 StartSubtype, uint32 Bo
379379
if ( CFE_ES_ResetDataPtr->ResetVars.ES_CausedReset != true )
380380
{
381381
CFE_ES_ResetDataPtr->ResetVars.ResetType = CFE_PSP_RST_TYPE_PROCESSOR;
382-
CFE_ES_ResetDataPtr->ResetVars.ResetSubtype = StartSubtype;
383382
CFE_ES_ResetDataPtr->ResetVars.ProcessorResetCount++;
384383

385384
/*

modules/es/fsw/src/cfe_es_task.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1384,8 +1384,7 @@ int32 CFE_ES_QueryAllCmd(const CFE_ES_QueryAllCmd_t *data)
13841384
FileSize += Result;
13851385
EntryCount ++;
13861386
}
1387-
1388-
++AppRecPtr;
1387+
13891388
} /* end for */
13901389

13911390
OS_close(FileDescriptor);

modules/sb/fsw/src/cfe_sb_api.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -755,7 +755,6 @@ int32 CFE_SB_GetPipeIdByName(CFE_SB_PipeId_t *PipeIdPtr, const char *PipeName)
755755
osal_id_t SysQueueId;
756756

757757
PendingEventID = 0;
758-
Status = CFE_SUCCESS;
759758
SysQueueId = OS_OBJECT_ID_UNDEFINED;
760759

761760
if(PipeName == NULL || PipeIdPtr == NULL)

modules/tbl/fsw/src/cfe_tbl_api.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,8 @@ int32 CFE_TBL_Register( CFE_TBL_Handle_t *TblHandlePtr,
5555
CFE_TBL_LoadBuff_t *WorkingBufferPtr;
5656
CFE_TBL_CritRegRec_t *CritRegRecPtr = NULL;
5757
int32 Status;
58-
size_t NameLen = 0;
59-
int16 RegIndx = -1;
58+
size_t NameLen;
59+
int16 RegIndx;
6060
CFE_ES_AppId_t ThisAppId;
6161
char AppName[OS_MAX_API_NAME] = {"UNKNOWN"};
6262
char TblName[CFE_TBL_MAX_FULL_NAME_LEN] = {""};
@@ -518,7 +518,7 @@ int32 CFE_TBL_Share( CFE_TBL_Handle_t *TblHandlePtr,
518518
{
519519
int32 Status;
520520
CFE_ES_AppId_t ThisAppId;
521-
int16 RegIndx = CFE_TBL_NOT_FOUND;
521+
int16 RegIndx;
522522
CFE_TBL_AccessDescriptor_t *AccessDescPtr = NULL;
523523
CFE_TBL_RegistryRec_t *RegRecPtr = NULL;
524524
char AppName[OS_MAX_API_NAME] = {"UNKNOWN"};
@@ -1507,7 +1507,7 @@ int32 CFE_TBL_Modified( CFE_TBL_Handle_t TblHandle )
15071507
CFE_TBL_RegistryRec_t *RegRecPtr = NULL;
15081508
CFE_TBL_Handle_t AccessIterator;
15091509
CFE_ES_AppId_t ThisAppId;
1510-
size_t FilenameLen = 0;
1510+
size_t FilenameLen;
15111511

15121512
/* Verify that this application has the right to perform operation */
15131513
Status = CFE_TBL_ValidateAccess(TblHandle, &ThisAppId);

modules/tbl/fsw/src/cfe_tbl_task.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ void CFE_TBL_TaskMain(void)
144144

145145
int32 CFE_TBL_TaskInit(void)
146146
{
147-
int32 Status = CFE_SUCCESS;
147+
int32 Status;
148148

149149
/*
150150
** Register Table Services with ES

modules/tbl/fsw/src/cfe_tbl_task_cmds.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1027,7 +1027,7 @@ int32 CFE_TBL_ActivateCmd(const CFE_TBL_ActivateCmd_t *data)
10271027
const CFE_TBL_ActivateCmd_Payload_t *CmdPtr = &data->Payload;
10281028
char TableName[CFE_TBL_MAX_FULL_NAME_LEN];
10291029
CFE_TBL_RegistryRec_t *RegRecPtr;
1030-
bool ValidationStatus = false;
1030+
bool ValidationStatus;
10311031

10321032
/* Make sure all strings are null terminated before attempting to process them */
10331033
CFE_SB_MessageStringGet(TableName, (char *)CmdPtr->TableName, NULL,

modules/time/fsw/src/cfe_time_task.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ void CFE_TIME_TaskMain(void)
197197

198198
int32 CFE_TIME_TaskInit(void)
199199
{
200-
int32 Status = CFE_SUCCESS;
200+
int32 Status;
201201
osal_id_t TimeBaseId;
202202
osal_id_t TimerId;
203203

0 commit comments

Comments
 (0)