From 20c0820910f5967c1a14abbf430db151639d5aa7 Mon Sep 17 00:00:00 2001 From: Loic Coenen Date: Sat, 9 May 2026 14:46:09 +0000 Subject: [PATCH] refactor: use explicit pointer casts to clarify type conversions Co-authored-by: aider (deepseek/deepseek-reasoner) --- src/looper.c | 6 ++++-- tests/integration.c | 10 +++++----- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/src/looper.c b/src/looper.c index d045092..dae0dd1 100644 --- a/src/looper.c +++ b/src/looper.c @@ -79,11 +79,13 @@ int process_callback(jack_nframes_t nframes, void *arg) { switch (state) { case STATE_RECORD: if (in) { + float *f_out = (float *)out; + const float *f_in = (const float *)in; for (i = 0; i < nframes; i++) { if (channels[c].record_pos < LOOP_BUF_SIZE) channels[c].loop_buffer[channels[c].record_pos++] = - ((const float *)in)[i]; - ((float *)out)[i] = ((const float *)in)[i]; // cppcheck-suppress unreadVariable + f_in[i]; + f_out[i] = f_in[i]; } } else { memset(out, 0, sizeof(jack_default_audio_sample_t) * nframes); diff --git a/tests/integration.c b/tests/integration.c index 1d5f446..1d4eea2 100644 --- a/tests/integration.c +++ b/tests/integration.c @@ -68,8 +68,8 @@ static int passthrough_process(jack_nframes_t nframes, void *arg) { const jack_default_audio_sample_t *in = (const jack_default_audio_sample_t *)jack_port_get_buffer(passthrough_input_port, nframes); if (!out || !in) return 0; - float *outf = out; - const float *inf = in; + float *f_out = (float *)out; + const float *f_in = (const float *)in; for (jack_nframes_t i = 0; i < nframes; i++) { /* generate beep while beep_remaining > 0 or continuous sine */ float out_val; @@ -82,17 +82,17 @@ static int passthrough_process(jack_nframes_t nframes, void *arg) { } else { out_val = 0.0f; } - outf[i] = out_val; + f_out[i] = out_val; /* detect bursts on the input (looper output) */ - float sample = inf[i]; + float sample = f_in[i]; int above = (fabsf(sample) > 0.05f); if (above && !prev_above) { bursts++; } prev_above = above; - passthrough_sum_sq += (double)inf[i] * (double)inf[i]; + passthrough_sum_sq += (double)f_in[i] * (double)f_in[i]; passthrough_total_samples++; } if (passthrough_total_samples >= passthrough_sample_rate * 2) {