diff options
author | Max Reitz <mreitz@redhat.com> | 2016-03-16 19:54:30 +0100 |
---|---|---|
committer | Timothy Pearson <tpearson@raptorengineering.com> | 2019-11-29 19:49:38 -0600 |
commit | 38da0316f87b07be04d90d46800d1e91088c1744 (patch) | |
tree | 2f11d61481aff55864dc6fb9f7e2829cb91e24d0 | |
parent | 0e38d67637c38aa4a19960aed29106c2d18f44b7 (diff) | |
download | hqemu-38da0316f87b07be04d90d46800d1e91088c1744.zip hqemu-38da0316f87b07be04d90d46800d1e91088c1744.tar.gz |
block: Use blk_next() in block-backend.c
Instead of iterating directly through blk_backends, we can use
blk_next() instead. This gives us some abstraction from the list itself
which we can use to rename it, for example.
Signed-off-by: Max Reitz <mreitz@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
-rw-r--r-- | block/block-backend.c | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/block/block-backend.c b/block/block-backend.c index 03e71b4..7a04e10 100644 --- a/block/block-backend.c +++ b/block/block-backend.c @@ -227,9 +227,9 @@ void blk_unref(BlockBackend *blk) void blk_remove_all_bs(void) { - BlockBackend *blk; + BlockBackend *blk = NULL; - QTAILQ_FOREACH(blk, &blk_backends, link) { + while ((blk = blk_next(blk)) != NULL) { AioContext *ctx = blk_get_aio_context(blk); aio_context_acquire(ctx); @@ -271,10 +271,10 @@ const char *blk_name(BlockBackend *blk) */ BlockBackend *blk_by_name(const char *name) { - BlockBackend *blk; + BlockBackend *blk = NULL; assert(name); - QTAILQ_FOREACH(blk, &blk_backends, link) { + while ((blk = blk_next(blk)) != NULL) { if (!strcmp(name, blk->name)) { return blk; } @@ -332,9 +332,9 @@ DriveInfo *blk_set_legacy_dinfo(BlockBackend *blk, DriveInfo *dinfo) */ BlockBackend *blk_by_legacy_dinfo(DriveInfo *dinfo) { - BlockBackend *blk; + BlockBackend *blk = NULL; - QTAILQ_FOREACH(blk, &blk_backends, link) { + while ((blk = blk_next(blk)) != NULL) { if (blk->legacy_dinfo == dinfo) { return blk; } |