[PATCH 5/9] json: Replace access to virJSONValue->type by virJSONValueGetType

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

 



Signed-off-by: Peter Krempa <pkrempa@xxxxxxxxxx>
---
 src/qemu/qemu_agent.c        |  6 +++---
 src/qemu/qemu_monitor_json.c | 18 +++++++++---------
 src/util/virqemu.c           |  5 +++--
 3 files changed, 15 insertions(+), 14 deletions(-)

diff --git a/src/qemu/qemu_agent.c b/src/qemu/qemu_agent.c
index dfec57d992..85af53d194 100644
--- a/src/qemu/qemu_agent.c
+++ b/src/qemu/qemu_agent.c
@@ -336,7 +336,7 @@ qemuAgentIOProcessLine(qemuAgentPtr mon,
         goto cleanup;
     }

-    if (obj->type != VIR_JSON_TYPE_OBJECT) {
+    if (virJSONValueGetType(obj) != VIR_JSON_TYPE_OBJECT) {
         virReportError(VIR_ERR_INTERNAL_ERROR,
                        _("Parsed JSON reply '%s' isn't an object"), line);
         goto cleanup;
@@ -1872,7 +1872,7 @@ qemuAgentGetFSInfo(qemuAgentPtr mon, virDomainFSInfoPtr **info,
         goto cleanup;
     }

-    if (data->type != VIR_JSON_TYPE_ARRAY) {
+    if (virJSONValueGetType(data) != VIR_JSON_TYPE_ARRAY) {
         virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
                        _("guest-get-fsinfo return information was not "
                          "an array"));
@@ -1931,7 +1931,7 @@ qemuAgentGetFSInfo(qemuAgentPtr mon, virDomainFSInfoPtr **info,
             goto cleanup;
         }

-        if (entry->type != VIR_JSON_TYPE_ARRAY) {
+        if (virJSONValueGetType(entry) != VIR_JSON_TYPE_ARRAY) {
             virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
                            _("guest-get-fsinfo 'disk' data was not an array"));
             goto cleanup;
diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c
index c94d2ef4b8..de915eabb4 100644
--- a/src/qemu/qemu_monitor_json.c
+++ b/src/qemu/qemu_monitor_json.c
@@ -197,7 +197,7 @@ qemuMonitorJSONIOProcessLine(qemuMonitorPtr mon,
     if (!(obj = virJSONValueFromString(line)))
         goto cleanup;

-    if (obj->type != VIR_JSON_TYPE_OBJECT) {
+    if (virJSONValueGetType(obj) != VIR_JSON_TYPE_OBJECT) {
         virReportError(VIR_ERR_INTERNAL_ERROR,
                        _("Parsed JSON reply '%s' isn't an object"), line);
         goto cleanup;
@@ -1978,7 +1978,7 @@ qemuMonitorJSONGetBlockDev(virJSONValuePtr devices,
 {
     virJSONValuePtr dev = virJSONValueArrayGet(devices, idx);

-    if (!dev || dev->type != VIR_JSON_TYPE_OBJECT) {
+    if (!dev || virJSONValueGetType(dev) != VIR_JSON_TYPE_OBJECT) {
         virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
                        _("query-block device entry was not in expected format"));
         return NULL;
@@ -2197,7 +2197,7 @@ qemuMonitorJSONGetAllBlockStatsInfo(qemuMonitorPtr mon,
         virJSONValuePtr dev = virJSONValueArrayGet(devices, i);
         const char *dev_name;

-        if (!dev || dev->type != VIR_JSON_TYPE_OBJECT) {
+        if (!dev || virJSONValueGetType(dev) != VIR_JSON_TYPE_OBJECT) {
             virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
                            _("blockstats device entry was not "
                              "in expected format"));
@@ -3276,7 +3276,7 @@ qemuMonitorJSONGetDumpGuestMemoryCapability(qemuMonitorPtr mon,
     for (i = 0; i < virJSONValueArraySize(formats); i++) {
         virJSONValuePtr dumpformat = virJSONValueArrayGet(formats, i);

-        if (!dumpformat || dumpformat->type != VIR_JSON_TYPE_STRING) {
+        if (!dumpformat || virJSONValueGetType(dumpformat) != VIR_JSON_TYPE_STRING) {
             virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
                            _("missing entry in supported dump formats"));
             goto cleanup;
@@ -4791,7 +4791,7 @@ qemuMonitorJSONBlockIoThrottleInfo(virJSONValuePtr result,
         virJSONValuePtr inserted;
         const char *current_dev;

-        if (!temp_dev || temp_dev->type != VIR_JSON_TYPE_OBJECT) {
+        if (!temp_dev || virJSONValueGetType(temp_dev) != VIR_JSON_TYPE_OBJECT) {
             virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
                            _("block_io_throttle device entry "
                              "was not in expected format"));
@@ -5261,7 +5261,7 @@ qemuMonitorJSONGetCPUDefinitions(qemuMonitorPtr mon,
             for (j = 0; j < len; j++) {
                 virJSONValuePtr blocker = virJSONValueArrayGet(blockers, j);

-                if (blocker->type != VIR_JSON_TYPE_STRING) {
+                if (virJSONValueGetType(blocker) != VIR_JSON_TYPE_STRING) {
                     virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
                                    _("unexpected value in unavailable-features "
                                      "array"));
@@ -5304,7 +5304,7 @@ qemuMonitorJSONParseCPUModelProperty(const char *key,

     prop = machine_model->props + machine_model->nprops;

-    switch ((virJSONType) value->type) {
+    switch ((virJSONType) virJSONValueGetType(value)) {
     case VIR_JSON_TYPE_STRING:
         if (VIR_STRDUP(prop->value.string, virJSONValueGetString(value)) < 0)
             return -1;
@@ -6193,7 +6193,7 @@ qemuMonitorJSONGetMigrationCapabilities(qemuMonitorPtr mon,
         virJSONValuePtr cap = virJSONValueArrayGet(caps, i);
         const char *name;

-        if (!cap || cap->type != VIR_JSON_TYPE_OBJECT) {
+        if (!cap || virJSONValueGetType(cap) != VIR_JSON_TYPE_OBJECT) {
             virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
                            _("missing entry in migration capabilities list"));
             goto cleanup;
@@ -6343,7 +6343,7 @@ qemuMonitorJSONGetGICCapabilities(qemuMonitorPtr mon,
         bool kernel;
         bool emulated;

-        if (!cap || cap->type != VIR_JSON_TYPE_OBJECT) {
+        if (!cap || virJSONValueGetType(cap) != VIR_JSON_TYPE_OBJECT) {
             virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
                            _("missing entry in GIC capabilities list"));
             goto cleanup;
diff --git a/src/util/virqemu.c b/src/util/virqemu.c
index 2e9e65f9ef..e7ea068b94 100644
--- a/src/util/virqemu.c
+++ b/src/util/virqemu.c
@@ -146,16 +146,17 @@ virQEMUBuildCommandLineJSONRecurse(const char *key,
                                    bool nested)
 {
     struct virQEMUCommandLineJSONIteratorData data = { key, buf, arrayFunc };
+    virJSONType type = virJSONValueGetType(value);
     virJSONValuePtr elem;
     size_t i;

-    if (!key && value->type != VIR_JSON_TYPE_OBJECT) {
+    if (!key && type != VIR_JSON_TYPE_OBJECT) {
         virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
                        _("only JSON objects can be top level"));
         return -1;
     }

-    switch ((virJSONType) value->type) {
+    switch (type) {
     case VIR_JSON_TYPE_STRING:
         virBufferAsprintf(buf, "%s=", key);
         virQEMUBuildBufferEscapeComma(buf, value->data.string);
-- 
2.16.2

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux