block: Assert validity of BdrvActionOps
PATCH 1/1 block: Assert validity of BdrvActionOps
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.
--- blockdev.c | 2 ++ 1 file changed, 2 insertions(+)
blockdev.c +2 -0
@@ -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 ); + state =g_malloc0 (ops->instance_size); state->ops = ops; state->action = dev_info;
Signature · 1 line
1.8.3.1
Quoted 6 lines · Max Reitz
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.
Quoted 11 lines
Signed-off-by Max Reitz <[email protected]>--- blockdev.c | 2 ++ 1 file changed, 2 insertions(+)blockdev.c +0
-0
blockdev.c void qmp_transaction(TransactionActionList *dev_list, Error **errp) · line 1105
Quoted 4 lines
blockdev.c +1
-0@@ -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).
Signature · 2 lines
Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org
Kevin Wolf
AppliedAm 12.09.2013 um 14:57 hat Max Reitz geschrieben:
Quoted 8 lines
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.
Signed-off-by Max Reitz <[email protected]>
Thanks, applied to the block branch.
Kevin