[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH] block: Assert validity of BdrvActionOps
From: |
Eric Blake |
Subject: |
Re: [Qemu-devel] [PATCH] block: Assert validity of BdrvActionOps |
Date: |
Thu, 12 Sep 2013 08:25:15 -0600 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130805 Thunderbird/17.0.8 |
On 09/12/2013 06:57 AM, Max Reitz wrote:
> In qmp_transaction, assert that the BdrvActionOps to be used is actually
> valid.
>
> This assertion failing is very improbable, however, it might happen, if
> a new TransactionActionKind is introduced "out of order" and the
> actions[] array is not updated.
All of which would be a programmer bug, so assert is correct.
>
> Signed-off-by: Max Reitz <address@hidden>
> ---
> blockdev.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/blockdev.c b/blockdev.c
> index 07dac05..14a0bb1 100644
> --- a/blockdev.c
> +++ b/blockdev.c
> @@ -1102,6 +1102,8 @@ void qmp_transaction(TransactionActionList *dev_list,
> Error **errp)
> assert(dev_info->kind < ARRAY_SIZE(actions));
>
> ops = &actions[dev_info->kind];
> + assert(ops->instance_size > 0);
Bikeshedding: assert(ops->instance_size) is slightly less typing (but
not enough to warrant a respin).
Reviewed-by: Eric Blake <address@hidden>
--
Eric Blake eblake redhat com +1-919-301-3266
Libvirt virtualization library http://libvirt.org
signature.asc
Description: OpenPGP digital signature