qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [PATCH v3 05/12] block: simplify bdrv_find_base()


From: Jeff Cody
Subject: [Qemu-devel] [PATCH v3 05/12] block: simplify bdrv_find_base()
Date: Fri, 30 May 2014 13:35:23 -0400

This simplifies the function bdrv_find_base(), while keeping the
same functionality.

Reviewed-by: Eric Blake <address@hidden>
Signed-off-by: Jeff Cody <address@hidden>
---
 block.c | 16 +++++-----------
 1 file changed, 5 insertions(+), 11 deletions(-)

diff --git a/block.c b/block.c
index 7eb3279..96b90d9 100644
--- a/block.c
+++ b/block.c
@@ -4372,20 +4372,14 @@ int bdrv_get_backing_file_depth(BlockDriverState *bs)
     return 1 + bdrv_get_backing_file_depth(bs->backing_hd);
 }
 
+/* Given a BDS, searches for the base layer.  If
+ * base layer cannot be found, returns NULL */
 BlockDriverState *bdrv_find_base(BlockDriverState *bs)
 {
-    BlockDriverState *curr_bs = NULL;
-
-    if (!bs) {
-        return NULL;
+    while (bs && bs->backing_hd) {
+        bs = bs->backing_hd;
     }
-
-    curr_bs = bs;
-
-    while (curr_bs->backing_hd) {
-        curr_bs = curr_bs->backing_hd;
-    }
-    return curr_bs;
+    return bs;
 }
 
 /* Given a BDS, searches for the active layer.  If
-- 
1.8.3.1




reply via email to

[Prev in Thread] Current Thread [Next in Thread]