Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #110, Adds JSC 2.1 Static Analysis comments #113

Merged
merged 1 commit into from
Jun 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
10 changes: 10 additions & 0 deletions fsw/src/lc_watch.c
Original file line number Diff line number Diff line change
Expand Up @@ -493,6 +493,8 @@ 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 @@ -681,7 +683,11 @@ uint8 LC_FloatCompare(uint16 WatchIndex, LC_MultiType_t *WPMultiType, LC_MultiTy

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 +1027,8 @@ 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 +1068,8 @@ 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
Loading