On 3/15/20 9:46 AM, Markus Armbruster wrote:
Checking the value of qmp_dispatch() is repetitive.  Factor out
helpers do_qmp_dispatch() and do_qmp_dispatch_error().  Without this,
the next commit would make things even more repetitive.

Signed-off-by: Markus Armbruster <arm...@redhat.com>
---
  tests/test-qmp-cmds.c | 72 +++++++++++++++++++++----------------------
  1 file changed, 35 insertions(+), 37 deletions(-)


+
+static void do_qmp_dispatch_error(QDict *req, bool allow_oob, ErrorClass cls)
+{
+    QDict *resp;
+
+    resp = qmp_dispatch(&qmp_commands, QOBJECT(req), allow_oob);
+    g_assert(resp && qdict_haskey(resp, "error"));
+
+    qobject_unref(resp);
+}

No checking of cls?  Or is that what you hint at as coming later?

At any rate, the refactoring is sane.
Reviewed-by: Eric Blake <ebl...@redhat.com>

--
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3226
Virtualization:  qemu.org | libvirt.org


Reply via email to