[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 04/29] block: Use blk_next() in block-backend.c
From: |
Kevin Wolf |
Subject: |
[Qemu-devel] [PULL 04/29] block: Use blk_next() in block-backend.c |
Date: |
Thu, 17 Mar 2016 16:56:17 +0100 |
From: Max Reitz <address@hidden>
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 <address@hidden>
Signed-off-by: Kevin Wolf <address@hidden>
---
block/block-backend.c | 12 ++++++------
1 file 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;
}
--
1.8.3.1
- [Qemu-devel] [PULL 00/29] Block patches, Kevin Wolf, 2016/03/17
- [Qemu-devel] [PULL 03/29] monitor: Use BB list for BB name completion, Kevin Wolf, 2016/03/17
- [Qemu-devel] [PULL 01/29] block: Fix qemu_root_bds_opts.head initialisation, Kevin Wolf, 2016/03/17
- [Qemu-devel] [PULL 05/29] block: Add blk_commit_all(), Kevin Wolf, 2016/03/17
- [Qemu-devel] [PULL 02/29] block: Fix memory leak in hmp_drive_add_node(), Kevin Wolf, 2016/03/17
- [Qemu-devel] [PULL 04/29] block: Use blk_next() in block-backend.c,
Kevin Wolf <=
- [Qemu-devel] [PULL 07/29] qapi: Drop QERR_UNKNOWN_BLOCK_FORMAT_FEATURE, Kevin Wolf, 2016/03/17
- [Qemu-devel] [PULL 09/29] blockdev: Rename blk_backends, Kevin Wolf, 2016/03/17
- [Qemu-devel] [PULL 08/29] block: Drop BB name from bad option error, Kevin Wolf, 2016/03/17
- [Qemu-devel] [PULL 06/29] block: Use blk_{commit, flush}_all() consistently, Kevin Wolf, 2016/03/17
- [Qemu-devel] [PULL 10/29] blockdev: Add list of all BlockBackends, Kevin Wolf, 2016/03/17
- [Qemu-devel] [PULL 11/29] blockdev: Separate BB name management, Kevin Wolf, 2016/03/17
- [Qemu-devel] [PULL 16/29] block: Add blk_next_root_bs(), Kevin Wolf, 2016/03/17
- [Qemu-devel] [PULL 13/29] blockdev: Remove blk_hide_on_behalf_of_hmp_drive_del(), Kevin Wolf, 2016/03/17
- [Qemu-devel] [PULL 15/29] block: Add bdrv_next_monitor_owned(), Kevin Wolf, 2016/03/17
- [Qemu-devel] [PULL 17/29] block: Rewrite bdrv_next(), Kevin Wolf, 2016/03/17