Skip to content

Fix #1514, Use XOR to swap between ping-pong buffers (style change only)#2351

Open
thnkslprpt wants to merge 1 commit intonasa:mainfrom
thnkslprpt:fix-1514-use-XOR-to-swap-ping-pong-buffers
Open

Fix #1514, Use XOR to swap between ping-pong buffers (style change only)#2351
thnkslprpt wants to merge 1 commit intonasa:mainfrom
thnkslprpt:fix-1514-use-XOR-to-swap-ping-pong-buffers

Conversation

@thnkslprpt
Copy link
Contributor

Checklist

Describe the contribution

Testing performed
GitHub CI actions all passing successfully (incl. Build + Run, Unit/Functional Tests etc.).

Expected behavior changes
No change to behavior.

Contributor Info
Avi Weiss @thnkslprpt

/* Call the Application's Validation function for the Inactive Buffer */
Status =
(RegRecPtr->ValidationFuncPtr)(RegRecPtr->Buffers[(1U - RegRecPtr->ActiveBufferIndex)].BufferPtr);
(RegRecPtr->ValidationFuncPtr)(RegRecPtr->Buffers[(RegRecPtr->ActiveBufferIndex ^ 1)].BufferPtr);

Check notice

Code scanning / CodeQL

Use of non-constant function pointer

This call does not go through a const function pointer.
DumpCmd.Payload.ActiveTableFlag = CFE_TBL_BufferSelect_INACTIVE;
CFE_TBL_Global.Registry[2].DoubleBuffered = true;
CFE_TBL_Global.Registry[2].Buffers[(1 - CFE_TBL_Global.Registry[2].ActiveBufferIndex)].BufferPtr = BuffPtr;
CFE_TBL_Global.Registry[2].Buffers[(CFE_TBL_Global.Registry[2].ActiveBufferIndex ^ 1)].BufferPtr = BuffPtr;

Check warning

Code scanning / CodeQL

Local variable address stored in non-local memory

A stack address ([source](1)) may be assigned to a non-local variable.
ValidateCmd.Payload.ActiveTableFlag = CFE_TBL_BufferSelect_INACTIVE;
CFE_TBL_Global.Registry[0].DoubleBuffered = true;
CFE_TBL_Global.Registry[0].Buffers[1 - CFE_TBL_Global.Registry[0].ActiveBufferIndex].BufferPtr = BuffPtr;
CFE_TBL_Global.Registry[0].Buffers[CFE_TBL_Global.Registry[0].ActiveBufferIndex ^ 1].BufferPtr = BuffPtr;

Check warning

Code scanning / CodeQL

Local variable address stored in non-local memory

A stack address ([source](1)) may be assigned to a non-local variable.
@thnkslprpt thnkslprpt force-pushed the fix-1514-use-XOR-to-swap-ping-pong-buffers branch from 283aa6c to e133e03 Compare April 19, 2024 21:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Use XOR for ping-pong buffer in TBL

1 participant