From dc5b8dbe66589f67d651caadeef1bf05a3a637f7 Mon Sep 17 00:00:00 2001 From: Peter Krempa Date: Thu, 1 Dec 2022 17:07:12 +0100 Subject: [PATCH] qemuAgentSSHGetAuthorizedKeys: Convert last use ofvirJSONValueObjectGetStringArray Use virJSONValueObjectGetArray + virJSONValueArrayToStringList instead so that the ofvirJSONValueObjectGetStringArray wrapper can be removed. Signed-off-by: Peter Krempa Reviewed-by: Michal Privoznik --- src/qemu/qemu_agent.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/qemu/qemu_agent.c b/src/qemu/qemu_agent.c index 70d45955b2..fa2c0bf915 100644 --- a/src/qemu/qemu_agent.c +++ b/src/qemu/qemu_agent.c @@ -2413,6 +2413,7 @@ qemuAgentSSHGetAuthorizedKeys(qemuAgent *agent, g_autoptr(virJSONValue) cmd = NULL; g_autoptr(virJSONValue) reply = NULL; virJSONValue *data = NULL; + virJSONValue *arr = NULL; if (!(cmd = qemuAgentMakeCommand("guest-ssh-get-authorized-keys", "s:username", user, @@ -2422,13 +2423,14 @@ qemuAgentSSHGetAuthorizedKeys(qemuAgent *agent, if (qemuAgentCommand(agent, cmd, &reply, agent->timeout) < 0) return -1; - if (!(data = virJSONValueObjectGetObject(reply, "return"))) { + if (!(data = virJSONValueObjectGetObject(reply, "return")) || + !(arr = virJSONValueObjectGetArray(data, "keys"))) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("qemu agent didn't return an array of keys")); return -1; } - if (!(*keys = virJSONValueObjectGetStringArray(data, "keys"))) + if (!(*keys = virJSONValueArrayToStringList(arr))) return -1; return g_strv_length(*keys);