engines/nvme: cache errno value
authorJens Axboe <axboe@kernel.dk>
Tue, 4 Apr 2023 14:51:31 +0000 (08:51 -0600)
committerJens Axboe <axboe@kernel.dk>
Tue, 4 Apr 2023 14:51:31 +0000 (08:51 -0600)
It's pretty pointless to do a bunch of things in between getting
a -1/errno value, and then expect errno to still be what you want.

Signed-off-by: Jens Axboe <axboe@kernel.dk>
engines/nvme.c

index ac9086876c24f11f105bcd7188d343c1684f1619..fd2161f363bf5ddcda6fe45501bfcc8e79898a7d 100644 (file)
@@ -112,9 +112,10 @@ int fio_nvme_get_info(struct fio_file *f, __u32 *nsid, __u32 *lba_sz,
 
        namespace_id = ioctl(fd, NVME_IOCTL_ID);
        if (namespace_id < 0) {
+               err = -errno;
                log_err("failed to fetch namespace-id");
                close(fd);
-               return -errno;
+               return err;
        }
 
        /*
@@ -414,6 +415,7 @@ int fio_nvme_iomgmt_ruhs(struct thread_data *td, struct fio_file *f,
        } else
                errno = 0;
 
+       ret = -errno;
        close(fd);
-       return -errno;
+       return ret;
 }