fdp: cleanup init
authorJens Axboe <axboe@kernel.dk>
Tue, 28 Feb 2023 15:28:51 +0000 (08:28 -0700)
committerJens Axboe <axboe@kernel.dk>
Tue, 28 Feb 2023 15:28:51 +0000 (08:28 -0700)
I don't believe we can have a NULL ->io_ops here, but let's just
add an error check and make the static checkers happy as they don't
like the non-NULL check and then a later deref in the other branch.

Add missing braces while at it.

Signed-off-by: Jens Axboe <axboe@kernel.dk>
fdp.c

diff --git a/fdp.c b/fdp.c
index 0f1aae5e4b9ba0be4e5ed52f35202bc39e60d3a6..c50af1e241cc071573fd8fcf6e07649dc7859736 100644 (file)
--- a/fdp.c
+++ b/fdp.c
@@ -20,16 +20,22 @@ static int fdp_ruh_info(struct thread_data *td, struct fio_file *f,
 {
        int ret = -EINVAL;
 
-       if (td->io_ops && td->io_ops->fdp_fetch_ruhs) {
+       if (!td->io_ops) {
+               log_err("fio: no ops set in fdp init?!\n");
+               return ret;
+       }
+
+       if (td->io_ops->fdp_fetch_ruhs) {
                ret = td->io_ops->fdp_fetch_ruhs(td, f, ruhs);
                if (ret < 0) {
                        td_verror(td, errno, "fdp fetch ruhs failed");
                        log_err("%s: fdp fetch ruhs failed (%d)\n",
                                f->file_name, errno);
                }
-       } else
+       } else {
                log_err("%s: engine (%s) lacks fetch ruhs\n",
                        f->file_name, td->io_ops->name);
+       }
 
        return ret;
 }