diff mbox

[v3,02/14] block: Use blk_next() where appropriate

Message ID 1455646106-2047-3-git-send-email-mreitz@redhat.com (mailing list archive)
State New, archived
Headers show

Commit Message

Max Reitz Feb. 16, 2016, 6:08 p.m. UTC
blk_by_name() and blk_by_legacy_dinfo() are not supposed to iterate over
hidden BlockBackends (that is, BlockBackends that do not have a name).
As of a follow-up patch, blk_backends will actually contain all BBs, not
only non-hidden ones, so use blk_next() instead of iterating over that
list.

Signed-off-by: Max Reitz <mreitz@redhat.com>
---
 block/block-backend.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
diff mbox

Patch

diff --git a/block/block-backend.c b/block/block-backend.c
index ebdf78a..2146268 100644
--- a/block/block-backend.c
+++ b/block/block-backend.c
@@ -269,10 +269,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;
         }
@@ -330,9 +330,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;
         }