From: Vincent Fu Date: Sat, 15 Apr 2023 00:51:44 +0000 (+0000) Subject: engines: separate declaration and assignment X-Git-Tag: fio-3.35~26 X-Git-Url: https://git.kernel.dk/?a=commitdiff_plain;h=a93259c9d05c69d4d32f2d1ce459e6a960077b17;p=fio.git 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 --- 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;