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>
This commit is contained in:
Leah Rowe
2023-06-13 22:50:27 +01:00
parent a1758a7ab0
commit 17cd0af9c1
+4 -10
View File
@@ -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)
{