From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on gnuweeb.org X-Spam-Level: X-Spam-Status: No, score=-0.8 required=5.0 tests=ALL_TRUSTED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NO_DNS_FOR_FROM,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.6 Received: from integral2.. (unknown [180.246.147.8]) by gnuweeb.org (Postfix) with ESMTPSA id 3AC417E790; Tue, 26 Apr 2022 21:21:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gnuweeb.org; s=default; t=1651008083; bh=pMZIVZau7iMXz/U97e6Tg4Bs5xKTzO08zHXSv9ZLmJ4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=C9dVWLginjP2DLwK+dp7zxCO+9jKC8TN17ykhbJAAfskuwWDA0Oh0L1agdIiXcoiM fPZ0idt0Rp34cua6i49eH9EOt6PRhmxgDnWzcsdk+skt3QLUAbwKFj6dJVbTr3Ybry di839n+O4fjuw8MYPcUBbjzDiUpJpVEukBTqd/lJNeSo2jNe+OJa6LMbp40gF6JkdD /zd1oUgD3uQxn2NRGV/1GAOSSjmdL7SdjNt/9wwU6019en1YBwL4UyUcq0P8Bi8FcZ S9rRyTTiwrekuEP648ms58Z7NobcG6K3xq/UpwPXxLnxtakNbjEMXToKWEI5pqF+QD /xYkENwkf7qtw== From: Ammar Faizi To: Jens Axboe Cc: fio Mailing List , GNU/Weeb Mailing List , Ammar Faizi Subject: [PATCH v1 4/6] engines/net: Replace `malloc()`+`memset()` with `calloc()` Date: Wed, 27 Apr 2022 04:20:42 +0700 Message-Id: <20220426212044.78898-5-ammarfaizi2@gnuweeb.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20220426212044.78898-1-ammarfaizi2@gnuweeb.org> References: <20220426212044.78898-1-ammarfaizi2@gnuweeb.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: From: Ammar Faizi Replace `malloc()` + `memset()` with `calloc()`. While in there, handle the ENOMEM case of it. Signed-off-by: Ammar Faizi --- engines/net.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/engines/net.c b/engines/net.c index c6cec584..8a898748 100644 --- a/engines/net.c +++ b/engines/net.c @@ -1363,6 +1363,10 @@ static int fio_netio_setup(struct thread_data *td) { struct netio_data *nd; + nd = calloc(1, sizeof(*nd)); + if (!nd) + return 1; + if (!td->files_index) { add_file(td, td->o.filename ?: "net", 0, 0); td->o.nr_files = td->o.nr_files ?: 1; @@ -1370,9 +1374,6 @@ static int fio_netio_setup(struct thread_data *td) } if (!td->io_ops_data) { - nd = malloc(sizeof(*nd)); - - memset(nd, 0, sizeof(*nd)); nd->listenfd = -1; nd->pipes[0] = nd->pipes[1] = -1; td->io_ops_data = nd; @@ -1391,7 +1392,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