From nobody Mon Feb 9 01:22:41 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=1639421204; cv=none; d=zohomail.com; s=zohoarc; b=CM6ulC8E5L7QDmJYXIxmfiAeiIh09cpaVD/2KtjlFZDjj0Dlyt9R7NhK9TFr+7ST529vMUvI+nModTwuFROW+7Af5NANQI4fT5Bg8H0yN9XEGMTUkKle7vxPiRV3PywS3aIpFMhTS17rDedI3qER/lChwFZxDEIQ/A2yB4XH7Ag= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1639421204; 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=Mho8JomLpm9MsIufWsxUIJrDZHlA3kKgaN6I+aezekM=; b=Uf6ck4OjrYoevryyr9frk+Cy7/1l96fw9EdkF6siPezwFMZYnattNfjOicApuqQrn0zwEhKRb3bzV/Gv11E29Rmu9Aha3REi4nlWReSz7jMrjHNK6eFw+ELUotyxbpeC0jZJIIz/4GLmaor9fUNojuBLGOnbGvrGDxyMNYrVPN8= 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 1639421204653357.0085392166476; Mon, 13 Dec 2021 10:46:44 -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-551-m-MQs8OkP0KDK6zlnUlNRA-1; Mon, 13 Dec 2021 13:44:04 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 7DECE100C612; Mon, 13 Dec 2021 18:43:52 +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 2BE765F4EF; Mon, 13 Dec 2021 18:43:52 +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 EB6054A70A; Mon, 13 Dec 2021 18:43:51 +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 1BDIhS1D003948 for ; Mon, 13 Dec 2021 13:43:28 -0500 Received: by smtp.corp.redhat.com (Postfix) id 33AF160C04; Mon, 13 Dec 2021 18:43:28 +0000 (UTC) Received: from hjs.redhat.com (unknown [10.43.2.85]) by smtp.corp.redhat.com (Postfix) with ESMTP id AFABD369A for ; Mon, 13 Dec 2021 18:43:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1639421203; 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=Mho8JomLpm9MsIufWsxUIJrDZHlA3kKgaN6I+aezekM=; b=S7m9QlgEc6CEpqFpgVkWMXuJuIbkbu7YHksyGxu0lqZaqxZSjPqSaLmHh2VKbl+BmWihIS Q0KytRezDhTIwzg3B6TzBqtx6qfQOdFAyzWQvOOom+hFe0wNxDC8//XIBmglVQCtz9gWz6 sGZNr1Hi3TWHmNBUdS55DaqNgvme5+o= X-MC-Unique: m-MQs8OkP0KDK6zlnUlNRA-1 From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Subject: [libvirt PATCH 16/20] vmware: refactor vmwareUpdateVMStatus Date: Mon, 13 Dec 2021 19:43:08 +0100 Message-Id: <48c995e703b2ab80f44f9314682b85453aedff68.1639420923.git.jtomko@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.15 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-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1639421205460100001 Use g_auto and get rid of the cleanup label, as well as the ret variable. Signed-off-by: J=C3=A1n Tomko --- src/vmware/vmware_driver.c | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/src/vmware/vmware_driver.c b/src/vmware/vmware_driver.c index 8f107dd529..998ecdb546 100644 --- a/src/vmware/vmware_driver.c +++ b/src/vmware/vmware_driver.c @@ -284,27 +284,26 @@ vmwareConnectGetVersion(virConnectPtr conn, unsigned = long *version) static int vmwareUpdateVMStatus(struct vmware_driver *driver, virDomainObj *vm) { - virCommand *cmd; - char *outbuf =3D NULL; - char *vmxAbsolutePath =3D NULL; + g_autoptr(virCommand) cmd =3D NULL; + g_autofree char *outbuf =3D NULL; + g_autofree char *vmxAbsolutePath =3D NULL; char *parsedVmxPath =3D NULL; char *str; char *saveptr =3D NULL; bool found =3D false; int oldState =3D virDomainObjGetState(vm, NULL); int newState; - int ret =3D -1; =20 cmd =3D virCommandNewArgList(driver->vmrun, "-T", vmwareDriverTypeToString(driver->type), "list", NULL); virCommandSetOutputBuffer(cmd, &outbuf); if (virCommandRun(cmd, NULL) < 0) - goto cleanup; + return -1; =20 if (virFileResolveAllLinks(((vmwareDomainPtr) vm->privateData)->vmxPat= h, &vmxAbsolutePath) < 0) - goto cleanup; + return -1; =20 for (str =3D outbuf; (parsedVmxPath =3D strtok_r(str, "\n", &saveptr))= !=3D NULL; str =3D NULL) { @@ -331,13 +330,7 @@ vmwareUpdateVMStatus(struct vmware_driver *driver, vir= DomainObj *vm) =20 virDomainObjSetState(vm, newState, 0); =20 - ret =3D 0; - - cleanup: - virCommandFree(cmd); - VIR_FREE(outbuf); - VIR_FREE(vmxAbsolutePath); - return ret; + return 0; } =20 static int --=20 2.31.1