Message ID | 04056568e560af9fff466f50e54d866fe2bb2624.1401200582.git.jcody@redhat.com |
---|---|
State | New |
Headers | show |
On 05/27/2014 08:28 AM, Jeff Cody wrote: > This simplifies the function bdrv_find_base(), while keeping the > same functionality. > > Signed-off-by: Jeff Cody <jcody@redhat.com> > --- > block.c | 16 +++++----------- > 1 file changed, 5 insertions(+), 11 deletions(-) Reviewed-by: Eric Blake <eblake@redhat.com> [no coincidence that it is oddly similar to bdrv_find_active in 4/11 :) ]
diff --git a/block.c b/block.c index 577d4f1..cf29494 100644 --- a/block.c +++ b/block.c @@ -4363,20 +4363,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
This simplifies the function bdrv_find_base(), while keeping the same functionality. Signed-off-by: Jeff Cody <jcody@redhat.com> --- block.c | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-)