Skip to content

Commit 2339c88

Browse files
bwhitmanclaude
andauthored
Use intptr_t instead of int64_t for void* state casts (#571)
The yield_synth_events and yield_synth_commands functions use void* as an opaque integer state. On 32-bit targets (ESP32), casting between void* and int64_t triggers -Wpointer-to-int-cast warnings since the sizes differ. intptr_t is guaranteed to match pointer width on all platforms. Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 35f955f commit 2339c88

1 file changed

Lines changed: 5 additions & 5 deletions

File tree

src/patches.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -621,7 +621,7 @@ void *yield_synth_events(uint8_t synth, struct amy_event *event, void *state) {
621621
int num_oscs = 0;
622622
while(osc_to_voice[base_osc + num_oscs] == voice) ++num_oscs;
623623
// The "state" indicates which osc within the voice we're going to report for.
624-
int state_val = (int64_t)state;
624+
int state_val = (intptr_t)state;
625625
//fprintf(stderr, "yield_synth_events(%d) voice=%d num_oscs=%d state_val=%d\n", synth, voice, num_oscs, (int)state_val);
626626
amy_clear_event(event);
627627
if (state_val < num_oscs) {
@@ -634,18 +634,18 @@ void *yield_synth_events(uint8_t synth, struct amy_event *event, void *state) {
634634
}
635635
++state_val;
636636
if (state_val == num_oscs + 1) state_val = 0; // Indicate this is the final event.
637-
return (void *)((int64_t)state_val);
637+
return (void *)((intptr_t)state_val);
638638
}
639639

640640
#define STATE_START_OF_MIDI 1024
641641
void *yield_synth_commands(uint8_t synth, char *s, size_t len, void *state) {
642642
// Generator to return multiple wirecode strings to reconfigure a synth.
643-
int state_val = (int64_t)state;
643+
int state_val = (intptr_t)state;
644644
//fprintf(stderr, "yield_synth_commands: synth %d state %d\n", synth, state_val);
645645
s[0] = '\0'; // By default, return an empty string.
646646
if (state_val < STATE_START_OF_MIDI) {
647647
amy_event event = amy_default_event();
648-
state_val = (int64_t)yield_synth_events(synth, &event, (void *)(int64_t)state_val);
648+
state_val = (intptr_t)yield_synth_events(synth, &event, (void *)(intptr_t)state_val);
649649
sprint_event(&event, s, len, /* wirecode= */ true);
650650
if (state_val == 0) {
651651
// Push the state machine on to the MIDI codes
@@ -666,7 +666,7 @@ void *yield_synth_commands(uint8_t synth, char *s, size_t len, void *state) {
666666
state_val = 0; // Will terminate the yield cycle.
667667
}
668668
}
669-
return (void *)(int64_t)state_val;
669+
return (void *)(intptr_t)state_val;
670670
}
671671

672672

0 commit comments

Comments
 (0)