engines/fileoperations: use local var for ioengine data
authorVincent Fu <vincent.fu@samsung.com>
Fri, 22 Mar 2024 14:21:56 +0000 (10:21 -0400)
committerVincent Fu <vincent.fu@samsung.com>
Fri, 22 Mar 2024 14:21:56 +0000 (10:21 -0400)
Improve code readability by using a local variable for ioengine data.

Signed-off-by: Vincent Fu <vincent.fu@samsung.com>
engines/fileoperations.c

index 58a814963780fab1097e722a944c2490cca79661..c52f09004eefed0f0b04bca197d1ae3601271be1 100644 (file)
@@ -90,6 +90,7 @@ static int open_file(struct thread_data *td, struct fio_file *f)
 {
        struct timespec start;
        int do_lat = !td->o.disable_lat;
+       struct fc_data *fcd = td->io_ops_data;
 
        dprint(FD_FILE, "fd open %s\n", f->file_name);
 
@@ -105,9 +106,9 @@ static int open_file(struct thread_data *td, struct fio_file *f)
        if (do_lat)
                fio_gettime(&start, NULL);
 
-       if (((struct fc_data *)td->io_ops_data)->op_engine == FILE_OP_ENGINE)
+       if (fcd->op_engine == FILE_OP_ENGINE)
                f->fd = open(f->file_name, O_CREAT|O_RDWR, 0600);
-       else if (((struct fc_data *)td->io_ops_data)->op_engine == DIR_OP_ENGINE)
+       else if (fcd->op_engine == DIR_OP_ENGINE)
                f->fd = fio_mkdir(f->file_name, S_IFDIR);
        else {
                log_err("fio: unknown file/directory operation engine\n");
@@ -209,6 +210,7 @@ static int delete_file(struct thread_data *td, struct fio_file *f)
 {
        struct timespec start;
        int do_lat = !td->o.disable_lat;
+       struct fc_data *fcd = td->io_ops_data;
        int ret;
 
        dprint(FD_FILE, "fd delete %s\n", f->file_name);
@@ -225,9 +227,9 @@ static int delete_file(struct thread_data *td, struct fio_file *f)
        if (do_lat)
                fio_gettime(&start, NULL);
 
-       if (((struct fc_data *)td->io_ops_data)->op_engine == FILE_OP_ENGINE)
+       if (fcd->op_engine == FILE_OP_ENGINE)
                ret = unlink(f->file_name);
-       else if (((struct fc_data *)td->io_ops_data)->op_engine == DIR_OP_ENGINE)
+       else if (fcd->op_engine == DIR_OP_ENGINE)
                ret = rmdir(f->file_name);
        else {
                log_err("fio: unknown file/directory operation engine\n");