Re: [PATCH v1 4/6] engines/net: Replace `malloc()`+`memset()` with `calloc()`

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 4/27/22 4:20 AM, Ammar Faizi wrote:
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;

This is also a wrong calloc() placement, will fix that in v2. I will
make sure to self-review carefully before send this time.

  	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



[Index of Archives]     [Linux Kernel]     [Linux SCSI]     [Linux IDE]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux SCSI]

  Powered by Linux