From nobody Mon Feb 9 17:58:18 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=1594006917; cv=none; d=zohomail.com; s=zohoarc; b=T07dgliW/wLa9aI6bDNyYOysEL36jO4pCuWLUWHw9h5QdMzLlDnQ3hk1XiGzLio0GDqt3EfPyoZG9weOnku0wiT2tMvySgW88VSy08qWf+LvQP8wEe5GTubFLsagKgUr4JrAuTWOZK+R0kBeFa0ieK34C9IrvbfOkl9XOIJjS5I= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1594006917; 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=feikxWiX1WaldCQ+J05wB1EEgduxRNXSDlkMliXgUrU=; b=YryOfURbRkq+KdmZZ0J4fwgPBZ6QWhlmpLV9QMe036r/AYvH84qTKPZQXvthtSLLuCaxH3COBdIliOsgT05PHy6gDBIv7B/Fs+BnGeWsM/sKkNipBOTv+MnpY3BAOBp372XjJiMzwMHR+p95XYo0LgvvoUvCHeCz5cGvfWYltJU= 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-1.mimecast.com [207.211.31.81]) by mx.zohomail.com with SMTPS id 1594006917235817.9662407583285; Sun, 5 Jul 2020 20:41:57 -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-417-uXdya8CAPj-89XpqcYsufA-1; Sun, 05 Jul 2020 23:41:54 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id A4D6710059B1; Mon, 6 Jul 2020 03:41:48 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 64F16100238C; Mon, 6 Jul 2020 03:41:48 +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 9EB3818095FF; Mon, 6 Jul 2020 03:41:42 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 0663ffF9004400 for ; Sun, 5 Jul 2020 23:41:41 -0400 Received: by smtp.corp.redhat.com (Postfix) id 432DE71678; Mon, 6 Jul 2020 03:41:41 +0000 (UTC) Received: from vhost2.laine.org (ovpn-112-194.phx2.redhat.com [10.3.112.194]) by smtp.corp.redhat.com (Postfix) with ESMTP id ED642275E20 for ; Mon, 6 Jul 2020 03:41:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1594006915; 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=feikxWiX1WaldCQ+J05wB1EEgduxRNXSDlkMliXgUrU=; b=eLkIWRnSmhTDiYmdv7CBtuLHWw2o8wZio4BTyzsh9Kz3fHtG2kI0SZOiCs/BgQsZSs024B gZuPuxq5I4xQGKXhBuziyKtvUju0jp1MjPi23JIQwf6Y6VnDt4fGqY9C34Fo/B+6M8/D2G dm2ap+ak2qXfU7UkvmqwbQJqr0o06o0= X-MC-Unique: uXdya8CAPj-89XpqcYsufA-1 From: Laine Stump To: libvir-list@redhat.com Subject: [PATCH 02/32] esx: use g_auto() for all virBuffers Date: Sun, 5 Jul 2020 23:40:57 -0400 Message-Id: <20200706034127.1117504-3-laine@redhat.com> In-Reply-To: <20200706034127.1117504-1-laine@redhat.com> References: <20200706034127.1117504-1-laine@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 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.84 on 10.5.11.22 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) Content-Type: text/plain; charset="utf-8" Signed-off-by: Laine Stump Reviewed-by: J=C3=A1n Tomko --- src/esx/esx_driver.c | 19 +++++-------------- src/esx/esx_util.c | 4 ++-- src/esx/esx_vi.c | 19 +++++-------------- src/esx/esx_vi_methods.c | 6 +----- 4 files changed, 13 insertions(+), 35 deletions(-) diff --git a/src/esx/esx_driver.c b/src/esx/esx_driver.c index 0ede65279a..3fb7a3b62c 100644 --- a/src/esx/esx_driver.c +++ b/src/esx/esx_driver.c @@ -275,7 +275,7 @@ esxFormatVMXFileName(const char *fileName, void *opaque) esxVI_ObjectContent *datastore =3D NULL; esxVI_DatastoreHostMount *hostMount =3D NULL; char separator =3D '/'; - virBuffer buffer =3D VIR_BUFFER_INITIALIZER; + g_auto(virBuffer) buffer =3D VIR_BUFFER_INITIALIZER; char *tmp; size_t length; =20 @@ -336,10 +336,8 @@ esxFormatVMXFileName(const char *fileName, void *opaqu= e) success =3D true; =20 cleanup: - if (! success) { - virBufferFreeAndReset(&buffer); + if (! success) VIR_FREE(result); - } =20 VIR_FREE(datastoreName); VIR_FREE(directoryAndFileName); @@ -2359,7 +2357,7 @@ esxDomainScreenshot(virDomainPtr domain, virStreamPtr= stream, esxVI_String *propertyNameList =3D NULL; esxVI_ObjectContent *virtualMachine =3D NULL; esxVI_VirtualMachinePowerState powerState; - virBuffer buffer =3D VIR_BUFFER_INITIALIZER; + g_auto(virBuffer) buffer =3D VIR_BUFFER_INITIALIZER; char *url =3D NULL; =20 virCheckFlags(0, NULL); @@ -2413,7 +2411,6 @@ esxDomainScreenshot(virDomainPtr domain, virStreamPtr= stream, } =20 cleanup: - virBufferFreeAndReset(&buffer); =20 esxVI_String_Free(&propertyNameList); esxVI_ObjectContent_Free(&virtualMachine); @@ -2579,7 +2576,7 @@ esxDomainGetXMLDesc(virDomainPtr domain, unsigned int= flags) char *datastoreName =3D NULL; char *directoryName =3D NULL; char *directoryAndFileName =3D NULL; - virBuffer buffer =3D VIR_BUFFER_INITIALIZER; + g_auto(virBuffer) buffer =3D VIR_BUFFER_INITIALIZER; char *url =3D NULL; char *vmx =3D NULL; virVMXContext ctx; @@ -2653,9 +2650,6 @@ esxDomainGetXMLDesc(virDomainPtr domain, unsigned int= flags) } =20 cleanup: - if (!url) - virBufferFreeAndReset(&buffer); - esxVI_String_Free(&propertyNameList); esxVI_ObjectContent_Free(&virtualMachine); VIR_FREE(moref); @@ -2936,7 +2930,7 @@ esxDomainDefineXMLFlags(virConnectPtr conn, const cha= r *xml, unsigned int flags) char *datastoreName =3D NULL; char *directoryName =3D NULL; char *escapedName =3D NULL; - virBuffer buffer =3D VIR_BUFFER_INITIALIZER; + g_auto(virBuffer) buffer =3D VIR_BUFFER_INITIALIZER; char *url =3D NULL; char *datastoreRelatedPath =3D NULL; esxVI_String *propertyNameList =3D NULL; @@ -3124,9 +3118,6 @@ esxDomainDefineXMLFlags(virConnectPtr conn, const cha= r *xml, unsigned int flags) /* FIXME: Add proper rollback in case of an error */ =20 cleanup: - if (!url) - virBufferFreeAndReset(&buffer); - virDomainDefFree(def); VIR_FREE(vmx); VIR_FREE(datastoreName); diff --git a/src/esx/esx_util.c b/src/esx/esx_util.c index 89d136248f..11f43acc19 100644 --- a/src/esx/esx_util.c +++ b/src/esx/esx_util.c @@ -357,7 +357,7 @@ esxUtil_EscapeBase64(const char *string) static const char *base64 =3D "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+,"; =20 - virBuffer buffer =3D VIR_BUFFER_INITIALIZER; + g_auto(virBuffer) buffer =3D VIR_BUFFER_INITIALIZER; const char *tmp1 =3D string; size_t length; unsigned char c1, c2, c3; @@ -456,7 +456,7 @@ esxUtil_EscapeDatastoreItem(const char *string) char * esxUtil_EscapeForXml(const char *string) { - virBuffer buffer =3D VIR_BUFFER_INITIALIZER; + g_auto(virBuffer) buffer =3D VIR_BUFFER_INITIALIZER; =20 virBufferEscapeString(&buffer, "%s", string); =20 diff --git a/src/esx/esx_vi.c b/src/esx/esx_vi.c index 16690edfbe..d48a24e9d3 100644 --- a/src/esx/esx_vi.c +++ b/src/esx/esx_vi.c @@ -370,7 +370,7 @@ esxVI_CURL_Download(esxVI_CURL *curl, const char *url, = char **content, unsigned long long offset, unsigned long long *length) { char *range =3D NULL; - virBuffer buffer =3D VIR_BUFFER_INITIALIZER; + g_auto(virBuffer) buffer =3D VIR_BUFFER_INITIALIZER; int responseCode =3D 0; =20 ESX_VI_CHECK_ARG_LIST(content); @@ -421,10 +421,8 @@ esxVI_CURL_Download(esxVI_CURL *curl, const char *url,= char **content, cleanup: VIR_FREE(range); =20 - if (!(*content)) { - virBufferFreeAndReset(&buffer); + if (!(*content)) return -1; - } =20 return 0; } @@ -1025,7 +1023,7 @@ esxVI_Context_LookupManagedObjectsByPath(esxVI_Contex= t *ctx, const char *path) char *saveptr =3D NULL; char *previousItem =3D NULL; char *item =3D NULL; - virBuffer buffer =3D VIR_BUFFER_INITIALIZER; + g_auto(virBuffer) buffer =3D VIR_BUFFER_INITIALIZER; esxVI_ManagedObjectReference *root =3D NULL; esxVI_Folder *folder =3D NULL; =20 @@ -1184,9 +1182,6 @@ esxVI_Context_LookupManagedObjectsByPath(esxVI_Contex= t *ctx, const char *path) result =3D 0; =20 cleanup: - if (result < 0) - virBufferFreeAndReset(&buffer); - if (root !=3D ctx->service->rootFolder && (!ctx->datacenter || root !=3D ctx->datacenter->hostFolder)) { esxVI_ManagedObjectReference_Free(&root); @@ -1248,7 +1243,7 @@ esxVI_Context_Execute(esxVI_Context *ctx, const char = *methodName, esxVI_Occurrence occurrence) { int result =3D -1; - virBuffer buffer =3D VIR_BUFFER_INITIALIZER; + g_auto(virBuffer) buffer =3D VIR_BUFFER_INITIALIZER; esxVI_Fault *fault =3D NULL; char *xpathExpression =3D NULL; xmlXPathContextPtr xpathContext =3D NULL; @@ -1408,7 +1403,6 @@ esxVI_Context_Execute(esxVI_Context *ctx, const char = *methodName, =20 cleanup: if (result < 0) { - virBufferFreeAndReset(&buffer); esxVI_Response_Free(response); esxVI_Fault_Free(&fault); } @@ -4130,7 +4124,7 @@ esxVI_HandleVirtualMachineQuestion { int result =3D -1; esxVI_ElementDescription *elementDescription =3D NULL; - virBuffer buffer =3D VIR_BUFFER_INITIALIZER; + g_auto(virBuffer) buffer =3D VIR_BUFFER_INITIALIZER; esxVI_ElementDescription *answerChoice =3D NULL; int answerIndex =3D 0; char *possibleAnswers =3D NULL; @@ -4212,9 +4206,6 @@ esxVI_HandleVirtualMachineQuestion result =3D 0; =20 cleanup: - if (result < 0) - virBufferFreeAndReset(&buffer); - VIR_FREE(possibleAnswers); =20 return result; diff --git a/src/esx/esx_vi_methods.c b/src/esx/esx_vi_methods.c index 616b202d09..e22a078997 100644 --- a/src/esx/esx_vi_methods.c +++ b/src/esx/esx_vi_methods.c @@ -105,7 +105,7 @@ { \ int result =3D -1; \ const char *methodName =3D #_name; \ - virBuffer buffer =3D VIR_BUFFER_INITIALIZER; \ + g_auto(virBuffer) buffer =3D VIR_BUFFER_INITIALIZER; \ char *request =3D NULL; \ esxVI_Response *response =3D NULL; \ \ @@ -136,10 +136,6 @@ result =3D 0; \ \ cleanup: \ - if (result < 0) { \ - virBufferFreeAndReset(&buffer); \ - } \ - \ VIR_FREE(request); \ esxVI_Response_Free(&response); \ \ --=20 2.25.4