diff options
| author | Leah Rowe <leah@libreboot.org> | 2026-03-11 23:40:34 +0000 |
|---|---|---|
| committer | Leah Rowe <leah@libreboot.org> | 2026-03-11 23:40:34 +0000 |
| commit | bbb8825553641f598ce120d3ffd3beb360e60d09 (patch) | |
| tree | 07d3d47bd84bc81bf1de632eae57693641a04b7c | |
| parent | 42cad20ffd10721eed3d386b139e94c9e376a000 (diff) | |
util/nvmutil: further clean up decode_pulse()
Signed-off-by: Leah Rowe <leah@libreboot.org>
| -rw-r--r-- | util/spkmodem_recv/spkmodem-recv.c | 19 |
1 files changed, 9 insertions, 10 deletions
diff --git a/util/spkmodem_recv/spkmodem-recv.c b/util/spkmodem_recv/spkmodem-recv.c index 9307ac12..7183563b 100644 --- a/util/spkmodem_recv/spkmodem-recv.c +++ b/util/spkmodem_recv/spkmodem-recv.c @@ -113,27 +113,26 @@ static void decode_pulse(void) { size_t n; - size_t frame_size; + int next_ringpos; - int next_ringpos = (ringpos + SAMPLES_PER_FRAME) % MAX_SAMPLES; + next_ringpos = (ringpos + SAMPLES_PER_FRAME) % MAX_SAMPLES; freq_data -= pulse[ringpos]; freq_data += pulse[next_ringpos]; freq_separator -= pulse[next_ringpos]; - frame_size = sizeof(frame[0]); - n = fread(&frame[ringpos], 1, frame_size, stdin); - - if (n != frame_size) { + n = fread(&frame[ringpos], 1, sizeof(frame[0]), stdin); + if (n != sizeof(frame[0])) { if (feof(stdin)) exit(EXIT_SUCCESS); - if (ferror(stdin)) - err(errno, "Could not read from frame."); + err(errno, "stdin read"); } pulse[ringpos] = (abs(frame[ringpos]) > THRESHOLD) ? 1 : 0; - freq_separator += pulse[ringpos++]; - ringpos %= MAX_SAMPLES; + + freq_separator += pulse[ringpos]; + ringpos = (ringpos + 1) % MAX_SAMPLES; + ++sample_count; } |
