Minor cleanups on cleanup()
authorTomohiro Kusumi <kusumi.tomohiro@gmail.com>
Mon, 1 Jun 2015 13:21:29 +0000 (22:21 +0900)
committerTomohiro Kusumi <kusumi.tomohiro@gmail.com>
Mon, 1 Jun 2015 13:21:29 +0000 (22:21 +0900)
Sync with the way other engines implement cleanup() that is regarded
as a better practice. td->io_ops->data should have null check before
dereference and its members can be freed without null check.

engines/null.c
engines/sync.c

index 600093052d683bc1d3e5a44d2ecd5e590e5d4786..41d42e0513b2f2670424c7955d0d03fee2761eb0 100644 (file)
@@ -86,8 +86,7 @@ static void fio_null_cleanup(struct thread_data *td)
        struct null_data *nd = (struct null_data *) td->io_ops->data;
 
        if (nd) {
-               if (nd->io_us)
-                       free(nd->io_us);
+               free(nd->io_us);
                free(nd);
        }
 }
index 48aafff8f153772804095edd541ce2858f225876..f5801fec9a9fd7a471e18d90fbb048d7a9fd03ec 100644 (file)
@@ -317,9 +317,11 @@ static void fio_vsyncio_cleanup(struct thread_data *td)
 {
        struct syncio_data *sd = td->io_ops->data;
 
-       free(sd->iovecs);
-       free(sd->io_us);
-       free(sd);
+       if (sd) {
+               free(sd->iovecs);
+               free(sd->io_us);
+               free(sd);
+       }
 }
 
 static struct ioengine_ops ioengine_rw = {