[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH 1/3] block: consistently use bdrv_is_read_only()
From: |
Kevin Wolf |
Subject: |
Re: [PATCH 1/3] block: consistently use bdrv_is_read_only() |
Date: |
Thu, 27 May 2021 16:48:24 +0200 |
Am 26.05.2021 um 23:15 hat Vladimir Sementsov-Ogievskiy geschrieben:
> It's better to use accessor function instead of bs->read_only directly.
> In some places use bdrv_is_writable() instead of
> checking both BDRV_O_RDWR set and BDRV_O_INACTIVE not set.
>
> In bdrv_open_common() it's a bit strange to add one more variable, but
> we are going to drop bs->read_only in the next patch, so new ro local
> variable substitutes it here.
>
> Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
> diff --git a/block/qcow2.c b/block/qcow2.c
> index 39b91ef940..d39d9f4e9b 100644
> --- a/block/qcow2.c
> +++ b/block/qcow2.c
> @@ -1724,7 +1724,7 @@ static int coroutine_fn qcow2_do_open(BlockDriverState
> *bs, QDict *options,
> /* Clear unknown autoclear feature bits */
> update_header |= s->autoclear_features & ~QCOW2_AUTOCLEAR_MASK;
> update_header =
> - update_header && !bs->read_only && !(flags & BDRV_O_INACTIVE);
> + update_header && bdrv_is_writable(bs);
This statement fits on a single line now.
Kevin