Commit 97b603a4 authored by Peter Meerwald's avatar Peter Meerwald Committed by Jonathan Cameron

staging:iio: Fix error handling in generic_buffer example

read() does not return -EAGAIN
read() returns -1 and the errno value needs to be checked for -EAGAIN
Signed-off-by: default avatarPeter Meerwald <pmeerw@pmeerw.net>
Signed-off-by: default avatarJonathan Cameron <jic23@kernel.org>
parent 723db167
......@@ -305,9 +305,12 @@ int main(int argc, char **argv)
read_size = read(fp,
data,
toread*scan_size);
if (read_size == -EAGAIN) {
printf("nothing available\n");
continue;
if (read_size < 0) {
if (errno == -EAGAIN) {
printf("nothing available\n");
continue;
} else
break;
}
for (i = 0; i < read_size/scan_size; i++)
process_scan(data + scan_size*i,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment