asl: fix void* pointer arithmetic in event data handling#4
Open
JNewtons wants to merge 1 commit into
Open
Conversation
There was a problem hiding this comment.
Pull request overview
This PR addresses a GCC warning (-Wpointer-arith) by making pointer arithmetic on event data well-defined (casting void* to a byte pointer before applying offsets) in the events module.
Changes:
- Cast
void*event buffers tounsigned char*before applying byte offsets when invoking callbacks. - Cast
void*event buffers tounsigned char*before applying byte offsets when writing updated event data viamemcpy.
Comments suppressed due to low confidence (1)
src/alignevents.c:36
DataIndexis wrapped with%= 2after a successful callback, but elsewhere the code usesevent->BufferSizeto compute the next buffer index. Ifbuffer_sizecan be anything other than 2, this will cause the callback to read from a different ring size thanAlign_Events_UpdateEventDatawrites to. Consider either enforcingbuffer_size == 2when adding events (and documenting it) or usingalign_events.Events[i].BufferSizehere instead of the hard-coded2.
bool done = align_events.Events[i].Fptr(((unsigned char *)align_events.Events[i].Data) + (align_events.Events[i].DataIndex * align_events.Events[i].DataSize)); // Call the function pointer with the data
if(done){
align_events.Events[i].LastTime = align_events.EventTimer; // Update the last time the event was triggered
align_events.Events[i].DataIndex++;
align_events.Events[i].DataIndex %= 2;
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
GCC flagger void* pointer arithmetic i alignevents.c (-Wpointer-arith). Denne endringen caster til byte-peker før offset.
Ingen funksjonell endring, kun definert pointer arithmetic.