summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorAneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>2011-08-02 11:36:24 +0530
committerAneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>2011-09-22 21:38:52 +0530
commitce421a19612aaf0d25dede4bad3ea205587c9dae (patch)
tree189acd9e1ef801a865db56905213d1c9fa910977
parent532decb715acb2e03bbe373c9bd914a8499896ee (diff)
downloadfocaccia-qemu-ce421a19612aaf0d25dede4bad3ea205587c9dae.tar.gz
focaccia-qemu-ce421a19612aaf0d25dede4bad3ea205587c9dae.zip
hw/9pfs: Avoid unnecessary get_fid in v9fs_clunk
Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
-rw-r--r--hw/9pfs/virtio-9p.c20
1 files changed, 10 insertions, 10 deletions
diff --git a/hw/9pfs/virtio-9p.c b/hw/9pfs/virtio-9p.c
index 2a6895396d..e51df2aa0f 100644
--- a/hw/9pfs/virtio-9p.c
+++ b/hw/9pfs/virtio-9p.c
@@ -417,7 +417,7 @@ static void put_fid(V9fsState *s, V9fsFidState *fidp)
     }
 }
 
-static int clunk_fid(V9fsState *s, int32_t fid)
+static V9fsFidState *clunk_fid(V9fsState *s, int32_t fid)
 {
     V9fsFidState **fidpp, *fidp;
 
@@ -426,14 +426,13 @@ static int clunk_fid(V9fsState *s, int32_t fid)
             break;
         }
     }
-
     if (*fidpp == NULL) {
-        return -ENOENT;
+        return NULL;
     }
     fidp = *fidpp;
     *fidpp = fidp->next;
     fidp->clunked = 1;
-    return 0;
+    return fidp;
 }
 
 void v9fs_reclaim_fd(V9fsState *s)
@@ -1700,17 +1699,18 @@ static void v9fs_clunk(void *opaque)
 
     pdu_unmarshal(pdu, offset, "d", &fid);
 
-    fidp = get_fid(s, fid);
+    fidp = clunk_fid(s, fid);
     if (fidp == NULL) {
         err = -ENOENT;
         goto out_nofid;
     }
-    err = clunk_fid(s, fidp->fid);
-    if (err < 0) {
-        goto out;
-    }
+    /*
+     * Bump the ref so that put_fid will
+     * free the fid.
+     */
+    fidp->ref++;
     err = offset;
-out:
+
     put_fid(s, fidp);
 out_nofid:
     complete_pdu(s, pdu, err);