Skip to content

Commit

Permalink
Fix #110, Adds JSC 2.1 Static Analysis comments
Browse files Browse the repository at this point in the history
  • Loading branch information
jdfiguer authored and jdfiguer committed Jun 10, 2024
1 parent b8769cd commit 90ac3ed
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 2 additions & 0 deletions fsw/src/lc_cmds.c
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,7 @@ CFE_Status_t LC_SendHkCmd(const CFE_MSG_CommandHeader_t *MsgPtr)
}

/* Update houskeeping watch results array */
/* SAD: HKIndex is derived from TableIndex, ensuring it stays within the bounds of the WPResults array */
PayloadPtr->WPResults[HKIndex] = ByteData;
}

Expand Down Expand Up @@ -248,6 +249,7 @@ CFE_Status_t LC_SendHkCmd(const CFE_MSG_CommandHeader_t *MsgPtr)
}

/* Update houskeeping action results array */
/* SAD: HKIndex is derived from TableIndex, ensuring it stays within the bounds of the APResults array */
PayloadPtr->APResults[HKIndex] = ByteData;
}

Expand Down
6 changes: 5 additions & 1 deletion fsw/src/lc_watch.c
Original file line number Diff line number Diff line change
Expand Up @@ -493,6 +493,7 @@ uint8 LC_OperatorCompare(uint16 WatchIndex, uint32 ProcessedWPData)
WatchpointValue.Unsigned32 = ProcessedWPData;
break;
}
/* SAD: Using memcpy to safely copy the float value from LC_MultiType_t to ComparisonValue, preserving bitwise representation */
memcpy(&ComparisonValue, &LC_OperData.WDTPtr[WatchIndex].ComparisonValue, sizeof(LC_MultiType_t));

/*
Expand Down Expand Up @@ -680,8 +681,9 @@ uint8 LC_FloatCompare(uint16 WatchIndex, LC_MultiType_t *WPMultiType, LC_MultiTy
float Diff;

OperatorID = LC_OperData.WDTPtr[WatchIndex].OperatorID;

/* SAD: Using memcpy to safely copy the float value from LC_MultiType_t to WPFloat, preserving bitwise representation */
memcpy(&WPFloat, WPMultiType, sizeof(float));
/* SAD: Using memcpy to safely copy the float value from LC_MultiType_t to CompareFloat, preserving bitwise representation */
memcpy(&CompareFloat, CompareMultiType, sizeof(float));

/*
Expand Down Expand Up @@ -1021,6 +1023,7 @@ int32 LC_ValidateWDT(void *TableData)
}
else if ((DataType == LC_DATA_WATCH_FLOAT_BE) || (DataType == LC_DATA_WATCH_FLOAT_LE))
{
/* SAD: Using memcpy to safely copy the float value from LC_MultiType_t to FloatValue, preserving bitwise representation */
memcpy(&FloatValue, &TableArray[TableIndex].ComparisonValue, sizeof(FloatValue));

/*
Expand Down Expand Up @@ -1060,6 +1063,7 @@ int32 LC_ValidateWDT(void *TableData)
{
if ((EntryResult == LC_WDTVAL_ERR_FPNAN) || (EntryResult == LC_WDTVAL_ERR_FPINF))
{
/* SAD: Using memcpy to safely copy the uint32 value from LC_MultiType_t to PrintableBits, preserving bitwise representation */
memcpy(&PrintableBits, &TableArray[TableIndex].ComparisonValue, sizeof(PrintableBits));
CFE_EVS_SendEvent(LC_WDTVAL_FPERR_EID, CFE_EVS_EventType_ERROR,
"WDT verify float err: WP = %d, Err = %d, ComparisonValue = 0x%08X", (int)TableIndex,
Expand Down

0 comments on commit 90ac3ed

Please sign in to comment.