From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([140.186.70.92]:50702) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QKcxu-0001MG-BK for qemu-devel@nongnu.org; Thu, 12 May 2011 16:58:35 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QKcxr-000217-PN for qemu-devel@nongnu.org; Thu, 12 May 2011 16:58:34 -0400 Received: from e37.co.us.ibm.com ([32.97.110.158]:56477) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QKcxr-00020l-JU for qemu-devel@nongnu.org; Thu, 12 May 2011 16:58:31 -0400 Received: from d03relay02.boulder.ibm.com (d03relay02.boulder.ibm.com [9.17.195.227]) by e37.co.us.ibm.com (8.14.4/8.13.1) with ESMTP id p4CKtYTm006222 for ; Thu, 12 May 2011 14:55:34 -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 p4CKwOeH153308 for ; Thu, 12 May 2011 14:58:24 -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 p4CEvuMP001215 for ; Thu, 12 May 2011 08:57:56 -0600 From: "Venkateswararao Jujjuri (JV)" Date: Thu, 12 May 2011 13:57:46 -0700 Message-Id: <1305233867-4367-25-git-send-email-jvrao@linux.vnet.ibm.com> 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> Subject: [Qemu-devel] [PATCH 24/25] [virtio-9p] clean up v9fs_remove. 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 V9fsRemoveState and additional malloc()s. Signed-off-by: Venkateswararao Jujjuri " --- hw/9pfs/virtio-9p.c | 24 +++++++++--------------- hw/9pfs/virtio-9p.h | 6 ------ 2 files changed, 9 insertions(+), 21 deletions(-) diff --git a/hw/9pfs/virtio-9p.c b/hw/9pfs/virtio-9p.c index dcce864..114162c 100644 --- a/hw/9pfs/virtio-9p.c +++ b/hw/9pfs/virtio-9p.c @@ -2615,35 +2615,29 @@ out: static void v9fs_remove(void *opaque) { V9fsCoPdu *copdu = opaque; - V9fsState *s = copdu->s; - V9fsPDU *pdu = copdu->pdu; int32_t fid; - V9fsRemoveState *vs; int err = 0; + size_t offset = 7; + V9fsFidState *fidp; - vs = qemu_malloc(sizeof(*vs)); - vs->pdu = pdu; - vs->offset = 7; - - pdu_unmarshal(vs->pdu, vs->offset, "d", &fid); + pdu_unmarshal(copdu->pdu, offset, "d", &fid); - vs->fidp = lookup_fid(s, fid); - if (vs->fidp == NULL) { + fidp = lookup_fid(copdu->s, fid); + if (fidp == NULL) { err = -EINVAL; goto out; } - err = v9fs_do_remove(s, &vs->fidp->path); + err = v9fs_do_remove(copdu->s, &fidp->path); if (err < 0) { err = -errno; } else { - err = vs->offset; + err = offset; } /* For TREMOVE we need to clunk the fid even on failed remove */ - free_fid(s, vs->fidp->fid); + free_fid(copdu->s, fidp->fid); out: - complete_pdu(s, 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 596d35b..04b2a19 100644 --- a/hw/9pfs/virtio-9p.h +++ b/hw/9pfs/virtio-9p.h @@ -331,12 +331,6 @@ typedef struct V9fsWriteState { int cnt; } V9fsWriteState; -typedef struct V9fsRemoveState { - V9fsPDU *pdu; - size_t offset; - V9fsFidState *fidp; -} V9fsRemoveState; - typedef struct V9fsWstatState { V9fsPDU *pdu; -- 1.7.1