qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [PATCH 21/36] qtest: Avoid dynamic JSON in tmp105-test


From: Eric Blake
Subject: [Qemu-devel] [PATCH 21/36] qtest: Avoid dynamic JSON in tmp105-test
Date: Wed, 30 Nov 2016 13:44:39 -0600

As argued elsewhere, it's less code to maintain if we convert
from a dynamic string passed to qobject_from_jsonv() to instead
use a hand-built QDict.

Signed-off-by: Eric Blake <address@hidden>
---
 tests/tmp105-test.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/tests/tmp105-test.c b/tests/tmp105-test.c
index a7940a4..7019445 100644
--- a/tests/tmp105-test.c
+++ b/tests/tmp105-test.c
@@ -80,9 +80,12 @@ static int qmp_tmp105_get_temperature(const char *id)
 static void qmp_tmp105_set_temperature(const char *id, int value)
 {
     QDict *response;
+    QDict *args = qdict_new();

-    response = qmp("{ 'execute': 'qom-set', 'arguments': { 'path': %s, "
-                   "'property': 'temperature', 'value': %d } }", id, value);
+    qdict_put_str(args, "path", id);
+    qdict_put_str(args, "property", "temperature");
+    qdict_put_int(args, "value", value);
+    response = qmp_cmd("qom-set", args);
     g_assert(qdict_haskey(response, "return"));
     QDECREF(response);
 }
-- 
2.7.4




reply via email to

[Prev in Thread] Current Thread [Next in Thread]