From nobody Mon Feb 9 01:21:49 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 207.211.31.81 as permitted sender) client-ip=207.211.31.81; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.81 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=1584347808; cv=none; d=zohomail.com; s=zohoarc; b=lXEDzBMpdOU/4UprlZGbFn/+h7aRgYRlsIDwVGQYnm6wyvMQLwgTDjHzJZXS/rEkw6U3n12M7G06kyHFIGXLPspvcbeOqolUsc8Nlfa4TZfOXTveQaI1XF//PjvhMWm9tpZmVNXBKqi98H1fEZEJV11dqlYqsjDYQNaAGD/MwGk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1584347808; 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=7buFgGLaQAkVOBQCK42Zo+UVSrPy+AQi8B71Q0KFONw=; b=KFFczpvnjlO3buwO7DK8Br1qqHAaClGK4EZByb27SeNRghy4rrJaCV3mprSurf54xycv9X63jsv3Na3FRDjXthzYrdRvkJQJDNbG6VAE+kP/1t1Qy8grqeaGzwyIWyrPprWY0aLm8qxj09ITMlxDQMSw+oaAQVo/mgPeO8aGDBM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.81 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-1.mimecast.com (us-smtp-2.mimecast.com [207.211.31.81]) by mx.zohomail.com with SMTPS id 1584347808752433.1573140250779; Mon, 16 Mar 2020 01:36:48 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-45-XKq8TtWrO7eE-lhq5FzhPw-1; Mon, 16 Mar 2020 04:36:45 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 9A95D801E66; Mon, 16 Mar 2020 08:36:39 +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 6E6935C1C3; Mon, 16 Mar 2020 08:36:39 +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 20D6086FF3; Mon, 16 Mar 2020 08:36:39 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 02G8a5Au026223 for ; Mon, 16 Mar 2020 04:36:05 -0400 Received: by smtp.corp.redhat.com (Postfix) id D218860BFB; Mon, 16 Mar 2020 08:36:05 +0000 (UTC) Received: from angien.redhat.com (unknown [10.43.2.48]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5881F60BF3 for ; Mon, 16 Mar 2020 08:36:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1584347807; 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=7buFgGLaQAkVOBQCK42Zo+UVSrPy+AQi8B71Q0KFONw=; b=ExDrHRqSJ9wSfwV105KgQ6wUtg6xeqpk3a0nDacxPKtGQTnCdBe6YEK4ljBR5EotEnxMOm TVWZnKgH7M8IzcH5ERLqbOILMhr2+VJkr49KphpK8CUIYRHfeXO2ZIhrjRFPlhXQIr48K8 l7oPGZ3nVlok5Bsaq6HyEzkPwS2aYOo= X-MC-Unique: XKq8TtWrO7eE-lhq5FzhPw-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 06/12] qemuAgentGetHostname: Refactor to remove cleanup section Date: Mon, 16 Mar 2020 09:35:48 +0100 Message-Id: <11ce85bdab9926424f5a278ac652e4b4eb99a07e.1584347691.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 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.16 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Use g_autoptr instead. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_agent.c | 26 +++++++++----------------- 1 file changed, 9 insertions(+), 17 deletions(-) diff --git a/src/qemu/qemu_agent.c b/src/qemu/qemu_agent.c index c55b989467..07aba2b45d 100644 --- a/src/qemu/qemu_agent.c +++ b/src/qemu/qemu_agent.c @@ -1720,44 +1720,36 @@ int qemuAgentGetHostname(qemuAgentPtr agent, char **hostname) { - int ret =3D -1; - virJSONValuePtr cmd; - virJSONValuePtr reply =3D NULL; + g_autoptr(virJSONValue) cmd =3D qemuAgentMakeCommand("guest-get-host-n= ame", NULL); + g_autoptr(virJSONValue) reply =3D NULL; virJSONValuePtr data =3D NULL; const char *result =3D NULL; - cmd =3D qemuAgentMakeCommand("guest-get-host-name", - NULL); - if (!cmd) - return ret; + return -1; if (qemuAgentCommand(agent, cmd, &reply, agent->timeout) < 0) { if (qemuAgentErrorCommandUnsupported(reply)) - ret =3D -2; - goto cleanup; + return -2; + + return -1; } if (!(data =3D virJSONValueObjectGet(reply, "return"))) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("malformed return value")); - goto cleanup; + return -1; } if (!(result =3D virJSONValueObjectGetString(data, "host-name"))) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("'host-name' missing in guest-get-host-name reply= ")); - goto cleanup; + return -1; } *hostname =3D g_strdup(result); - ret =3D 0; - - cleanup: - virJSONValueFree(cmd); - virJSONValueFree(reply); - return ret; + return 0; } --=20 2.24.1