Skip to content

Commit

Permalink
Fix #2196, resolve static analysis errors
Browse files Browse the repository at this point in the history
Resolves two uninitialized variable errors reported in the workflow,
and other minor style items.  Add suppressions for endian checks
which are constant on a given arch.
  • Loading branch information
jphickey committed Nov 3, 2022
1 parent 7a220ae commit 660590b
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 2 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/static-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ jobs:
name: Run cppcheck
uses: nasa/cFS/.github/workflows/static-analysis.yml@main
with:
strict-dir-list: './modules/core_api/fsw ./modules/core_private/fsw ./modules/es/fsw ./modules/evs/fsw ./modules/fs/fsw ./modules/msg/fsw ./modules/resourceid/fsw ./modules/sb/fsw ./modules/sbr/fsw ./modules/tbl/fsw ./modules/time/fsw -UCFE_PLATFORM_TIME_CFG_CLIENT -DCFE_PLATFORM_TIME_CFG_SERVER'
strict-dir-list: './modules/core_api/fsw ./modules/core_private/fsw ./modules/es/fsw ./modules/evs/fsw ./modules/fs/fsw ./modules/msg/fsw ./modules/resourceid/fsw ./modules/sb/fsw ./modules/sbr/fsw ./modules/tbl/fsw ./modules/time/fsw -UCFE_PLATFORM_TIME_CFG_CLIENT -DCFE_PLATFORM_TIME_CFG_SERVER'
4 changes: 4 additions & 0 deletions modules/fs/fsw/src/cfe_fs_api.c
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ CFE_Status_t CFE_FS_ReadHeader(CFE_FS_Header_t *Hdr, osal_id_t FileDes)
OsStatus = OS_read(FileDes, Hdr, sizeof(CFE_FS_Header_t));

/* Determine if this processor is a little endian processor */
/* cppcheck-suppress knownConditionTrueFalse */
if ((*(char *)(&EndianCheck)) == 0x04)
{
/* If this is a little endian processor, then convert the header data structure from */
Expand Down Expand Up @@ -231,6 +232,7 @@ CFE_Status_t CFE_FS_WriteHeader(osal_id_t FileDes, CFE_FS_Header_t *Hdr)
/*
** Determine if this is a little endian processor
*/
/* cppcheck-suppress knownConditionTrueFalse */
if ((*(char *)(&EndianCheck)) == 0x04)
{
/* If this is a little endian processor, then convert the header data structure from */
Expand All @@ -246,6 +248,7 @@ CFE_Status_t CFE_FS_WriteHeader(osal_id_t FileDes, CFE_FS_Header_t *Hdr)
/*
** Determine if this is a little endian processor
*/
/* cppcheck-suppress knownConditionTrueFalse */
if ((*(char *)(&EndianCheck)) == 0x04)
{
/* If this is a little endian processor, then convert the header data structure back */
Expand Down Expand Up @@ -290,6 +293,7 @@ CFE_Status_t CFE_FS_SetTimestamp(osal_id_t FileDes, CFE_TIME_SysTime_t NewTimest
/*
** Determine if this is a little endian processor
*/
/* cppcheck-suppress knownConditionTrueFalse */
if ((*(char *)(&EndianCheck)) == 0x04)
{
/* If this processor is a little endian processor, then convert the timestamp to a big */
Expand Down
2 changes: 1 addition & 1 deletion modules/sb/fsw/src/cfe_sb_priv.h
Original file line number Diff line number Diff line change
Expand Up @@ -564,7 +564,7 @@ static inline CFE_SB_BufferLink_t *CFE_SB_TrackingListGetNext(CFE_SB_BufferLink_
/**
* \brief For SB buffer tracking, checks if this current position represents the end of the list
*/
static inline bool CFE_SB_TrackingListIsEnd(CFE_SB_BufferLink_t *List, CFE_SB_BufferLink_t *Node)
static inline bool CFE_SB_TrackingListIsEnd(const CFE_SB_BufferLink_t *List, const CFE_SB_BufferLink_t *Node)
{
/* Normally list nodes should never have NULL, buf if they do, do not follow it */
return (Node == NULL || Node == List);
Expand Down
1 change: 1 addition & 0 deletions modules/tbl/fsw/src/cfe_tbl_internal.c
Original file line number Diff line number Diff line change
Expand Up @@ -1113,6 +1113,7 @@ int32 CFE_TBL_ReadHeaders(osal_id_t FileDescriptor, CFE_FS_Header_t *StdFileHead
/* All "required" checks have passed and we are pointing at the data */
Status = CFE_SUCCESS;

/* cppcheck-suppress knownConditionTrueFalse */
if ((*(char *)&EndianCheck) == 0x04)
{
/* If this is a little endian processor, then the standard cFE Table Header, */
Expand Down
4 changes: 4 additions & 0 deletions modules/tbl/ut-coverage/tbl_UT.c
Original file line number Diff line number Diff line change
Expand Up @@ -2401,6 +2401,8 @@ void Test_CFE_TBL_ReleaseAddresses(void)
/* Test releasing 0 then 1 addresses */
UT_InitData();

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

/* a. Configure for successful file read to initialize table */
strncpy(FileHeader.Description, "FS header description", sizeof(FileHeader.Description) - 1);
FileHeader.Description[sizeof(FileHeader.Description) - 1] = '\0';
Expand Down Expand Up @@ -3057,6 +3059,8 @@ void Test_CFE_TBL_TblMod(void)
/* b. Perform test */
UT_ClearEventHistory();

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

/* Configure for successful file read to initialize table */
strncpy(FileHeader.Description, "FS header description", sizeof(FileHeader.Description) - 1);
FileHeader.Description[sizeof(FileHeader.Description) - 1] = '\0';
Expand Down

0 comments on commit 660590b

Please sign in to comment.