Add error handling to calls which can indicate a major problem by
returning an error code.
Signed-off-by: Hartmut Knaack <knaack.h@gmx.de>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
goto error_free_chrdev_name;
}
- close(fd);
+ if (close(fd) == -1) {
+ ret = -errno;
+ goto error_free_chrdev_name;
+ }
while (true) {
ret = read(event_fd, &event, sizeof(event));
print_event(&event);
}
- close(event_fd);
+ if (close(event_fd) == -1)
+ perror("Failed to close event file");
+
error_free_chrdev_name:
free(chrdev_name);
error_ret: