From nobody Mon May 12 17:57:23 2025
Delivered-To: importer@patchew.org
Authentication-Results: mx.zohomail.com;
	dkim=pass;
	spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as
 permitted sender)
  smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org
ARC-Seal: i=1; a=rsa-sha256; t=1734553362; cv=none;
	d=zohomail.com; s=zohoarc;
	b=D1u9ZXfngXUstx9Hq1G5xntjiAMLZ+GqbvjB9MqglByeLdTGSFca8LNuYAzcIslR7WcX3FAIqNl5A7aEpkaeKOs0gMix7Tmf/7WgQrkGw5GXIYmuOpABU86Jl74U/M5OMF5ML8vVTOp7yjt0A1VuLJdjRE75WMj0z+xdUzwCng4=
ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com;
 s=zohoarc;
	t=1734553362;
 h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To;
	bh=Fwbq5xyzI6PRmIt0HAom/UBI62Wcs3ps5RdZPJLyvZU=;
	b=f/5idaRFPEl4P5dLBsbBJBurrN3RPyJZDZsK7mau3DAnZAcg9+5T0oeanbv8BztG0AuZC5+N19Y82KTGAnk71VSD9h+jotl8/yfLgVbXViZph+uQYbA2xnttXLsEbGz3MAPDEWgO5LqzsYZ/hins4dQ6PkOBxTcR/3EdEhx09qY=
ARC-Authentication-Results: i=1; mx.zohomail.com;
	dkim=pass;
	spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as
 permitted sender)
  smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org
Return-Path: <qemu-devel-bounces+importer=patchew.org@nongnu.org>
Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by
 mx.zohomail.com
	with SMTPS id 1734553362224518.1102752286506;
 Wed, 18 Dec 2024 12:22:42 -0800 (PST)
Received: from localhost ([::1] helo=lists1p.gnu.org)
	by lists.gnu.org with esmtp (Exim 4.90_1)
	(envelope-from <qemu-devel-bounces@nongnu.org>)
	id 1tO0Xs-0001ez-L5; Wed, 18 Dec 2024 15:21:24 -0500
Received: from eggs.gnu.org ([2001:470:142:3::10])
 by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <phil@philjordan.eu>)
 id 1tO0Xn-0001a0-Tw
 for qemu-devel@nongnu.org; Wed, 18 Dec 2024 15:21:19 -0500
Received: from mail-wr1-x42a.google.com ([2a00:1450:4864:20::42a])
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128)
 (Exim 4.90_1) (envelope-from <phil@philjordan.eu>)
 id 1tO0Xl-0000OY-Ce
 for qemu-devel@nongnu.org; Wed, 18 Dec 2024 15:21:19 -0500
Received: by mail-wr1-x42a.google.com with SMTP id
 ffacd0b85a97d-3862b364538so44818f8f.1
 for <qemu-devel@nongnu.org>; Wed, 18 Dec 2024 12:21:17 -0800 (PST)
Received: from localhost.localdomain (h082218084190.host.wavenet.at.
 [82.218.84.190]) by smtp.gmail.com with ESMTPSA id
 ffacd0b85a97d-388c80120c7sm14842267f8f.13.2024.12.18.12.21.14
 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256);
 Wed, 18 Dec 2024 12:21:15 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=philjordan-eu.20230601.gappssmtp.com; s=20230601; t=1734553276;
 x=1735158076;
 darn=nongnu.org;
 h=content-transfer-encoding:mime-version:references:in-reply-to
 :message-id:date:subject:cc:to:from:from:to:cc:subject:date
 :message-id:reply-to;
 bh=Fwbq5xyzI6PRmIt0HAom/UBI62Wcs3ps5RdZPJLyvZU=;
 b=I5jj8+5SeVRAuE/BpxVq9jqUJcEL+FcjlOh/rv9gkfbA7hmSWfM2UFzT8XrJIPwfDX
 4TeVg9IN0DRv0YSdHYBHNLE6fe53A/Efb/UGMX5qM+giakVTQrjVZXu7IvPuaFiMq30r
 qWRmtNep+gTMr/syB+NgFHlyeo/2dd+CEBTtybYzp3V5D69VlZ/R0gnDO8iuAraIcWIe
 T1v2KiFe6nPZwbbnm0mxs+645U5Ts6U/2/aQS2lSwMf5efMq18ojZodr2ojPORAcRtBH
 JshDNLeWbEQUzhnn7H7e/Hx6LnRL4OjYkEE3Vn9kDZIfZ7PiZ0kuCQZhFUqP/j6mU+hk
 1g6A==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20230601; t=1734553276; x=1735158076;
 h=content-transfer-encoding:mime-version:references:in-reply-to
 :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc
 :subject:date:message-id:reply-to;
 bh=Fwbq5xyzI6PRmIt0HAom/UBI62Wcs3ps5RdZPJLyvZU=;
 b=mCuR1Di3k9q2BRljaqIsD9dPBQuLjXT8/TSsVovmz3zbzo9cs2hP1fEBu8zuU3L8lT
 dC8PPQVsd5FasejH0/aTALNebGY4e8RJ8dpaQSSGmODG/sz0MFP8W8ufGInmG/FtQqTW
 ynAEdUUFC3+t9xdgnHwzEUaK5cHnhyTDzH7rPoJlbImEuYvep/S/ny+P51rLcJSxQ6mj
 900kVTbtxI+jAPn1+e3YscaAyHRTAUQCSEDSjFt1b2zt9LIWIIcFPA/nU9bzz0Y+z8x3
 MCMiUQlmAp5xlzcphpujoL9RdT2Kwdxli6RUkKAoeYjBYPy2aCZhTJEAi/qoedP6kL8M
 2FsQ==
X-Gm-Message-State: AOJu0YynkEYjLqMIbtOFA1266qe3JzQVwsDgYwW0svYefSW2/M9P/dMh
 k7OLyyxcTFCWvptitVfn3UxoGdr14CYFIxOVJ8AEPyOdutdsRQH4eWQqc9PbUPF/RkaeqQ/mBZD
 8VQ==
X-Gm-Gg: ASbGncuXKhI8om1W8QE4o8TJ9+IHMeniYKF8d/VHgpN6eG9KaMly2BMzJdgz4gIu5Gn
 TOV2as28wnx4Qf2MJEF7nekDELDZsgSCgLypAZiDcuD8vWUFYPtUGawxkoW7QmTodQCnijsZfvz
 +UpB3Ty9nQxu54OE89cTyy3kmG2s0e45oKpnuaMCo6IyIK1lC6OfzxOP4Q/uKl4noElIeX1S9iO
 DHvDfIJf+3sHCkEuBZj9rkWn1VktJtdagPzoVPP4ADLovLg9p367WcQqTpMaApXDrtVpRFrheA6
 pVkeh4f4ML8yxhKIpXTke5OlIOuWUakG
X-Google-Smtp-Source: 
 AGHT+IFsFvPLqbtOH1rYq6wAPoYXwikMb5dOUpdLGuPvgkPlDdAjsmbLGt7z4V0nXJqam3/P0Erogw==
X-Received: by 2002:a05:6000:2c8:b0:385:e8e7:d09a with SMTP id
 ffacd0b85a97d-38a1a1fa088mr614933f8f.2.1734553275835;
 Wed, 18 Dec 2024 12:21:15 -0800 (PST)
From: Phil Dennis-Jordan <phil@philjordan.eu>
To: qemu-devel@nongnu.org
Cc: agraf@csgraf.de, phil@philjordan.eu, peter.maydell@linaro.org,
 pbonzini@redhat.com, rad@semihalf.com, quic_llindhol@quicinc.com,
 stefanha@redhat.com, mst@redhat.com, slp@redhat.com,
 richard.henderson@linaro.org, eduardo@habkost.net,
 marcel.apfelbaum@gmail.com, gaosong@loongson.cn, jiaxun.yang@flygoat.com,
 chenhuacai@kernel.org, kwolf@redhat.com, hreitz@redhat.com,
 philmd@linaro.org, shorne@gmail.com, palmer@dabbelt.com,
 alistair.francis@wdc.com, bmeng.cn@gmail.com, liwei1518@gmail.com,
 dbarboza@ventanamicro.com, zhiwei_liu@linux.alibaba.com,
 jcmvbkbc@gmail.com, marcandre.lureau@redhat.com, berrange@redhat.com,
 akihiko.odaki@daynix.com, qemu-arm@nongnu.org, qemu-block@nongnu.org,
 qemu-riscv@nongnu.org, balaton@eik.bme.hu
Subject: [PATCH v15 14/15] hw/block/virtio-blk: Replaces request free function
 with g_free
Date: Wed, 18 Dec 2024 21:20:35 +0100
Message-Id: <20241218202036.80064-15-phil@philjordan.eu>
X-Mailer: git-send-email 2.39.5 (Apple Git-154)
In-Reply-To: <20241218202036.80064-1-phil@philjordan.eu>
References: <20241218202036.80064-1-phil@philjordan.eu>
MIME-Version: 1.0
Content-Transfer-Encoding: quoted-printable
Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17
 as permitted sender) client-ip=209.51.188.17;
 envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org;
 helo=lists.gnu.org;
Received-SPF: neutral client-ip=2a00:1450:4864:20::42a;
 envelope-from=phil@philjordan.eu; helo=mail-wr1-x42a.google.com
X-Spam_score_int: -10
X-Spam_score: -1.1
X-Spam_bar: -
X-Spam_report: (-1.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1,
 DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001,
 SPF_NEUTRAL=0.779 autolearn=no autolearn_force=no
X-Spam_action: no action
X-BeenThere: qemu-devel@nongnu.org
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: <qemu-devel.nongnu.org>
List-Unsubscribe: <https://lists.nongnu.org/mailman/options/qemu-devel>,
 <mailto:qemu-devel-request@nongnu.org?subject=unsubscribe>
List-Archive: <https://lists.nongnu.org/archive/html/qemu-devel>
List-Post: <mailto:qemu-devel@nongnu.org>
List-Help: <mailto:qemu-devel-request@nongnu.org?subject=help>
List-Subscribe: <https://lists.nongnu.org/mailman/listinfo/qemu-devel>,
 <mailto:qemu-devel-request@nongnu.org?subject=subscribe>
Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org
Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org
X-ZohoMail-DKIM: pass (identity @philjordan-eu.20230601.gappssmtp.com)
X-ZM-MESSAGEID: 1734553365079116600
Content-Type: text/plain; charset="utf-8"

The virtio_blk_free_request() function has been a 1-liner forwarding
to g_free() for a while now. We may as well call g_free on the request
pointer directly.

Signed-off-by: Phil Dennis-Jordan <phil@philjordan.eu>
Reviewed-by: Akihiko Odaki <akihiko.odaki@daynix.com>
Tested-by: Akihiko Odaki <akihiko.odaki@daynix.com>
---
 hw/block/virtio-blk.c          | 43 +++++++++++++++-------------------
 hw/vmapple/virtio-blk.c        |  2 +-
 include/hw/virtio/virtio-blk.h |  1 -
 3 files changed, 20 insertions(+), 26 deletions(-)

diff --git a/hw/block/virtio-blk.c b/hw/block/virtio-blk.c
index 89a5697cf9b..1ff1a59b784 100644
--- a/hw/block/virtio-blk.c
+++ b/hw/block/virtio-blk.c
@@ -50,11 +50,6 @@ static void virtio_blk_init_request(VirtIOBlock *s, Virt=
Queue *vq,
     req->mr_next =3D NULL;
 }
=20
-void virtio_blk_free_request(VirtIOBlockReq *req)
-{
-    g_free(req);
-}
-
 void virtio_blk_req_complete(VirtIOBlockReq *req, unsigned char status)
 {
     VirtIOBlock *s =3D req->dev;
@@ -93,7 +88,7 @@ static int virtio_blk_handle_rw_error(VirtIOBlockReq *req=
, int error,
         if (acct_failed) {
             block_acct_failed(blk_get_stats(s->blk), &req->acct);
         }
-        virtio_blk_free_request(req);
+        g_free(req);
     }
=20
     blk_error_action(s->blk, action, is_read, error);
@@ -136,7 +131,7 @@ static void virtio_blk_rw_complete(void *opaque, int re=
t)
=20
         virtio_blk_req_complete(req, VIRTIO_BLK_S_OK);
         block_acct_done(blk_get_stats(s->blk), &req->acct);
-        virtio_blk_free_request(req);
+        g_free(req);
     }
 }
=20
@@ -151,7 +146,7 @@ static void virtio_blk_flush_complete(void *opaque, int=
 ret)
=20
     virtio_blk_req_complete(req, VIRTIO_BLK_S_OK);
     block_acct_done(blk_get_stats(s->blk), &req->acct);
-    virtio_blk_free_request(req);
+    g_free(req);
 }
=20
 static void virtio_blk_discard_write_zeroes_complete(void *opaque, int ret)
@@ -169,7 +164,7 @@ static void virtio_blk_discard_write_zeroes_complete(vo=
id *opaque, int ret)
     if (is_write_zeroes) {
         block_acct_done(blk_get_stats(s->blk), &req->acct);
     }
-    virtio_blk_free_request(req);
+    g_free(req);
 }
=20
 static VirtIOBlockReq *virtio_blk_get_request(VirtIOBlock *s, VirtQueue *v=
q)
@@ -214,7 +209,7 @@ static void virtio_blk_handle_scsi(VirtIOBlockReq *req)
=20
 fail:
     virtio_blk_req_complete(req, status);
-    virtio_blk_free_request(req);
+    g_free(req);
 }
=20
 static inline void submit_requests(VirtIOBlock *s, MultiReqBuffer *mrb,
@@ -612,7 +607,7 @@ static void virtio_blk_zone_report_complete(void *opaqu=
e, int ret)
=20
 out:
     virtio_blk_req_complete(req, err_status);
-    virtio_blk_free_request(req);
+    g_free(req);
     g_free(data->zone_report_data.zones);
     g_free(data);
 }
@@ -661,7 +656,7 @@ static void virtio_blk_handle_zone_report(VirtIOBlockRe=
q *req,
     return;
 out:
     virtio_blk_req_complete(req, err_status);
-    virtio_blk_free_request(req);
+    g_free(req);
 }
=20
 static void virtio_blk_zone_mgmt_complete(void *opaque, int ret)
@@ -677,7 +672,7 @@ static void virtio_blk_zone_mgmt_complete(void *opaque,=
 int ret)
     }
=20
     virtio_blk_req_complete(req, err_status);
-    virtio_blk_free_request(req);
+    g_free(req);
 }
=20
 static int virtio_blk_handle_zone_mgmt(VirtIOBlockReq *req, BlockZoneOp op)
@@ -719,7 +714,7 @@ static int virtio_blk_handle_zone_mgmt(VirtIOBlockReq *=
req, BlockZoneOp op)
     return 0;
 out:
     virtio_blk_req_complete(req, err_status);
-    virtio_blk_free_request(req);
+    g_free(req);
     return err_status;
 }
=20
@@ -750,7 +745,7 @@ static void virtio_blk_zone_append_complete(void *opaqu=
e, int ret)
=20
 out:
     virtio_blk_req_complete(req, err_status);
-    virtio_blk_free_request(req);
+    g_free(req);
     g_free(data);
 }
=20
@@ -788,7 +783,7 @@ static int virtio_blk_handle_zone_append(VirtIOBlockReq=
 *req,
=20
 out:
     virtio_blk_req_complete(req, err_status);
-    virtio_blk_free_request(req);
+    g_free(req);
     return err_status;
 }
=20
@@ -855,7 +850,7 @@ static int virtio_blk_handle_request(VirtIOBlockReq *re=
q, MultiReqBuffer *mrb)
             virtio_blk_req_complete(req, VIRTIO_BLK_S_IOERR);
             block_acct_invalid(blk_get_stats(s->blk),
                                is_write ? BLOCK_ACCT_WRITE : BLOCK_ACCT_RE=
AD);
-            virtio_blk_free_request(req);
+            g_free(req);
             return 0;
         }
=20
@@ -911,7 +906,7 @@ static int virtio_blk_handle_request(VirtIOBlockReq *re=
q, MultiReqBuffer *mrb)
                               VIRTIO_BLK_ID_BYTES));
         iov_from_buf(in_iov, in_num, 0, serial, size);
         virtio_blk_req_complete(req, VIRTIO_BLK_S_OK);
-        virtio_blk_free_request(req);
+        g_free(req);
         break;
     }
     case VIRTIO_BLK_T_ZONE_APPEND & ~VIRTIO_BLK_T_OUT:
@@ -943,7 +938,7 @@ static int virtio_blk_handle_request(VirtIOBlockReq *re=
q, MultiReqBuffer *mrb)
         if (unlikely(!(type & VIRTIO_BLK_T_OUT) ||
                      out_len > sizeof(dwz_hdr))) {
             virtio_blk_req_complete(req, VIRTIO_BLK_S_UNSUPP);
-            virtio_blk_free_request(req);
+            g_free(req);
             return 0;
         }
=20
@@ -960,7 +955,7 @@ static int virtio_blk_handle_request(VirtIOBlockReq *re=
q, MultiReqBuffer *mrb)
                                                             is_write_zeroe=
s);
         if (err_status !=3D VIRTIO_BLK_S_OK) {
             virtio_blk_req_complete(req, err_status);
-            virtio_blk_free_request(req);
+            g_free(req);
         }
=20
         break;
@@ -975,7 +970,7 @@ static int virtio_blk_handle_request(VirtIOBlockReq *re=
q, MultiReqBuffer *mrb)
         if (!vbk->handle_unknown_request ||
             !vbk->handle_unknown_request(req, mrb, type)) {
             virtio_blk_req_complete(req, VIRTIO_BLK_S_UNSUPP);
-            virtio_blk_free_request(req);
+            g_free(req);
         }
     }
     }
@@ -998,7 +993,7 @@ void virtio_blk_handle_vq(VirtIOBlock *s, VirtQueue *vq)
         while ((req =3D virtio_blk_get_request(s, vq))) {
             if (virtio_blk_handle_request(req, &mrb)) {
                 virtqueue_detach_element(req->vq, &req->elem, 0);
-                virtio_blk_free_request(req);
+                g_free(req);
                 break;
             }
         }
@@ -1048,7 +1043,7 @@ static void virtio_blk_dma_restart_bh(void *opaque)
             while (req) {
                 next =3D req->next;
                 virtqueue_detach_element(req->vq, &req->elem, 0);
-                virtio_blk_free_request(req);
+                g_free(req);
                 req =3D next;
             }
             break;
@@ -1131,7 +1126,7 @@ static void virtio_blk_reset(VirtIODevice *vdev)
             /* No other threads can access req->vq here */
             virtqueue_detach_element(req->vq, &req->elem, 0);
=20
-            virtio_blk_free_request(req);
+            g_free(req);
         }
     }
=20
diff --git a/hw/vmapple/virtio-blk.c b/hw/vmapple/virtio-blk.c
index d5d6a7b39dd..c8162efac27 100644
--- a/hw/vmapple/virtio-blk.c
+++ b/hw/vmapple/virtio-blk.c
@@ -55,7 +55,7 @@ static bool vmapple_virtio_blk_handle_unknown_request(Vir=
tIOBlockReq *req,
         qemu_log_mask(LOG_UNIMP, "%s: Barrier requests are currently no-op=
s\n",
                       __func__);
         virtio_blk_req_complete(req, VIRTIO_BLK_S_OK);
-        virtio_blk_free_request(req);
+        g_free(req);
         return true;
     default:
         return false;
diff --git a/include/hw/virtio/virtio-blk.h b/include/hw/virtio/virtio-blk.h
index 28d5046ea6c..dcb2c89aed5 100644
--- a/include/hw/virtio/virtio-blk.h
+++ b/include/hw/virtio/virtio-blk.h
@@ -109,7 +109,6 @@ typedef struct VirtIOBlkClass {
 } VirtIOBlkClass;
=20
 void virtio_blk_handle_vq(VirtIOBlock *s, VirtQueue *vq);
-void virtio_blk_free_request(VirtIOBlockReq *req);
 void virtio_blk_req_complete(VirtIOBlockReq *req, unsigned char status);
=20
 #endif
--=20
2.39.5 (Apple Git-154)