mirror of
https://github.com/qemu/qemu.git
synced 2024-11-26 04:13:39 +08:00
block: Use blk_next() in block-backend.c
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 <mreitz@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
This commit is contained in:
parent
da27a00e27
commit
74d1b8fc27
@ -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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user