From: Tomohiro Kusumi Date: Mon, 1 Jun 2015 13:21:29 +0000 (+0900) Subject: Minor cleanups on cleanup() X-Git-Tag: fio-2.2.9~23^2 X-Git-Url: https://git.kernel.dk/?p=fio.git;a=commitdiff_plain;h=02a3d83f79e3c5fb9490432cdc17a3be36ac32ad Minor cleanups on cleanup() 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. --- diff --git a/engines/null.c b/engines/null.c index 60009305..41d42e05 100644 --- a/engines/null.c +++ b/engines/null.c @@ -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); } } diff --git a/engines/sync.c b/engines/sync.c index 48aafff8..f5801fec 100644 --- a/engines/sync.c +++ b/engines/sync.c @@ -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 = {