iio.c: Check return of fd before using ioctl