From 17cd0af9c127993bf2eadb87c561e05df3403362 Mon Sep 17 00:00:00 2001 From: Leah Rowe Date: Tue, 13 Jun 2023 22:50:27 +0100 Subject: util/spkmodem-recv: remove unnecessary error check the loop in main() already checks EOF, and errno is properly handled at the end of main() we only need to call ferror(), to check error state this fixes a bogus error message when pressing ctrl+D to terminate the program, *which is the intended way to terminate this program* (that, or EOF is reached in any other another way) do not treat intended behaviour as an error condition! Signed-off-by: Leah Rowe --- util/spkmodem_recv/spkmodem-recv.c | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) (limited to 'util') diff --git a/util/spkmodem_recv/spkmodem-recv.c b/util/spkmodem_recv/spkmodem-recv.c index 72b85d0c..9776ebc8 100644 --- a/util/spkmodem_recv/spkmodem-recv.c +++ b/util/spkmodem_recv/spkmodem-recv.c @@ -44,7 +44,6 @@ char ascii = 0; void handle_audio(void); void fetch_sample(void); -void read_frame(void); int set_ascii_bit(void); void print_char(void); void print_stats(void); @@ -94,7 +93,10 @@ fetch_sample(void) freq_data += pulse[next_ringpos]; freq_separator -= pulse[next_ringpos]; - read_frame(); + fread(frame + ringpos, 1, sizeof(frame[0]), stdin); + if (ferror(stdin) != 0) + err(ERR(), "Could not read from frame."); + if ((pulse[ringpos] = (abs(frame[ringpos]) > THRESHOLD) ? 1 : 0)) ++freq_separator; ++ringpos; @@ -102,14 +104,6 @@ fetch_sample(void) ++sample_count; } -void -read_frame(void) -{ - if ((fread(frame + ringpos, 1, sizeof(frame[0]), stdin) - != sizeof(frame[0])) || (ferror(stdin) != 0)) - err(ERR(), "Could not read from frame."); -} - int set_ascii_bit(void) { -- cgit v1.2.1