[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-block] [PATCH v3 02/14] block: Use blk_next() where appropriate
From: |
Max Reitz |
Subject: |
[Qemu-block] [PATCH v3 02/14] block: Use blk_next() where appropriate |
Date: |
Tue, 16 Feb 2016 19:08:14 +0100 |
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 <address@hidden>
---
block/block-backend.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
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;
}
--
2.7.1
- [Qemu-block] [PATCH v3 00/14] blockdev: Further BlockBackend work, Max Reitz, 2016/02/16
- [Qemu-block] [PATCH v3 02/14] block: Use blk_next() where appropriate,
Max Reitz <=
- [Qemu-block] [PATCH v3 01/14] monitor: Use BB list for BB name completion, Max Reitz, 2016/02/16
- [Qemu-block] [PATCH v3 03/14] block: Add blk_all_next(), Max Reitz, 2016/02/16
- [Qemu-block] [PATCH v3 05/14] block: Add blk_commit_all(), Max Reitz, 2016/02/16
- [Qemu-block] [PATCH v3 06/14] block: Use blk_{commit, flush}_all() consistently, Max Reitz, 2016/02/16
- [Qemu-block] [PATCH v3 04/14] block: Add blk_name_taken(), Max Reitz, 2016/02/16
- [Qemu-block] [PATCH v3 08/14] blockdev: Remove blk_hide_on_behalf_of_hmp_drive_del(), Max Reitz, 2016/02/16