Replace `malloc()` + `memset()` with `calloc()` to simplify the call. `calloc()` zeroes the allocated memory, so we can avoid `memset()`. Also, handle the `ENOMEM` case. Signed-off-by: Ammar Faizi <ammarfaizi2@xxxxxxxxxxx> --- engines/net.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/engines/net.c b/engines/net.c index c6cec584..24c1463d 100644 --- a/engines/net.c +++ b/engines/net.c @@ -1370,9 +1370,9 @@ static int fio_netio_setup(struct thread_data *td) } if (!td->io_ops_data) { - nd = malloc(sizeof(*nd)); - - memset(nd, 0, sizeof(*nd)); + nd = calloc(1, sizeof(*nd)); + if (!nd) + return 1; nd->listenfd = -1; nd->pipes[0] = nd->pipes[1] = -1; td->io_ops_data = nd; @@ -1391,7 +1391,8 @@ static int fio_netio_setup_splice(struct thread_data *td) { struct netio_data *nd; - fio_netio_setup(td); + if (fio_netio_setup(td)) + return 1; nd = td->io_ops_data; if (nd) { -- Ammar Faizi