- bf = (struct binject_file *) (uintptr_t) f->engine_data;
- fcntl(bf->fd, F_SETFL, bd->fd_flags[i]);
+ struct binject_file *bf = FILE_ENG_DATA(f);
+
+ if (bd->fd_flags[i] == -1)
+ continue;
+
+ if (fcntl(bf->fd, F_SETFL, bd->fd_flags[i]) < 0)
+ log_err("fio: binject failed to restore fcntl flags: %s\n", strerror(errno));