Skip to content
Snippets Groups Projects
Verified Commit fefcad37 authored by Ralph Giles's avatar Ralph Giles
Browse files

trivial_example: Check the return value of fread().


Silence a gcc warning by checking the return value of the fread()
call instead of the feof() guard. This prevents an infinite loop
in the case of a read error. Otherwise, when end-of-file is reached
fread() will certainly return a smaller number of elements read
than requested, so both cases are handled now.

Add a comment to clarify that we're dropping a partial frame on
purpose to keep the code simple.

Also add more braces around conditional bodies for less error-prone
style.

Signed-off-by: default avatarMark Harris <mark.hsj@gmail.com>
parent 1168a29e
No related branches found
No related tags found
1 merge request!4Fix trivial_example
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment