Skip to content

Commit

Permalink
Fix nasa#2101, Resolve fsw uninit var static analysis warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
skliper committed May 18, 2022
1 parent 847794c commit 558b5a4
Show file tree
Hide file tree
Showing 11 changed files with 38 additions and 26 deletions.
4 changes: 2 additions & 2 deletions modules/es/fsw/src/cfe_es_api.c
Original file line number Diff line number Diff line change
Expand Up @@ -780,7 +780,7 @@ CFE_Status_t CFE_ES_GetLibIDByName(CFE_ES_LibId_t *LibIdPtr, const char *LibName
*-----------------------------------------------------------------*/
CFE_Status_t CFE_ES_GetTaskIDByName(CFE_ES_TaskId_t *TaskIdPtr, const char *TaskName)
{
osal_id_t OsalId;
osal_id_t OsalId = OS_OBJECT_ID_UNDEFINED;
int32 OsStatus;
CFE_Status_t Result;

Expand Down Expand Up @@ -2189,7 +2189,7 @@ int32 CFE_ES_LibID_ToIndex(CFE_ES_LibId_t LibId, uint32 *Idx)
CFE_Status_t CFE_ES_TaskID_ToIndex(CFE_ES_TaskId_t TaskID, uint32 *Idx)
{
osal_id_t OsalID;
osal_index_t OsalIndex;
osal_index_t OsalIndex = OSAL_INDEX_C(0);
int32 OsStatus;

if (!CFE_RESOURCEID_TEST_DEFINED(TaskID))
Expand Down
9 changes: 5 additions & 4 deletions modules/es/fsw/src/cfe_es_apps.c
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ void CFE_ES_StartApplications(uint32 ResetType, const char *StartFilePath)
osal_id_t AppFile = OS_OBJECT_ID_UNDEFINED;
int32 Status;
int32 OsStatus;
char c;
char c = 0;
bool LineTooLong = false;
bool FileOpened = false;

Expand Down Expand Up @@ -401,7 +401,7 @@ int32 CFE_ES_ParseFileEntry(const char **TokenList, uint32 NumTokens)
int32 CFE_ES_LoadModule(CFE_ResourceId_t ParentResourceId, const char *ModuleName,
const CFE_ES_ModuleLoadParams_t *LoadParams, CFE_ES_ModuleLoadStatus_t *LoadStatus)
{
osal_id_t ModuleId;
osal_id_t ModuleId = OS_OBJECT_ID_UNDEFINED;
cpuaddr InitSymbolAddress;
int32 ReturnCode;
int32 OsStatus;
Expand Down Expand Up @@ -590,7 +590,7 @@ int32 CFE_ES_StartAppTask(CFE_ES_TaskId_t *TaskIdPtr, const char *TaskName, CFE_
const CFE_ES_TaskStartParams_t *Params, CFE_ES_AppId_t ParentAppId)
{
CFE_ES_TaskRecord_t *TaskRecPtr;
osal_id_t OsalTaskId;
osal_id_t OsalTaskId = OS_OBJECT_ID_UNDEFINED;
CFE_ES_TaskId_t LocalTaskId;
int32 OsStatus;
int32 ReturnCode;
Expand Down Expand Up @@ -1785,6 +1785,8 @@ void CFE_ES_CopyModuleAddressInfo(osal_id_t ModuleId, CFE_ES_AppInfo_t *AppInfoP
OS_module_prop_t ModuleInfo;
int32 OsStatus;

memset(&ModuleInfo, 0, sizeof(ModuleInfo));

OsStatus = OS_ModuleInfo(ModuleId, &ModuleInfo);
if (OsStatus == OS_SUCCESS)
{
Expand All @@ -1794,7 +1796,6 @@ void CFE_ES_CopyModuleAddressInfo(osal_id_t ModuleId, CFE_ES_AppInfo_t *AppInfoP
else
{
AppInfoPtr->AddressesAreValid = false;
memset(&ModuleInfo, 0, sizeof(ModuleInfo));
}

/*
Expand Down
3 changes: 3 additions & 0 deletions modules/es/fsw/src/cfe_es_backgroundtask.c
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,9 @@ void CFE_ES_BackgroundTask(void)
OS_time_t LastTime;
const CFE_ES_BackgroundJobEntry_t *JobPtr;

memset(&LastTime, 0, sizeof(LastTime));
memset(&CurrTime, 0, sizeof(CurrTime));

CFE_PSP_GetTime(&LastTime);

while (true)
Expand Down
4 changes: 3 additions & 1 deletion modules/es/fsw/src/cfe_es_start.c
Original file line number Diff line number Diff line change
Expand Up @@ -475,11 +475,13 @@ void CFE_ES_InitializeFileSystems(uint32 StartType)
{
int32 OsStatus;
int32 PspStatus;
cpuaddr RamDiskMemoryAddress;
cpuaddr RamDiskMemoryAddress = 0;
uint32 RamDiskMemorySize;
int32 PercentFree;
OS_statvfs_t StatBuf;

memset(&StatBuf, 0, sizeof(StatBuf));

/*
** Get the memory area for the RAM disk
*/
Expand Down
2 changes: 1 addition & 1 deletion modules/es/fsw/src/cfe_es_syslog.c
Original file line number Diff line number Diff line change
Expand Up @@ -450,7 +450,7 @@ void CFE_ES_SysLog_vsnprintf(char *Buffer, size_t BufferSize, const char *SpecSt
*-----------------------------------------------------------------*/
int32 CFE_ES_SysLogDump(const char *Filename)
{
osal_id_t fd;
osal_id_t fd = OS_OBJECT_ID_UNDEFINED;
int32 OsStatus;
int32 Status;
size_t WritePos;
Expand Down
25 changes: 13 additions & 12 deletions modules/es/fsw/src/cfe_es_task.c
Original file line number Diff line number Diff line change
Expand Up @@ -679,6 +679,8 @@ int32 CFE_ES_HousekeepingCmd(const CFE_MSG_CommandHeader_t *data)
int32 OsStatus;
uint32 PerfIdx;

memset(&HeapProp, 0, sizeof(HeapProp));

/*
** Get command execution counters, system log entry count & bytes used.
*/
Expand Down Expand Up @@ -750,21 +752,20 @@ int32 CFE_ES_HousekeepingCmd(const CFE_MSG_CommandHeader_t *data)
}
}

/* Fill in heap info if get successful/supported */
OsStatus = OS_HeapGetInfo(&HeapProp);

/*
* If retrieving info from OSAL was not successful,
* zero out the property struct, so all sizes will
* in turn be reported in telemetry as 0.
*/
if (OsStatus != OS_SUCCESS)
if (OsStatus == OS_SUCCESS)
{
memset(&HeapProp, 0, sizeof(HeapProp));
CFE_ES_Global.TaskData.HkPacket.Payload.HeapBytesFree = CFE_ES_MEMOFFSET_C(HeapProp.free_bytes);
CFE_ES_Global.TaskData.HkPacket.Payload.HeapBlocksFree = CFE_ES_MEMOFFSET_C(HeapProp.free_blocks);
CFE_ES_Global.TaskData.HkPacket.Payload.HeapMaxBlockSize = CFE_ES_MEMOFFSET_C(HeapProp.largest_free_block);
}
else
{
CFE_ES_Global.TaskData.HkPacket.Payload.HeapBytesFree = 0;
CFE_ES_Global.TaskData.HkPacket.Payload.HeapBlocksFree = 0;
CFE_ES_Global.TaskData.HkPacket.Payload.HeapMaxBlockSize = 0;
}

CFE_ES_Global.TaskData.HkPacket.Payload.HeapBytesFree = CFE_ES_MEMOFFSET_C(HeapProp.free_bytes);
CFE_ES_Global.TaskData.HkPacket.Payload.HeapBlocksFree = CFE_ES_MEMOFFSET_C(HeapProp.free_blocks);
CFE_ES_Global.TaskData.HkPacket.Payload.HeapMaxBlockSize = CFE_ES_MEMOFFSET_C(HeapProp.largest_free_block);

/*
** Send housekeeping telemetry packet.
Expand Down
3 changes: 3 additions & 0 deletions modules/evs/fsw/src/cfe_evs_utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -358,6 +358,9 @@ void EVS_GenerateEventTelemetry(EVS_AppData_t *AppDataPtr, uint16 EventID, uint1
CFE_EVS_ShortEventTlm_t ShortEventTlm; /* The "short" flavor is only generated if selected */
int ExpandedLength;

memset(&LongEventTlm, 0, sizeof(LongEventTlm));
memset(&ShortEventTlm, 0, sizeof(ShortEventTlm));

/* Initialize EVS event packets */
CFE_MSG_Init(CFE_MSG_PTR(LongEventTlm.TelemetryHeader), CFE_SB_ValueToMsgId(CFE_EVS_LONG_EVENT_MSG_MID),
sizeof(LongEventTlm));
Expand Down
4 changes: 2 additions & 2 deletions modules/sb/fsw/src/cfe_sb_task.c
Original file line number Diff line number Diff line change
Expand Up @@ -857,9 +857,9 @@ void CFE_SB_CollectRouteInfo(CFE_SBR_RouteId_t RouteId, void *ArgPtr)
int32 CFE_SB_SendSubscriptionReport(CFE_SB_MsgId_t MsgId, CFE_SB_PipeId_t PipeId, CFE_SB_Qos_t Quality)
{
CFE_SB_SingleSubscriptionTlm_t SubRptMsg;
int32 Status;
int32 Status = CFE_SUCCESS;

Status = CFE_SUCCESS;
memset(&SubRptMsg, 0, sizeof(SubRptMsg));

if (CFE_SB_Global.SubscriptionReporting == CFE_SB_ENABLE)
{
Expand Down
4 changes: 2 additions & 2 deletions modules/tbl/fsw/src/cfe_tbl_internal.c
Original file line number Diff line number Diff line change
Expand Up @@ -812,8 +812,8 @@ int32 CFE_TBL_LoadFromFile(const char *AppName, CFE_TBL_LoadBuff_t *WorkingBuffe
int32 OsStatus;
CFE_FS_Header_t StdFileHeader;
CFE_TBL_File_Hdr_t TblFileHeader;
osal_id_t FileDescriptor;
size_t FilenameLen = strlen(Filename);
osal_id_t FileDescriptor = OS_OBJECT_ID_UNDEFINED;
size_t FilenameLen = strlen(Filename);
uint32 NumBytes;
uint8 ExtraByte;

Expand Down
4 changes: 2 additions & 2 deletions modules/tbl/fsw/src/cfe_tbl_task_cmds.c
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,7 @@ int32 CFE_TBL_LoadCmd(const CFE_TBL_LoadCmd_t *data)
const CFE_TBL_LoadCmd_Payload_t *CmdPtr = &data->Payload;
CFE_FS_Header_t StdFileHeader;
CFE_TBL_File_Hdr_t TblFileHeader;
osal_id_t FileDescriptor;
osal_id_t FileDescriptor = OS_OBJECT_ID_UNDEFINED;
int32 Status;
int32 OsStatus;
int16 RegIndex;
Expand Down Expand Up @@ -698,7 +698,7 @@ CFE_TBL_CmdProcRet_t CFE_TBL_DumpToFile(const char *DumpFilename, const char *Ta
bool FileExistedPrev = false;
CFE_FS_Header_t StdFileHeader;
CFE_TBL_File_Hdr_t TblFileHeader;
osal_id_t FileDescriptor;
osal_id_t FileDescriptor = OS_OBJECT_ID_UNDEFINED;
int32 Status;
int32 OsStatus;
int32 EndianCheck = 0x01020304;
Expand Down
2 changes: 2 additions & 0 deletions modules/time/fsw/src/cfe_time_utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,8 @@ CFE_TIME_SysTime_t CFE_TIME_LatchClock(void)
CFE_TIME_SysTime_t LatchTime;
OS_time_t LocalTime;

memset(&LocalTime, 0, sizeof(LocalTime));

/*
** Get time in O/S format (seconds : microseconds)...
*/
Expand Down

0 comments on commit 558b5a4

Please sign in to comment.