提交 0f0ad111 编写于 作者: P Peter Krempa

json: Replace access to virJSONValue->type by virJSONValueGetType

Signed-off-by: NPeter Krempa <pkrempa@redhat.com>
上级 91813b87
...@@ -336,7 +336,7 @@ qemuAgentIOProcessLine(qemuAgentPtr mon, ...@@ -336,7 +336,7 @@ qemuAgentIOProcessLine(qemuAgentPtr mon,
goto cleanup; goto cleanup;
} }
if (obj->type != VIR_JSON_TYPE_OBJECT) { if (virJSONValueGetType(obj) != VIR_JSON_TYPE_OBJECT) {
virReportError(VIR_ERR_INTERNAL_ERROR, virReportError(VIR_ERR_INTERNAL_ERROR,
_("Parsed JSON reply '%s' isn't an object"), line); _("Parsed JSON reply '%s' isn't an object"), line);
goto cleanup; goto cleanup;
...@@ -1872,7 +1872,7 @@ qemuAgentGetFSInfo(qemuAgentPtr mon, virDomainFSInfoPtr **info, ...@@ -1872,7 +1872,7 @@ qemuAgentGetFSInfo(qemuAgentPtr mon, virDomainFSInfoPtr **info,
goto cleanup; goto cleanup;
} }
if (data->type != VIR_JSON_TYPE_ARRAY) { if (virJSONValueGetType(data) != VIR_JSON_TYPE_ARRAY) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s", virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("guest-get-fsinfo return information was not " _("guest-get-fsinfo return information was not "
"an array")); "an array"));
...@@ -1931,7 +1931,7 @@ qemuAgentGetFSInfo(qemuAgentPtr mon, virDomainFSInfoPtr **info, ...@@ -1931,7 +1931,7 @@ qemuAgentGetFSInfo(qemuAgentPtr mon, virDomainFSInfoPtr **info,
goto cleanup; goto cleanup;
} }
if (entry->type != VIR_JSON_TYPE_ARRAY) { if (virJSONValueGetType(entry) != VIR_JSON_TYPE_ARRAY) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s", virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("guest-get-fsinfo 'disk' data was not an array")); _("guest-get-fsinfo 'disk' data was not an array"));
goto cleanup; goto cleanup;
......
...@@ -197,7 +197,7 @@ qemuMonitorJSONIOProcessLine(qemuMonitorPtr mon, ...@@ -197,7 +197,7 @@ qemuMonitorJSONIOProcessLine(qemuMonitorPtr mon,
if (!(obj = virJSONValueFromString(line))) if (!(obj = virJSONValueFromString(line)))
goto cleanup; goto cleanup;
if (obj->type != VIR_JSON_TYPE_OBJECT) { if (virJSONValueGetType(obj) != VIR_JSON_TYPE_OBJECT) {
virReportError(VIR_ERR_INTERNAL_ERROR, virReportError(VIR_ERR_INTERNAL_ERROR,
_("Parsed JSON reply '%s' isn't an object"), line); _("Parsed JSON reply '%s' isn't an object"), line);
goto cleanup; goto cleanup;
...@@ -1978,7 +1978,7 @@ qemuMonitorJSONGetBlockDev(virJSONValuePtr devices, ...@@ -1978,7 +1978,7 @@ qemuMonitorJSONGetBlockDev(virJSONValuePtr devices,
{ {
virJSONValuePtr dev = virJSONValueArrayGet(devices, idx); 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", virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("query-block device entry was not in expected format")); _("query-block device entry was not in expected format"));
return NULL; return NULL;
...@@ -2197,7 +2197,7 @@ qemuMonitorJSONGetAllBlockStatsInfo(qemuMonitorPtr mon, ...@@ -2197,7 +2197,7 @@ qemuMonitorJSONGetAllBlockStatsInfo(qemuMonitorPtr mon,
virJSONValuePtr dev = virJSONValueArrayGet(devices, i); virJSONValuePtr dev = virJSONValueArrayGet(devices, i);
const char *dev_name; 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", virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("blockstats device entry was not " _("blockstats device entry was not "
"in expected format")); "in expected format"));
...@@ -3276,7 +3276,7 @@ qemuMonitorJSONGetDumpGuestMemoryCapability(qemuMonitorPtr mon, ...@@ -3276,7 +3276,7 @@ qemuMonitorJSONGetDumpGuestMemoryCapability(qemuMonitorPtr mon,
for (i = 0; i < virJSONValueArraySize(formats); i++) { for (i = 0; i < virJSONValueArraySize(formats); i++) {
virJSONValuePtr dumpformat = virJSONValueArrayGet(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", virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("missing entry in supported dump formats")); _("missing entry in supported dump formats"));
goto cleanup; goto cleanup;
...@@ -4791,7 +4791,7 @@ qemuMonitorJSONBlockIoThrottleInfo(virJSONValuePtr result, ...@@ -4791,7 +4791,7 @@ qemuMonitorJSONBlockIoThrottleInfo(virJSONValuePtr result,
virJSONValuePtr inserted; virJSONValuePtr inserted;
const char *current_dev; 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", virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("block_io_throttle device entry " _("block_io_throttle device entry "
"was not in expected format")); "was not in expected format"));
...@@ -5261,7 +5261,7 @@ qemuMonitorJSONGetCPUDefinitions(qemuMonitorPtr mon, ...@@ -5261,7 +5261,7 @@ qemuMonitorJSONGetCPUDefinitions(qemuMonitorPtr mon,
for (j = 0; j < len; j++) { for (j = 0; j < len; j++) {
virJSONValuePtr blocker = virJSONValueArrayGet(blockers, 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", virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("unexpected value in unavailable-features " _("unexpected value in unavailable-features "
"array")); "array"));
...@@ -5304,7 +5304,7 @@ qemuMonitorJSONParseCPUModelProperty(const char *key, ...@@ -5304,7 +5304,7 @@ qemuMonitorJSONParseCPUModelProperty(const char *key,
prop = machine_model->props + machine_model->nprops; prop = machine_model->props + machine_model->nprops;
switch ((virJSONType) value->type) { switch ((virJSONType) virJSONValueGetType(value)) {
case VIR_JSON_TYPE_STRING: case VIR_JSON_TYPE_STRING:
if (VIR_STRDUP(prop->value.string, virJSONValueGetString(value)) < 0) if (VIR_STRDUP(prop->value.string, virJSONValueGetString(value)) < 0)
return -1; return -1;
...@@ -6193,7 +6193,7 @@ qemuMonitorJSONGetMigrationCapabilities(qemuMonitorPtr mon, ...@@ -6193,7 +6193,7 @@ qemuMonitorJSONGetMigrationCapabilities(qemuMonitorPtr mon,
virJSONValuePtr cap = virJSONValueArrayGet(caps, i); virJSONValuePtr cap = virJSONValueArrayGet(caps, i);
const char *name; 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", virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("missing entry in migration capabilities list")); _("missing entry in migration capabilities list"));
goto cleanup; goto cleanup;
...@@ -6343,7 +6343,7 @@ qemuMonitorJSONGetGICCapabilities(qemuMonitorPtr mon, ...@@ -6343,7 +6343,7 @@ qemuMonitorJSONGetGICCapabilities(qemuMonitorPtr mon,
bool kernel; bool kernel;
bool emulated; bool emulated;
if (!cap || cap->type != VIR_JSON_TYPE_OBJECT) { if (!cap || virJSONValueGetType(cap) != VIR_JSON_TYPE_OBJECT) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s", virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("missing entry in GIC capabilities list")); _("missing entry in GIC capabilities list"));
goto cleanup; goto cleanup;
......
...@@ -146,16 +146,17 @@ virQEMUBuildCommandLineJSONRecurse(const char *key, ...@@ -146,16 +146,17 @@ virQEMUBuildCommandLineJSONRecurse(const char *key,
bool nested) bool nested)
{ {
struct virQEMUCommandLineJSONIteratorData data = { key, buf, arrayFunc }; struct virQEMUCommandLineJSONIteratorData data = { key, buf, arrayFunc };
virJSONType type = virJSONValueGetType(value);
virJSONValuePtr elem; virJSONValuePtr elem;
size_t i; size_t i;
if (!key && value->type != VIR_JSON_TYPE_OBJECT) { if (!key && type != VIR_JSON_TYPE_OBJECT) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s", virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("only JSON objects can be top level")); _("only JSON objects can be top level"));
return -1; return -1;
} }
switch ((virJSONType) value->type) { switch (type) {
case VIR_JSON_TYPE_STRING: case VIR_JSON_TYPE_STRING:
virBufferAsprintf(buf, "%s=", key); virBufferAsprintf(buf, "%s=", key);
virQEMUBuildBufferEscapeComma(buf, value->data.string); virQEMUBuildBufferEscapeComma(buf, value->data.string);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册