From patchwork Thu May 12 20:57:26 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: jvrao X-Patchwork-Id: 95362 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [140.186.70.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id D36E1B6F0A for ; Fri, 13 May 2011 06:58:48 +1000 (EST) Received: from localhost ([::1]:52865 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QKcy6-0000pm-8y for incoming@patchwork.ozlabs.org; Thu, 12 May 2011 16:58:46 -0400 Received: from eggs.gnu.org ([140.186.70.92]:50418) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QKcxa-0000ki-94 for qemu-devel@nongnu.org; Thu, 12 May 2011 16:58:15 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QKcxZ-0001nZ-8I for qemu-devel@nongnu.org; Thu, 12 May 2011 16:58:14 -0400 Received: from e33.co.us.ibm.com ([32.97.110.151]:42802) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QKcxZ-0001nQ-2Z for qemu-devel@nongnu.org; Thu, 12 May 2011 16:58:13 -0400 Received: from d03relay04.boulder.ibm.com (d03relay04.boulder.ibm.com [9.17.195.106]) by e33.co.us.ibm.com (8.14.4/8.13.1) with ESMTP id p4CKp4Y8014676 for ; Thu, 12 May 2011 14:51:04 -0600 Received: from d03av02.boulder.ibm.com (d03av02.boulder.ibm.com [9.17.195.168]) by d03relay04.boulder.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id p4CKxG6F137222 for ; Thu, 12 May 2011 14:59:17 -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 p4CEvZu8031957 for ; Thu, 12 May 2011 08:57:35 -0600 Received: from oc6675851006.ibm.com (dyn9047029068.beaverton.ibm.com [9.47.29.68]) by d03av02.boulder.ibm.com (8.14.4/8.13.1/NCO v10.0 AVin) with ESMTP id p4CEvUhK031551; Thu, 12 May 2011 08:57:35 -0600 From: "Venkateswararao Jujjuri (JV)" To: qemu-devel@nongnu.org Date: Thu, 12 May 2011 13:57:26 -0700 Message-Id: <1305233867-4367-5-git-send-email-jvrao@linux.vnet.ibm.com> X-Mailer: git-send-email 1.7.1 In-Reply-To: <1305233867-4367-1-git-send-email-jvrao@linux.vnet.ibm.com> References: <1305233867-4367-1-git-send-email-jvrao@linux.vnet.ibm.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6, seldom 2.4 (older, 4) X-Received-From: 32.97.110.151 Cc: aliguori@us.ibm.com, "Venkateswararao Jujjuri \(JV\)" , stefanha@linux.vnet.ibm.com Subject: [Qemu-devel] [PATCH 04/25] [virtio-9p] clean up v9fs_readlink. X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Rearrange the code so that we can avoid V9fsReadLinkState. Signed-off-by: Venkateswararao Jujjuri " --- hw/9pfs/virtio-9p.c | 26 ++++++++++---------------- hw/9pfs/virtio-9p.h | 7 ------- 2 files changed, 10 insertions(+), 23 deletions(-) diff --git a/hw/9pfs/virtio-9p.c b/hw/9pfs/virtio-9p.c index 0b38868..c4d903a 100644 --- a/hw/9pfs/virtio-9p.c +++ b/hw/9pfs/virtio-9p.c @@ -3640,36 +3640,30 @@ out: static void v9fs_readlink(void *opaque) { V9fsCoPdu *copdu = opaque; - V9fsState *s = copdu->s; - V9fsPDU *pdu = copdu->pdu; + 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(copdu->pdu, offset, "d", &fid); + fidp = lookup_fid(copdu->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(copdu->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(copdu->pdu, offset, "s", &target); + err = offset; + v9fs_string_free(&target); out: - complete_pdu(s, vs->pdu, err); - qemu_free(vs); + complete_pdu(copdu->s, copdu->pdu, err); qemu_free(copdu); } diff --git a/hw/9pfs/virtio-9p.h b/hw/9pfs/virtio-9p.h index 5021da8..bf8f64b 100644 --- a/hw/9pfs/virtio-9p.h +++ b/hw/9pfs/virtio-9p.h @@ -493,13 +493,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);