Received: from eggs.gnu.org ([2001:4830:134:3::10]:44868) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aVk3C-0007mf-4O for qemu-devel@nongnu.org; Tue, 16 Feb 2016 13:08:39 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aVk3B-0005Rx-1N for qemu-devel@nongnu.org; Tue, 16 Feb 2016 13:08:38 -0500 From: Max Reitz Date: Tue, 16 Feb 2016 19:08:14 +0100 Message-Id: <1455646106-2047-3-git-send-email-mreitz@redhat.com> In-Reply-To: <1455646106-2047-1-git-send-email-mreitz@redhat.com> References: <1455646106-2047-1-git-send-email-mreitz@redhat.com> Subject: [Qemu-devel] [PATCH v3 02/14] block: Use blk_next() where appropriate List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-block@nongnu.org Cc: Kevin Wolf , Markus Armbruster , qemu-devel@nongnu.org, Stefan Hajnoczi , Max Reitz 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 --- 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