mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-29 19:21:31 -04:00
tools:iio:iio_event_monitor: save right errno
Move up error handling code to preserve the errno coming from ioctl(), before it may be changed by close(). Signed-off-by: Hartmut Knaack <[email protected]> Signed-off-by: Jonathan Cameron <[email protected]>
This commit is contained in:
parent
2b6a6e67af
commit
5fdb8c6127
1 changed files with 5 additions and 3 deletions
|
|
@ -275,15 +275,17 @@ int main(int argc, char **argv)
|
|||
}
|
||||
|
||||
ret = ioctl(fd, IIO_GET_EVENT_FD_IOCTL, &event_fd);
|
||||
|
||||
close(fd);
|
||||
|
||||
if (ret == -1 || event_fd == -1) {
|
||||
ret = -errno;
|
||||
fprintf(stdout, "Failed to retrieve event fd\n");
|
||||
if (close(fd) == -1)
|
||||
perror("Failed to close character device file");
|
||||
|
||||
goto error_free_chrdev_name;
|
||||
}
|
||||
|
||||
close(fd);
|
||||
|
||||
while (true) {
|
||||
ret = read(event_fd, &event, sizeof(event));
|
||||
if (ret == -1) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue