From nobody Sun Feb 8 22:08:22 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1638543688; cv=none; d=zohomail.com; s=zohoarc; b=TSklNoSs+yq0iB9Y347x7lIYRGrEp6kbUJWn+3pOz6AVwQvM7YkZrVl2Y/ygZq0kTaZNywHCLoC1LoRc4BYFB9/1ySy6gcBv9H6MOCC7EvUme0doTWMcY+5qirjdXUgXq9vv7qFATFnWq5N77q3ryWWyJBgmTApVvByek+NjIy4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1638543688; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=jIqXmw665jL0PsaccYSEyfyjdN4WiwC8RCDOjry4GD4=; b=Kixal2ecvyjs5l31SKSbD82hosoA6RlI+RO3MzLLzwjpcEX7TZbGPK3iS+JRK3TAe2f1Z72H3yMWD7zY1eCdiTasAcQUxgprnwndlIiCFdUIak3KYjiIJhHtteXZ37nGMCJ3ONHRmMnRpCwtA5+y9J0GsABOQf4kqz1odbCEmy8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mx.zohomail.com with SMTPS id 1638543688989773.7039146000149; Fri, 3 Dec 2021 07:01:28 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-469-OSw2CwisN-axMLShOpexdA-1; Fri, 03 Dec 2021 10:01:26 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id CC6FE84BA6C; Fri, 3 Dec 2021 15:01:07 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id A81355DF3F; Fri, 3 Dec 2021 15:01:07 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 70D104BB7C; Fri, 3 Dec 2021 15:01:07 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 1B3Ew3Ox029712 for ; Fri, 3 Dec 2021 09:58:03 -0500 Received: by smtp.corp.redhat.com (Postfix) id F41D110016FE; Fri, 3 Dec 2021 14:58:02 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.10]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4531010016F5 for ; Fri, 3 Dec 2021 14:58:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1638543688; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=jIqXmw665jL0PsaccYSEyfyjdN4WiwC8RCDOjry4GD4=; b=S3irhU3VzZhGoPTtedI/KUYzsgXGnRw4TNwIGyj2yi70BpEtcxj4id+0nswwCdEHFIPoFQ rek75MuEj1Zkoosap/Qo6MnCVGe3DEYVbNIAyVKKmFaItA6Nevdm1O1i9rzaSj/o32AYNS WGCZBnbRieUx9Lcv4fvlHWFkFtGh/SA= X-MC-Unique: OSw2CwisN-axMLShOpexdA-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 16/16] qemu: agent: Remove unneeded cleanup sections Date: Fri, 3 Dec 2021 15:57:43 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-loop: libvir-list@redhat.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1638543692227100001 Content-Type: text/plain; charset="utf-8" Remove the cleanup sections where not needed after we've converted to automatic freeing of virJSONValue. Signed-off-by: Peter Krempa --- src/qemu/qemu_agent.c | 96 +++++++++++++++++-------------------------- 1 file changed, 38 insertions(+), 58 deletions(-) diff --git a/src/qemu/qemu_agent.c b/src/qemu/qemu_agent.c index 1eb31ffca2..e2107e5cbf 100644 --- a/src/qemu/qemu_agent.c +++ b/src/qemu/qemu_agent.c @@ -1205,7 +1205,6 @@ VIR_ENUM_IMPL(qemuAgentShutdownMode, int qemuAgentShutdown(qemuAgent *agent, qemuAgentShutdownMode mode) { - int ret =3D -1; g_autoptr(virJSONValue) cmd =3D NULL; g_autoptr(virJSONValue) reply =3D NULL; @@ -1219,10 +1218,9 @@ int qemuAgentShutdown(qemuAgent *agent, agent->await_event =3D QEMU_AGENT_EVENT_RESET; else agent->await_event =3D QEMU_AGENT_EVENT_SHUTDOWN; - ret =3D qemuAgentCommand(agent, cmd, &reply, - VIR_DOMAIN_QEMU_AGENT_COMMAND_SHUTDOWN); - return ret; + return qemuAgentCommand(agent, cmd, &reply, + VIR_DOMAIN_QEMU_AGENT_COMMAND_SHUTDOWN); } /* @@ -1242,7 +1240,7 @@ int qemuAgentShutdown(qemuAgent *agent, int qemuAgentFSFreeze(qemuAgent *agent, const char **mountpoints, unsigned int nmountpoints) { - int ret =3D -1; + int nfrozen =3D 0; g_autoptr(virJSONValue) cmd =3D NULL; g_autoptr(virJSONValue) reply =3D NULL; @@ -1258,18 +1256,18 @@ int qemuAgentFSFreeze(qemuAgent *agent, const char = **mountpoints, } if (!cmd) - goto cleanup; + return -1; if (qemuAgentCommand(agent, cmd, &reply, agent->timeout) < 0) - goto cleanup; + return -1; - if (virJSONValueObjectGetNumberInt(reply, "return", &ret) < 0) { + if (virJSONValueObjectGetNumberInt(reply, "return", &nfrozen) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("malformed return value")); + return -1; } - cleanup: - return ret; + return nfrozen; } /* @@ -1285,7 +1283,7 @@ int qemuAgentFSFreeze(qemuAgent *agent, const char **= mountpoints, */ int qemuAgentFSThaw(qemuAgent *agent) { - int ret =3D -1; + int nthawed =3D 0; g_autoptr(virJSONValue) cmd =3D qemuAgentMakeCommand("guest-fsfreeze-t= haw", NULL); g_autoptr(virJSONValue) reply =3D NULL; @@ -1293,15 +1291,15 @@ int qemuAgentFSThaw(qemuAgent *agent) return -1; if (qemuAgentCommand(agent, cmd, &reply, agent->timeout) < 0) - goto cleanup; + return -1; - if (virJSONValueObjectGetNumberInt(reply, "return", &ret) < 0) { + if (virJSONValueObjectGetNumberInt(reply, "return", &nthawed) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("malformed return value")); + return -1; } - cleanup: - return ret; + return nthawed; } VIR_ENUM_DECL(qemuAgentSuspendMode); @@ -1317,7 +1315,6 @@ int qemuAgentSuspend(qemuAgent *agent, unsigned int target) { - int ret =3D -1; g_autoptr(virJSONValue) cmd =3D NULL; g_autoptr(virJSONValue) reply =3D NULL; @@ -1327,9 +1324,8 @@ qemuAgentSuspend(qemuAgent *agent, return -1; agent->await_event =3D QEMU_AGENT_EVENT_SUSPEND; - ret =3D qemuAgentCommand(agent, cmd, &reply, agent->timeout); - return ret; + return qemuAgentCommand(agent, cmd, &reply, agent->timeout); } int @@ -1338,7 +1334,7 @@ qemuAgentArbitraryCommand(qemuAgent *agent, char **result, int timeout) { - int ret =3D -1; + int rc; g_autoptr(virJSONValue) cmd =3D NULL; g_autoptr(virJSONValue) reply =3D NULL; @@ -1348,28 +1344,25 @@ qemuAgentArbitraryCommand(qemuAgent *agent, _("guest agent timeout '%d' is " "less than the minimum '%d'"), timeout, VIR_DOMAIN_QEMU_AGENT_COMMAND_MIN); - goto cleanup; + return -1; } if (!(cmd =3D virJSONValueFromString(cmd_str))) - goto cleanup; + return -1; - if ((ret =3D qemuAgentCommand(agent, cmd, &reply, timeout)) < 0) - goto cleanup; + if ((rc =3D qemuAgentCommand(agent, cmd, &reply, timeout)) < 0) + return rc; if (!(*result =3D virJSONValueToString(reply, false))) - ret =3D -1; - + return -1; - cleanup: - return ret; + return rc; } int qemuAgentFSTrim(qemuAgent *agent, unsigned long long minimum) { - int ret =3D -1; g_autoptr(virJSONValue) cmd =3D NULL; g_autoptr(virJSONValue) reply =3D NULL; @@ -1377,18 +1370,15 @@ qemuAgentFSTrim(qemuAgent *agent, "U:minimum", minimum, NULL); if (!cmd) - return ret; - - ret =3D qemuAgentCommand(agent, cmd, &reply, agent->timeout); + return -1; - return ret; + return qemuAgentCommand(agent, cmd, &reply, agent->timeout); } int qemuAgentGetVCPUs(qemuAgent *agent, qemuAgentCPUInfo **info) { - int ret =3D -1; size_t i; g_autoptr(virJSONValue) cmd =3D NULL; g_autoptr(virJSONValue) reply =3D NULL; @@ -1399,12 +1389,12 @@ qemuAgentGetVCPUs(qemuAgent *agent, return -1; if (qemuAgentCommand(agent, cmd, &reply, agent->timeout) < 0) - goto cleanup; + return -1; if (!(data =3D virJSONValueObjectGetArray(reply, "return"))) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("guest-get-vcpus reply was missing return data")); - goto cleanup; + return -1; } ndata =3D virJSONValueArraySize(data); @@ -1419,33 +1409,30 @@ qemuAgentGetVCPUs(qemuAgent *agent, virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("array element missing in guest-get-vcpus ret= urn " "value")); - goto cleanup; + return -1; } if (virJSONValueObjectGetNumberUint(entry, "logical-id", &in->id) = < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("'logical-id' missing in reply of guest-get-v= cpus")); - goto cleanup; + return -1; } if (virJSONValueObjectGetBoolean(entry, "online", &in->online) < 0= ) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("'online' missing in reply of guest-get-vcpus= ")); - goto cleanup; + return -1; } if (virJSONValueObjectGetBoolean(entry, "can-offline", &in->offlinable) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("'can-offline' missing in reply of guest-get-= vcpus")); - goto cleanup; + return -1; } } - ret =3D ndata; - - cleanup: - return ret; + return ndata; } @@ -1676,7 +1663,6 @@ qemuAgentGetTime(qemuAgent *agent, long long *seconds, unsigned int *nseconds) { - int ret =3D -1; unsigned long long json_time; g_autoptr(virJSONValue) cmd =3D NULL; g_autoptr(virJSONValue) reply =3D NULL; @@ -1684,25 +1670,22 @@ qemuAgentGetTime(qemuAgent *agent, cmd =3D qemuAgentMakeCommand("guest-get-time", NULL); if (!cmd) - return ret; + return -1; if (qemuAgentCommand(agent, cmd, &reply, agent->timeout) < 0) - goto cleanup; + return -1; if (virJSONValueObjectGetNumberUlong(reply, "return", &json_time) < 0)= { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("malformed return value")); - goto cleanup; + return -1; } /* guest agent returns time in nanoseconds, * we need it in seconds here */ *seconds =3D json_time / 1000000000LL; *nseconds =3D json_time % 1000000000LL; - ret =3D 0; - - cleanup: - return ret; + return 0; } @@ -1717,7 +1700,6 @@ qemuAgentSetTime(qemuAgent *agent, unsigned int nseconds, bool rtcSync) { - int ret =3D -1; g_autoptr(virJSONValue) cmd =3D NULL; g_autoptr(virJSONValue) reply =3D NULL; @@ -1736,7 +1718,7 @@ qemuAgentSetTime(qemuAgent *agent, virReportError(VIR_ERR_INVALID_ARG, _("Time '%lld' is too big for guest agent"), seconds); - return ret; + return -1; } json_time =3D seconds * 1000000000LL; @@ -1747,14 +1729,12 @@ qemuAgentSetTime(qemuAgent *agent, } if (!cmd) - return ret; + return -1; if (qemuAgentCommand(agent, cmd, &reply, agent->timeout) < 0) - goto cleanup; + return -1; - ret =3D 0; - cleanup: - return ret; + return 0; } void --=20 2.31.1