summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLeah Rowe <leah@libreboot.org>2023-06-13 22:50:27 +0100
committerLeah Rowe <leah@libreboot.org>2023-06-13 22:52:12 +0100
commit17cd0af9c127993bf2eadb87c561e05df3403362 (patch)
treeedc215495d56ea01ccc972651861572023adb227
parenta1758a7ab082944cbcd41d3fa4a547d4fc218601 (diff)
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 <leah@libreboot.org>
-rw-r--r--util/spkmodem_recv/spkmodem-recv.c14
1 files changed, 4 insertions, 10 deletions
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)
{