engines: separate declaration and assignment
authorVincent Fu <vincent.fu@samsung.com>
Sat, 15 Apr 2023 00:51:44 +0000 (00:51 +0000)
committerVincent Fu <vincent.fu@samsung.com>
Thu, 20 Apr 2023 13:43:30 +0000 (09:43 -0400)
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 <vincent.fu@samsung.com>
engines/null.c
engines/posixaio.c
engines/solarisaio.c

index 68c9969c4f03a646e81b699efec029a2226ad484..c17697bff59642012faed0270d0efa25a9114877 100644 (file)
@@ -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));
 
index 135d088c7a029ef1ac3e55192d724d147875bbe7..948f8a2483210ac368c53595bd3a401e6f9bd831 100644 (file)
@@ -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 *));
index 59bae71379a34cd5324243aced85e8af7328996b..366b72f46de714f410b1a0fd17fedde45e73257c 100644 (file)
@@ -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;