fio: replace malloc+memset with calloc
authorVincent Fu <vincent.fu@samsung.com>
Sat, 15 Apr 2023 00:52:47 +0000 (00:52 +0000)
committerVincent Fu <vincent.fu@samsung.com>
Thu, 20 Apr 2023 13:43:30 +0000 (09:43 -0400)
commit223decddb199e9af0c5cd357d28c43e48dbcea7a
tree6a54c6e9067afce80cfc4e881f0c2a852f8301e2
parenta93259c9d05c69d4d32f2d1ce459e6a960077b17
fio: replace malloc+memset with calloc

Clean up the code base by replacing malloc+memset with calloc. This
patch was generated from the Coccinelle script below.

The script below is inspired by similar scripts used elsewhere:
https://lore.kernel.org/linux-btrfs/cover.1443546000.git.silvio.fricke@gmail.com/
https://github.com/coccinelle/coccinellery/blob/master/simple_kzalloc/simple_kzalloc1.cocci

@@
expression x,y;
statement s;
type T;
@@

-x = malloc(y * sizeof(T));
+x = calloc(y, sizeof(T));
(
if (!x) s
|
if (x == NULL) s
|
)
-memset(x, 0, y * sizeof(T));

@@
expression x,y,z;
statement s;
@@

-x = malloc(y * sizeof(z));
+x = calloc(y, sizeof(z));
(
if (!x) s
|
if (x == NULL) s
|
)
-memset(x, 0, y * sizeof(z));

@@
expression e,x;
statement s;
@@

-x = malloc(e);
+x = calloc(1, e);
(
if (!x) s
|
if (x == NULL) s
|
)
-memset(x, 0, e);

Signed-off-by: Vincent Fu <vincent.fu@samsung.com>
20 files changed:
client.c
engines/e4defrag.c
engines/io_uring.c
engines/libhdfs.c
engines/libiscsi.c
engines/net.c
engines/nfs.c
engines/null.c
engines/posixaio.c
engines/rdma.c
engines/solarisaio.c
engines/sync.c
eta.c
filesetup.c
gfio.c
graph.c
init.c
t/io_uring.c
t/lfsr-test.c
verify.c