Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit e133e03

Browse files
committedApr 19, 2024·
Fix #1514, Use XOR to swap between ping-pong buffers (style change
only)
1 parent 28a5820 commit e133e03

File tree

4 files changed

+9
-9
lines changed

4 files changed

+9
-9
lines changed
 

‎modules/tbl/fsw/src/cfe_tbl_api.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -867,12 +867,12 @@ CFE_Status_t CFE_TBL_Validate(CFE_TBL_Handle_t TblHandle)
867867
{
868868
/* Call the Application's Validation function for the Inactive Buffer */
869869
Status =
870-
(RegRecPtr->ValidationFuncPtr)(RegRecPtr->Buffers[(1U - RegRecPtr->ActiveBufferIndex)].BufferPtr);
870+
(RegRecPtr->ValidationFuncPtr)(RegRecPtr->Buffers[(RegRecPtr->ActiveBufferIndex ^ 1)].BufferPtr);
871871

872872
/* Allow buffer to be activated after passing validation */
873873
if (Status == CFE_SUCCESS)
874874
{
875-
RegRecPtr->Buffers[(1U - RegRecPtr->ActiveBufferIndex)].Validated = true;
875+
RegRecPtr->Buffers[(RegRecPtr->ActiveBufferIndex ^ 1)].Validated = true;
876876
}
877877
}
878878
else

‎modules/tbl/fsw/src/cfe_tbl_internal.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -344,7 +344,7 @@ int32 CFE_TBL_GetWorkingBuffer(CFE_TBL_LoadBuff_t **WorkingBufferPtr, CFE_TBL_Re
344344
{
345345
if (RegRecPtr->DoubleBuffered)
346346
{
347-
*WorkingBufferPtr = &RegRecPtr->Buffers[(1U - RegRecPtr->ActiveBufferIndex)];
347+
*WorkingBufferPtr = &RegRecPtr->Buffers[(RegRecPtr->ActiveBufferIndex ^ 1)];
348348
}
349349
else
350350
{

‎modules/tbl/fsw/src/cfe_tbl_task_cmds.c

+4-4
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,7 @@ void CFE_TBL_GetTblRegData(void)
264264
{
265265
/* For a double buffered table, the inactive is the other allocated buffer */
266266
CFE_TBL_Global.TblRegPacket.Payload.InactiveBufferAddr =
267-
CFE_ES_MEMADDRESS_C(RegRecPtr->Buffers[(1U - RegRecPtr->ActiveBufferIndex)].BufferPtr);
267+
CFE_ES_MEMADDRESS_C(RegRecPtr->Buffers[(RegRecPtr->ActiveBufferIndex ^ 1)].BufferPtr);
268268
}
269269
else
270270
{
@@ -565,7 +565,7 @@ int32 CFE_TBL_DumpCmd(const CFE_TBL_DumpCmd_t *data)
565565
/* If this is a double buffered table, locating the inactive buffer is trivial */
566566
if (RegRecPtr->DoubleBuffered)
567567
{
568-
DumpDataAddr = RegRecPtr->Buffers[(1U - RegRecPtr->ActiveBufferIndex)].BufferPtr;
568+
DumpDataAddr = RegRecPtr->Buffers[(RegRecPtr->ActiveBufferIndex ^ 1)].BufferPtr;
569569
}
570570
else
571571
{
@@ -827,7 +827,7 @@ int32 CFE_TBL_ValidateCmd(const CFE_TBL_ValidateCmd_t *data)
827827
/* If this is a double buffered table, locating the inactive buffer is trivial */
828828
if (RegRecPtr->DoubleBuffered)
829829
{
830-
ValidationDataPtr = RegRecPtr->Buffers[(1U - RegRecPtr->ActiveBufferIndex)].BufferPtr;
830+
ValidationDataPtr = RegRecPtr->Buffers[(RegRecPtr->ActiveBufferIndex ^ 1)].BufferPtr;
831831
}
832832
else
833833
{
@@ -966,7 +966,7 @@ int32 CFE_TBL_ActivateCmd(const CFE_TBL_ActivateCmd_t *data)
966966
/* Determine if the inactive buffer has been successfully validated or not */
967967
if (RegRecPtr->DoubleBuffered)
968968
{
969-
ValidationStatus = RegRecPtr->Buffers[(1U - RegRecPtr->ActiveBufferIndex)].Validated;
969+
ValidationStatus = RegRecPtr->Buffers[(RegRecPtr->ActiveBufferIndex ^ 1)].Validated;
970970
}
971971
else
972972
{

‎modules/tbl/ut-coverage/tbl_UT.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -726,7 +726,7 @@ void Test_CFE_TBL_ValidateCmd(void)
726726
UT_InitData();
727727
ValidateCmd.Payload.ActiveTableFlag = CFE_TBL_BufferSelect_INACTIVE;
728728
CFE_TBL_Global.Registry[0].DoubleBuffered = true;
729-
CFE_TBL_Global.Registry[0].Buffers[1 - CFE_TBL_Global.Registry[0].ActiveBufferIndex].BufferPtr = BuffPtr;
729+
CFE_TBL_Global.Registry[0].Buffers[CFE_TBL_Global.Registry[0].ActiveBufferIndex ^ 1].BufferPtr = BuffPtr;
730730
CFE_TBL_Global.ValidationResults[0].State = CFE_TBL_VALIDATION_FREE;
731731
CFE_TBL_Global.Registry[0].ValidationFuncPtr = ValFuncPtr;
732732
UtAssert_INT32_EQ(CFE_TBL_ValidateCmd(&ValidateCmd), CFE_TBL_INC_CMD_CTR);
@@ -1111,7 +1111,7 @@ void Test_CFE_TBL_DumpCmd(void)
11111111
UT_InitData();
11121112
DumpCmd.Payload.ActiveTableFlag = CFE_TBL_BufferSelect_INACTIVE;
11131113
CFE_TBL_Global.Registry[2].DoubleBuffered = true;
1114-
CFE_TBL_Global.Registry[2].Buffers[(1 - CFE_TBL_Global.Registry[2].ActiveBufferIndex)].BufferPtr = BuffPtr;
1114+
CFE_TBL_Global.Registry[2].Buffers[(CFE_TBL_Global.Registry[2].ActiveBufferIndex ^ 1)].BufferPtr = BuffPtr;
11151115
CFE_TBL_Global.Registry[2].DumpControlIndex = CFE_TBL_NO_DUMP_PENDING + 1;
11161116
UtAssert_INT32_EQ(CFE_TBL_DumpCmd(&DumpCmd), CFE_TBL_INC_ERR_CTR);
11171117

0 commit comments

Comments
 (0)
Please sign in to comment.