From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([140.186.70.92]:34720) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QMQCA-0002eY-5y for qemu-devel@nongnu.org; Tue, 17 May 2011 15:44:43 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QMQC9-000282-7N for qemu-devel@nongnu.org; Tue, 17 May 2011 15:44:42 -0400 Received: from e39.co.us.ibm.com ([32.97.110.160]:33596) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QMQC8-00027j-Mp for qemu-devel@nongnu.org; Tue, 17 May 2011 15:44:41 -0400 Received: from d03relay02.boulder.ibm.com (d03relay02.boulder.ibm.com [9.17.195.227]) by e39.co.us.ibm.com (8.14.4/8.13.1) with ESMTP id p4HJUhRb009226 for ; Tue, 17 May 2011 13:30:43 -0600 Received: from d03av02.boulder.ibm.com (d03av02.boulder.ibm.com [9.17.195.168]) by d03relay02.boulder.ibm.com (8.13.8/8.13.8/NCO v9.1) with ESMTP id p4HJiX4I159584 for ; Tue, 17 May 2011 13:44:33 -0600 Received: from d03av02.boulder.ibm.com (loopback [127.0.0.1]) by d03av02.boulder.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id p4HDhicx017430 for ; Tue, 17 May 2011 07:43:45 -0600 From: "Venkateswararao Jujjuri (JV)" Date: Tue, 17 May 2011 12:43:30 -0700 Message-Id: <1305661431-21289-5-git-send-email-jvrao@linux.vnet.ibm.com> In-Reply-To: <1305661431-21289-1-git-send-email-jvrao@linux.vnet.ibm.com> References: <1305661431-21289-1-git-send-email-jvrao@linux.vnet.ibm.com> Subject: [Qemu-devel] [V2 04/25] [virtio-9p] clean up v9fs_readlink. List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: aliguori@us.ibm.com, "Venkateswararao Jujjuri (JV)" , stefanha@linux.vnet.ibm.com Rearrange the code so that we can avoid V9fsReadLinkState. Signed-off-by: Venkateswararao Jujjuri " --- hw/9pfs/virtio-9p.c | 25 ++++++++++--------------- hw/9pfs/virtio-9p.h | 7 ------- 2 files changed, 10 insertions(+), 22 deletions(-) diff --git a/hw/9pfs/virtio-9p.c b/hw/9pfs/virtio-9p.c index 06da2c9..e0e7eed 100644 --- a/hw/9pfs/virtio-9p.c +++ b/hw/9pfs/virtio-9p.c @@ -3586,35 +3586,30 @@ out: static void v9fs_readlink(void *opaque) { V9fsPDU *pdu = opaque; - V9fsState *s = pdu->s; + size_t offset = 7; + V9fsString target; int32_t fid; - V9fsReadLinkState *vs; int err = 0; V9fsFidState *fidp; - vs = qemu_malloc(sizeof(*vs)); - vs->pdu = pdu; - vs->offset = 7; - - pdu_unmarshal(vs->pdu, vs->offset, "d", &fid); - fidp = lookup_fid(s, fid); + pdu_unmarshal(pdu, offset, "d", &fid); + fidp = lookup_fid(pdu->s, fid); if (fidp == NULL) { err = -ENOENT; goto out; } - v9fs_string_init(&vs->target); - err = v9fs_do_readlink(s, &fidp->path, &vs->target); + v9fs_string_init(&target); + err = v9fs_do_readlink(pdu->s, &fidp->path, &target); if (err < 0) { err = -errno; goto out; } - vs->offset += pdu_marshal(vs->pdu, vs->offset, "s", &vs->target); - err = vs->offset; - v9fs_string_free(&vs->target); + offset += pdu_marshal(pdu, offset, "s", &target); + err = offset; + v9fs_string_free(&target); out: - complete_pdu(s, vs->pdu, err); - qemu_free(vs); + complete_pdu(pdu->s, pdu, err); } static CoroutineEntry *pdu_co_handlers[] = { diff --git a/hw/9pfs/virtio-9p.h b/hw/9pfs/virtio-9p.h index fb1e465..e95b63d 100644 --- a/hw/9pfs/virtio-9p.h +++ b/hw/9pfs/virtio-9p.h @@ -495,13 +495,6 @@ typedef struct V9fsGetlockState V9fsGetlock *glock; } V9fsGetlockState; -typedef struct V9fsReadLinkState -{ - V9fsPDU *pdu; - size_t offset; - V9fsString target; -} V9fsReadLinkState; - size_t pdu_packunpack(void *addr, struct iovec *sg, int sg_count, size_t offset, size_t size, int pack); -- 1.7.1