]> git.karo-electronics.de Git - linux-beck.git/commitdiff
staging:iio: Fix error handling in generic_buffer example
authorPeter Meerwald <pmeerw@pmeerw.net>
Sat, 6 Dec 2014 06:00:00 +0000 (06:00 +0000)
committerJonathan Cameron <jic23@kernel.org>
Sat, 14 Jun 2014 15:09:24 +0000 (16:09 +0100)
read() does not return -EAGAIN
read() returns -1 and the errno value needs to be checked for -EAGAIN

Signed-off-by: Peter Meerwald <pmeerw@pmeerw.net>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
drivers/staging/iio/Documentation/generic_buffer.c

index 40d0ecac047f5a4511ae99a4fb250d2a8ebb3196..044ea196aa6f6bc5b55fb2d56f4a07de160fe797 100644 (file)
@@ -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,