@@ -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;
}
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(-)