From nobody Wed May 1 13:21:52 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1486474156519619.699588436957; Tue, 7 Feb 2017 05:29:16 -0800 (PST) Received: from localhost ([::1]:54027 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cb5pZ-0006Rr-2J for importer@patchew.org; Tue, 07 Feb 2017 08:29:13 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53140) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cb5nx-0005XT-9p for qemu-devel@nongnu.org; Tue, 07 Feb 2017 08:27:34 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cb5nw-0007ol-I4 for qemu-devel@nongnu.org; Tue, 07 Feb 2017 08:27:33 -0500 Received: from mx1.redhat.com ([209.132.183.28]:49906) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cb5nu-0007mn-LL; Tue, 07 Feb 2017 08:27:30 -0500 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id D369B7E9CA; Tue, 7 Feb 2017 13:27:30 +0000 (UTC) Received: from lemon.redhat.com (ovpn-8-41.pek2.redhat.com [10.72.8.41]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v17DRPDB016447; Tue, 7 Feb 2017 08:27:28 -0500 From: Fam Zheng To: qemu-devel@nongnu.org Date: Tue, 7 Feb 2017 21:27:22 +0800 Message-Id: <20170207132723.13934-2-famz@redhat.com> In-Reply-To: <20170207132723.13934-1-famz@redhat.com> References: <20170207132723.13934-1-famz@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Tue, 07 Feb 2017 13:27:30 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH 1/2] virtio-blk: Remove useless condition around g_free() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Laszlo Ersek , qemu-block@nongnu.org, Stefan Hajnoczi Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Laszlo spotted and studied this wasteful "if". He pointed out: The original virtio_blk_free_request needed an "if" as it accesses one field, since 671ec3f05655 ("virtio-blk: Convert VirtIOBlockReq.elem to pointer", 2014-06-11); later on in f897bf751fbd ("virtio-blk: embed VirtQueueElement in VirtIOBlockReq", 2014-07-09) the field became embedded, so the "if" became unnecessary (at which point we were using g_slice_free(), but it is the same. Now drop it. Reported-by: Laszlo Ersek Signed-off-by: Fam Zheng Reviewed-by: Laszlo Ersek Reviewed-by: Stefan Hajnoczi --- hw/block/virtio-blk.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/hw/block/virtio-blk.c b/hw/block/virtio-blk.c index 702eda8..2858c31 100644 --- a/hw/block/virtio-blk.c +++ b/hw/block/virtio-blk.c @@ -42,9 +42,7 @@ static void virtio_blk_init_request(VirtIOBlock *s, VirtQ= ueue *vq, =20 static void virtio_blk_free_request(VirtIOBlockReq *req) { - if (req) { - g_free(req); - } + g_free(req); } =20 static void virtio_blk_req_complete(VirtIOBlockReq *req, unsigned char sta= tus) --=20 2.9.3 From nobody Wed May 1 13:21:52 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1486474154857870.1203995578137; Tue, 7 Feb 2017 05:29:14 -0800 (PST) Received: from localhost ([::1]:54029 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cb5pZ-0006S2-F4 for importer@patchew.org; Tue, 07 Feb 2017 08:29:13 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53183) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cb5nz-0005ZR-GE for qemu-devel@nongnu.org; Tue, 07 Feb 2017 08:27:36 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cb5ny-0007qw-NS for qemu-devel@nongnu.org; Tue, 07 Feb 2017 08:27:35 -0500 Received: from mx1.redhat.com ([209.132.183.28]:34288) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cb5nw-0007oU-Kp; Tue, 07 Feb 2017 08:27:32 -0500 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id D50EA81243; Tue, 7 Feb 2017 13:27:32 +0000 (UTC) Received: from lemon.redhat.com (ovpn-8-41.pek2.redhat.com [10.72.8.41]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v17DRPDC016447; Tue, 7 Feb 2017 08:27:31 -0500 From: Fam Zheng To: qemu-devel@nongnu.org Date: Tue, 7 Feb 2017 21:27:23 +0800 Message-Id: <20170207132723.13934-3-famz@redhat.com> In-Reply-To: <20170207132723.13934-1-famz@redhat.com> References: <20170207132723.13934-1-famz@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Tue, 07 Feb 2017 13:27:32 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH 2/2] virtio-blk: Inline request init, complete and free functions X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Laszlo Ersek , qemu-block@nongnu.org, Stefan Hajnoczi Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" These are used in each request handling, inline them. Signed-off-by: Fam Zheng --- hw/block/virtio-blk.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/hw/block/virtio-blk.c b/hw/block/virtio-blk.c index 2858c31..1da9570 100644 --- a/hw/block/virtio-blk.c +++ b/hw/block/virtio-blk.c @@ -29,8 +29,8 @@ #include "hw/virtio/virtio-bus.h" #include "hw/virtio/virtio-access.h" =20 -static void virtio_blk_init_request(VirtIOBlock *s, VirtQueue *vq, - VirtIOBlockReq *req) +static inline void virtio_blk_init_request(VirtIOBlock *s, VirtQueue *vq, + VirtIOBlockReq *req) { req->dev =3D s; req->vq =3D vq; @@ -40,12 +40,13 @@ static void virtio_blk_init_request(VirtIOBlock *s, Vir= tQueue *vq, req->mr_next =3D NULL; } =20 -static void virtio_blk_free_request(VirtIOBlockReq *req) +static inline void virtio_blk_free_request(VirtIOBlockReq *req) { g_free(req); } =20 -static void virtio_blk_req_complete(VirtIOBlockReq *req, unsigned char sta= tus) +static inline void virtio_blk_req_complete(VirtIOBlockReq *req, + unsigned char status) { VirtIOBlock *s =3D req->dev; VirtIODevice *vdev =3D VIRTIO_DEVICE(s); --=20 2.9.3