Skip to content

asl: fix void* pointer arithmetic in event data handling#4

Open
JNewtons wants to merge 1 commit into
align-racing-uia:AR25from
JNewtons:fix/voidptr-arith
Open

asl: fix void* pointer arithmetic in event data handling#4
JNewtons wants to merge 1 commit into
align-racing-uia:AR25from
JNewtons:fix/voidptr-arith

Conversation

@JNewtons

Copy link
Copy Markdown

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.

Copilot AI review requested due to automatic review settings February 25, 2026 06:07

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 to unsigned char* before applying byte offsets when invoking callbacks.
  • Cast void* event buffers to unsigned char* before applying byte offsets when writing updated event data via memcpy.
Comments suppressed due to low confidence (1)

src/alignevents.c:36

  • DataIndex is wrapped with %= 2 after a successful callback, but elsewhere the code uses event->BufferSize to compute the next buffer index. If buffer_size can be anything other than 2, this will cause the callback to read from a different ring size than Align_Events_UpdateEventData writes to. Consider either enforcing buffer_size == 2 when adding events (and documenting it) or using align_events.Events[i].BufferSize here instead of the hard-coded 2.
          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.

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.

2 participants