From a93259c9d05c69d4d32f2d1ce459e6a960077b17 Mon Sep 17 00:00:00 2001 From: Vincent Fu Date: Sat, 15 Apr 2023 00:51:44 +0000 Subject: [PATCH] engines: separate declaration and assignment Separate the declaraction and assignment for some variables. This is a prep patch for a Coccinelle script that converts mallloc+memset(,0,) to calloc. Part of this patch was created using the Coccinelle script below. @@ identifier x; expression y; statement s; type T; @@ -T x = malloc(y); +T x; +x = malloc(y); ( if (!x) s | if (x == NULL) s | ) memset(x, 0, y); Signed-off-by: Vincent Fu --- engines/null.c | 3 ++- engines/posixaio.c | 3 ++- engines/solarisaio.c | 3 ++- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/engines/null.c b/engines/null.c index 68c9969c..c17697bf 100644 --- a/engines/null.c +++ b/engines/null.c @@ -106,7 +106,8 @@ static void null_cleanup(struct null_data *nd) static struct null_data *null_init(struct thread_data *td) { - struct null_data *nd = malloc(sizeof(*nd)); + struct null_data *nd; + nd = malloc(sizeof(*nd)); memset(nd, 0, sizeof(*nd)); diff --git a/engines/posixaio.c b/engines/posixaio.c index 135d088c..948f8a24 100644 --- a/engines/posixaio.c +++ b/engines/posixaio.c @@ -197,7 +197,8 @@ static void fio_posixaio_cleanup(struct thread_data *td) static int fio_posixaio_init(struct thread_data *td) { - struct posixaio_data *pd = malloc(sizeof(*pd)); + struct posixaio_data *pd; + pd = malloc(sizeof(*pd)); memset(pd, 0, sizeof(*pd)); pd->aio_events = malloc(td->o.iodepth * sizeof(struct io_u *)); diff --git a/engines/solarisaio.c b/engines/solarisaio.c index 59bae713..366b72f4 100644 --- a/engines/solarisaio.c +++ b/engines/solarisaio.c @@ -186,7 +186,8 @@ static void fio_solarisaio_init_sigio(void) static int fio_solarisaio_init(struct thread_data *td) { unsigned int max_depth; - struct solarisaio_data *sd = malloc(sizeof(*sd)); + struct solarisaio_data *sd; + sd = malloc(sizeof(*sd)); memset(sd, 0, sizeof(*sd)); max_depth = td->o.iodepth; -- 2.25.1