From nobody Mon May 6 01:10:47 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 205.139.110.120 as permitted sender) client-ip=205.139.110.120; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.120 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=X3V/di2ziRwsWGoixw1Nf9W5lTw6S54iZkz3FtNIjE84qZYrjrAjCvJqkDRnQKrId0NFIBb+f7lnj4BHTcallLnTckzOZ0zS/J3LfbPo941I5FE1GTQpR69y7qz+MurKwANUlDKhxVmO8GHUq+/PjytNmjs6UM1az5zckCVK6Sk= 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=3bZjdob8ooINa6E1k82G83aprH5EGhB2oWubro24PG4=; b=HWMD7Y3aBPVzxKDtO2bltEBv1vpfdR9WDr66sIlQrHLVZPzZkF+jeC/wNli8S+RG12gvZREDMu7+WAYl5ltm+jt4c8hWM8lKVPA60XxBtA6PzP5AgA/ds0YT9XItxi7lbJ7fkkbOFCdfmIVC1vD9vu/heAff18u5oXH1k6B7AF8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.120 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-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) by mx.zohomail.com with SMTPS id 1594006917293120.19241581825872; 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-340-HF3FzgbKMYqFaY8_J6MQ0Q-1; Sun, 05 Jul 2020 23:41:53 -0400 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 A3B3580040D; 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 5A5895BAD5; 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 7D4B81809547; 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 0663fe0l004395 for ; Sun, 5 Jul 2020 23:41:40 -0400 Received: by smtp.corp.redhat.com (Postfix) id BB4537AC9F; Mon, 6 Jul 2020 03:41:40 +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 7078571678 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=1594006916; 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=3bZjdob8ooINa6E1k82G83aprH5EGhB2oWubro24PG4=; b=CKs/q/te7qxB6AqJv1ntovxuMhAvgWScf4tU4XaRJLNvOenJNNhQNDUgTEmewRk1+nW4Ae ial1sBsPGiqLvV4FGBTbiuyilX+gDzQIWdv08YjMq8W1ni9mYmNKnzQReH1Mio7+pX365t xOmKArvhwntXvsYlTJBnzX+sX/cGknQ= X-MC-Unique: HF3FzgbKMYqFaY8_J6MQ0Q-1 From: Laine Stump To: libvir-list@redhat.com Subject: [PATCH 01/32] bhyve: use g_auto() for all virBuffers Date: Sun, 5 Jul 2020 23:40:56 -0400 Message-Id: <20200706034127.1117504-2-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.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-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" In most cases this eliminates one or more calls to virBufferClearAndReset(), but even when it doesn't it's better because: 1) it makes the code more consistent, making it more likely that new contri= butors who are "learning by example" will to the right thing. 2) it protects against future modifications that might have otherwise needed to add a virBufferClearAndReset() 3) Currently some functions don't call virBufferClearAndReset() only because they're relying on some subordinate function to call it for them (e.g. bhyveConnectGetSysinfo() in this patch relies on virSysinfoFormat() to clear out the buffer when there is an error). I think this is sloppy behavior, and that the toplevel function that defines and initializes the buffer should be the function clearing it at the end. Signed-off-by: Laine Stump Reviewed-by: J=C3=A1n Tomko --- src/bhyve/bhyve_command.c | 15 ++++++--------- src/bhyve/bhyve_driver.c | 4 ++-- 2 files changed, 8 insertions(+), 11 deletions(-) diff --git a/src/bhyve/bhyve_command.c b/src/bhyve/bhyve_command.c index 5b1d80083a..9649c2d2a2 100644 --- a/src/bhyve/bhyve_command.c +++ b/src/bhyve/bhyve_command.c @@ -166,14 +166,15 @@ bhyveBuildAHCIControllerArgStr(const virDomainDef *de= f, bhyveConnPtr driver, virCommandPtr cmd) { - virBuffer buf =3D VIR_BUFFER_INITIALIZER; - virBuffer device =3D VIR_BUFFER_INITIALIZER; + g_auto(virBuffer) buf =3D VIR_BUFFER_INITIALIZER; const char *disk_source; size_t i; int ret =3D -1; =20 for (i =3D 0; i < def->ndisks; i++) { + g_auto(virBuffer) device =3D VIR_BUFFER_INITIALIZER; virDomainDiskDefPtr disk =3D def->disks[i]; + if (disk->bus !=3D VIR_DOMAIN_DISK_BUS_SATA) continue; =20 @@ -221,7 +222,6 @@ bhyveBuildAHCIControllerArgStr(const virDomainDef *def, goto error; } virBufferAddBuffer(&buf, &device); - virBufferFreeAndReset(&device); } =20 virCommandAddArg(cmd, "-s"); @@ -231,7 +231,6 @@ bhyveBuildAHCIControllerArgStr(const virDomainDef *def, =20 ret =3D 0; error: - virBufferFreeAndReset(&buf); return ret; } =20 @@ -378,7 +377,7 @@ bhyveBuildGraphicsArgStr(const virDomainDef *def, virCommandPtr cmd, bool dryRun) { - virBuffer opt =3D VIR_BUFFER_INITIALIZER; + g_auto(virBuffer) opt =3D VIR_BUFFER_INITIALIZER; virDomainGraphicsListenDefPtr glisten =3D NULL; bool escapeAddr; unsigned short port; @@ -478,7 +477,6 @@ bhyveBuildGraphicsArgStr(const virDomainDef *def, return 0; =20 error: - virBufferFreeAndReset(&opt); return -1; } =20 @@ -765,7 +763,6 @@ virBhyveProcessBuildGrubbhyveCmd(virDomainDefPtr def, char **devicesmap_out) { virDomainDiskDefPtr hdd, cd, userdef, diskdef; - virBuffer devicemap; virCommandPtr cmd; unsigned int best_idx =3D UINT_MAX; size_t i; @@ -773,8 +770,6 @@ virBhyveProcessBuildGrubbhyveCmd(virDomainDefPtr def, if (def->os.bootloaderArgs !=3D NULL) return virBhyveProcessBuildCustomLoaderCmd(def); =20 - devicemap =3D (virBuffer)VIR_BUFFER_INITIALIZER; - /* Search disk list for CD or HDD device. We'll respect if * present and otherwise pick the first CD or failing that HDD we come * across. */ @@ -809,6 +804,8 @@ virBhyveProcessBuildGrubbhyveCmd(virDomainDefPtr def, VIR_DEBUG("grub-bhyve with default arguments"); =20 if (devicesmap_out !=3D NULL) { + g_auto(virBuffer) devicemap =3D VIR_BUFFER_INITIALIZER; + /* Grub device.map (just for boot) */ if (userdef !=3D NULL) { virBhyveFormatGrubDevice(&devicemap, userdef); diff --git a/src/bhyve/bhyve_driver.c b/src/bhyve/bhyve_driver.c index b6204c7fb9..daa20bad40 100644 --- a/src/bhyve/bhyve_driver.c +++ b/src/bhyve/bhyve_driver.c @@ -244,7 +244,7 @@ static char * bhyveConnectGetSysinfo(virConnectPtr conn, unsigned int flags) { bhyveConnPtr privconn =3D conn->privateData; - virBuffer buf =3D VIR_BUFFER_INITIALIZER; + g_auto(virBuffer) buf =3D VIR_BUFFER_INITIALIZER; =20 virCheckFlags(0, NULL); =20 @@ -678,7 +678,7 @@ bhyveConnectDomainXMLToNative(virConnectPtr conn, const char *xmlData, unsigned int flags) { - virBuffer buf =3D VIR_BUFFER_INITIALIZER; + g_auto(virBuffer) buf =3D VIR_BUFFER_INITIALIZER; bhyveConnPtr privconn =3D conn->privateData; virDomainDefPtr def =3D NULL; virCommandPtr cmd =3D NULL, loadcmd =3D NULL; --=20 2.25.4 From nobody Mon May 6 01:10:47 2024 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 From nobody Mon May 6 01:10:47 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 205.139.110.61 as permitted sender) client-ip=205.139.110.61; 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 205.139.110.61 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=1594006934; cv=none; d=zohomail.com; s=zohoarc; b=BdfK/xQF3P44lhteYmRgNcMrxSd7A2oMR+V7Twmth28y0qNzs+mePlcJyv2p5Ilml5neU8gj3+FQ2BaS9u+ZRePKOoA843dcZcw+VdmryiaNxbIod/8k2fZzDqzXA8LWZFwIJdZ1y1HI98kD5NAKH9KYB8bLEBsX1wLobjv2Ang= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1594006934; 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=Ple1JdOYV2YiuxuLuNshPT3ATWuNWRUDlZbV1YH2+vM=; b=GSW6yfhWo5uQ6mygkSAAqk+Im3b7/zPVKpGH0ObLULLmGFEtiGkF6g1Gi5y+AuAIS+15npEGfUKNNHNHLKDNaXTw6LM2o2Py/iU3D2c40Z/VONTvO66kHPdfM3aeW/aFXsn9NOI80cPbdQIUNbIISsXWYx760Ny9+uuDq8Z62n0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.61 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 [205.139.110.61]) by mx.zohomail.com with SMTPS id 1594006934314544.4236830861767; Sun, 5 Jul 2020 20:42:14 -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-508-NQ7ttXmOM9KPrlpD4Z1Qsw-1; Sun, 05 Jul 2020 23:42:10 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 24F4F8015FB; Mon, 6 Jul 2020 03:42:05 +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 045B3619B5; Mon, 6 Jul 2020 03:42:05 +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 CB1E987886; Mon, 6 Jul 2020 03:42:04 +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 0663ffs0004410 for ; Sun, 5 Jul 2020 23:41:41 -0400 Received: by smtp.corp.redhat.com (Postfix) id C1A147AC9F; 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 747FB71678 for ; Mon, 6 Jul 2020 03:41:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1594006932; 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=Ple1JdOYV2YiuxuLuNshPT3ATWuNWRUDlZbV1YH2+vM=; b=H9m/29CJlbwX2Ij0QQYH2jtRKTeMzqiwHQNTIM8p7VbE1wQPPUFh1K0whNKK/Ks7iT1RkK uRHDt/DZqUZm58+dDMweUWO6pNXv9b9V/uzrgOCN1TnJmqRefThc/I72xFwdIoRnZY8Oti wqeIgeIojzKu+aTaRxi4xtbyck6OlPo= X-MC-Unique: NQ7ttXmOM9KPrlpD4Z1Qsw-1 From: Laine Stump To: libvir-list@redhat.com Subject: [PATCH 03/32] hyperv: use g_auto() for all virBuffers Date: Sun, 5 Jul 2020 23:40:58 -0400 Message-Id: <20200706034127.1117504-4-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.79 on 10.5.11.12 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/hyperv/hyperv_driver.c | 34 ++++++++++++++++------------------ src/hyperv/hyperv_wmi.c | 11 +++++------ 2 files changed, 21 insertions(+), 24 deletions(-) diff --git a/src/hyperv/hyperv_driver.c b/src/hyperv/hyperv_driver.c index 4677a25ff8..20d372b274 100644 --- a/src/hyperv/hyperv_driver.c +++ b/src/hyperv/hyperv_driver.c @@ -60,7 +60,7 @@ static int hypervInitConnection(virConnectPtr conn, hypervPrivate *priv, char *username, char *password) { - virBuffer query =3D VIR_BUFFER_INITIALIZER; + g_auto(virBuffer) query =3D VIR_BUFFER_INITIALIZER; hypervWqlQuery wqlQuery =3D HYPERV_WQL_QUERY_INITIALIZER; hypervObject *computerSystem =3D NULL; int ret =3D -1; @@ -204,7 +204,7 @@ hypervConnectGetHostname(virConnectPtr conn) { char *hostname =3D NULL; hypervPrivate *priv =3D conn->privateData; - virBuffer query =3D VIR_BUFFER_INITIALIZER; + g_auto(virBuffer) query =3D VIR_BUFFER_INITIALIZER; Win32_ComputerSystem *computerSystem =3D NULL; =20 virBufferAddLit(&query, WIN32_COMPUTERSYSTEM_WQL_SELECT); @@ -234,7 +234,7 @@ hypervNodeGetInfo(virConnectPtr conn, virNodeInfoPtr in= fo) { int result =3D -1; hypervPrivate *priv =3D conn->privateData; - virBuffer query =3D VIR_BUFFER_INITIALIZER; + g_auto(virBuffer) query =3D VIR_BUFFER_INITIALIZER; Win32_ComputerSystem *computerSystem =3D NULL; Win32_Processor *processorList =3D NULL; Win32_Processor *processor =3D NULL; @@ -329,7 +329,7 @@ hypervConnectListDomains(virConnectPtr conn, int *ids, = int maxids) { bool success =3D false; hypervPrivate *priv =3D conn->privateData; - virBuffer query =3D VIR_BUFFER_INITIALIZER; + g_auto(virBuffer) query =3D VIR_BUFFER_INITIALIZER; Msvm_ComputerSystem *computerSystemList =3D NULL; Msvm_ComputerSystem *computerSystem =3D NULL; int count =3D 0; @@ -371,7 +371,7 @@ hypervConnectNumOfDomains(virConnectPtr conn) { bool success =3D false; hypervPrivate *priv =3D conn->privateData; - virBuffer query =3D VIR_BUFFER_INITIALIZER; + g_auto(virBuffer) query =3D VIR_BUFFER_INITIALIZER; Msvm_ComputerSystem *computerSystemList =3D NULL; Msvm_ComputerSystem *computerSystem =3D NULL; int count =3D 0; @@ -407,7 +407,7 @@ hypervDomainLookupByID(virConnectPtr conn, int id) { virDomainPtr domain =3D NULL; hypervPrivate *priv =3D conn->privateData; - virBuffer query =3D VIR_BUFFER_INITIALIZER; + g_auto(virBuffer) query =3D VIR_BUFFER_INITIALIZER; Msvm_ComputerSystem *computerSystem =3D NULL; =20 virBufferAddLit(&query, MSVM_COMPUTERSYSTEM_WQL_SELECT); @@ -439,7 +439,7 @@ hypervDomainLookupByUUID(virConnectPtr conn, const unsi= gned char *uuid) virDomainPtr domain =3D NULL; hypervPrivate *priv =3D conn->privateData; char uuid_string[VIR_UUID_STRING_BUFLEN]; - virBuffer query =3D VIR_BUFFER_INITIALIZER; + g_auto(virBuffer) query =3D VIR_BUFFER_INITIALIZER; Msvm_ComputerSystem *computerSystem =3D NULL; =20 virUUIDFormat(uuid, uuid_string); @@ -473,7 +473,7 @@ hypervDomainLookupByName(virConnectPtr conn, const char= *name) { virDomainPtr domain =3D NULL; hypervPrivate *priv =3D conn->privateData; - virBuffer query =3D VIR_BUFFER_INITIALIZER; + g_auto(virBuffer) query =3D VIR_BUFFER_INITIALIZER; Msvm_ComputerSystem *computerSystem =3D NULL; =20 virBufferAddLit(&query, MSVM_COMPUTERSYSTEM_WQL_SELECT); @@ -612,7 +612,7 @@ hypervDomainGetInfo(virDomainPtr domain, virDomainInfoP= tr info) int result =3D -1; hypervPrivate *priv =3D domain->conn->privateData; char uuid_string[VIR_UUID_STRING_BUFLEN]; - virBuffer query =3D VIR_BUFFER_INITIALIZER; + g_auto(virBuffer) query =3D VIR_BUFFER_INITIALIZER; Msvm_ComputerSystem *computerSystem =3D NULL; Msvm_VirtualSystemSettingData *virtualSystemSettingData =3D NULL; Msvm_ProcessorSettingData *processorSettingData =3D NULL; @@ -746,7 +746,7 @@ hypervDomainGetXMLDesc(virDomainPtr domain, unsigned in= t flags) hypervPrivate *priv =3D domain->conn->privateData; virDomainDefPtr def =3D NULL; char uuid_string[VIR_UUID_STRING_BUFLEN]; - virBuffer query =3D VIR_BUFFER_INITIALIZER; + g_auto(virBuffer) query =3D VIR_BUFFER_INITIALIZER; Msvm_ComputerSystem *computerSystem =3D NULL; Msvm_VirtualSystemSettingData *virtualSystemSettingData =3D NULL; Msvm_ProcessorSettingData *processorSettingData =3D NULL; @@ -851,7 +851,7 @@ hypervDomainGetXMLDesc(virDomainPtr domain, unsigned in= t flags) } else if (priv->wmiVersion =3D=3D HYPERV_WMI_VERSION_V2 && virtualSystemSettingData->data.v2->Notes.data !=3D NULL) { char **notes =3D (char **)virtualSystemSettingData->data.v2->Notes= .data; - virBuffer buf =3D VIR_BUFFER_INITIALIZER; + g_auto(virBuffer) buf =3D VIR_BUFFER_INITIALIZER; size_t i =3D 0; =20 /* in practice Notes has 1 element */ @@ -906,7 +906,7 @@ hypervConnectListDefinedDomains(virConnectPtr conn, cha= r **const names, int maxn { bool success =3D false; hypervPrivate *priv =3D conn->privateData; - virBuffer query =3D VIR_BUFFER_INITIALIZER; + g_auto(virBuffer) query =3D VIR_BUFFER_INITIALIZER; Msvm_ComputerSystem *computerSystemList =3D NULL; Msvm_ComputerSystem *computerSystem =3D NULL; int count =3D 0; @@ -958,7 +958,7 @@ hypervConnectNumOfDefinedDomains(virConnectPtr conn) { bool success =3D false; hypervPrivate *priv =3D conn->privateData; - virBuffer query =3D VIR_BUFFER_INITIALIZER; + g_auto(virBuffer) query =3D VIR_BUFFER_INITIALIZER; Msvm_ComputerSystem *computerSystemList =3D NULL; Msvm_ComputerSystem *computerSystem =3D NULL; int count =3D 0; @@ -1198,7 +1198,7 @@ hypervConnectListAllDomains(virConnectPtr conn, unsigned int flags) { hypervPrivate *priv =3D conn->privateData; - virBuffer query =3D VIR_BUFFER_INITIALIZER; + g_auto(virBuffer) query =3D VIR_BUFFER_INITIALIZER; Msvm_ComputerSystem *computerSystemList =3D NULL; Msvm_ComputerSystem *computerSystem =3D NULL; size_t ndoms; @@ -1336,7 +1336,7 @@ hypervDomainSendKey(virDomainPtr domain, unsigned int= codeset, char *selector =3D NULL; Msvm_ComputerSystem *computerSystem =3D NULL; Msvm_Keyboard *keyboard =3D NULL; - virBuffer query =3D VIR_BUFFER_INITIALIZER; + g_auto(virBuffer) query =3D VIR_BUFFER_INITIALIZER; hypervInvokeParamsListPtr params =3D NULL; char keycodeStr[VIR_INT64_STR_BUFLEN]; =20 @@ -1437,7 +1437,6 @@ hypervDomainSendKey(virDomainPtr domain, unsigned int= codeset, VIR_FREE(selector); hypervFreeObject(priv, (hypervObject *)keyboard); hypervFreeObject(priv, (hypervObject *)computerSystem); - virBufferFreeAndReset(&query); return result; } =20 @@ -1454,7 +1453,7 @@ hypervDomainSetMemoryFlags(virDomainPtr domain, unsig= ned long memory, unsigned long memory_mb =3D VIR_ROUND_UP(VIR_DIV_UP(memory, 1024), 2); Msvm_VirtualSystemSettingData *vssd =3D NULL; Msvm_MemorySettingData *memsd =3D NULL; - virBuffer eprQuery =3D VIR_BUFFER_INITIALIZER; + g_auto(virBuffer) eprQuery =3D VIR_BUFFER_INITIALIZER; virHashTablePtr memResource =3D NULL; =20 virCheckFlags(0, -1); @@ -1537,7 +1536,6 @@ hypervDomainSetMemoryFlags(virDomainPtr domain, unsig= ned long memory, =20 params_cleanup: hypervFreeInvokeParams(params); - virBufferFreeAndReset(&eprQuery); cleanup: VIR_FREE(memory_str); hypervFreeObject(priv, (hypervObject *)vssd); diff --git a/src/hyperv/hyperv_wmi.c b/src/hyperv/hyperv_wmi.c index ca2d29733e..f8d0aaf373 100644 --- a/src/hyperv/hyperv_wmi.c +++ b/src/hyperv/hyperv_wmi.c @@ -778,7 +778,7 @@ hypervInvokeMethod(hypervPrivate *priv, hypervInvokePar= amsListPtr params, char *returnValue =3D NULL; char *instanceID =3D NULL; bool completed =3D false; - virBuffer query =3D VIR_BUFFER_INITIALIZER; + g_auto(virBuffer) query =3D VIR_BUFFER_INITIALIZER; Msvm_ConcreteJob *job =3D NULL; int jobState =3D -1; hypervParamPtr p =3D NULL; @@ -939,7 +939,6 @@ hypervInvokeMethod(hypervPrivate *priv, hypervInvokePar= amsListPtr params, VIR_FREE(jobcode_instance_xpath); VIR_FREE(returnValue); VIR_FREE(instanceID); - virBufferFreeAndReset(&query); hypervFreeObject(priv, (hypervObject *)job); hypervFreeInvokeParams(params); return result; @@ -1314,7 +1313,7 @@ hypervInvokeMsvmComputerSystemRequestStateChange(virD= omainPtr domain, char *returnValue =3D NULL; int returnCode; char *instanceID =3D NULL; - virBuffer query =3D VIR_BUFFER_INITIALIZER; + g_auto(virBuffer) query =3D VIR_BUFFER_INITIALIZER; Msvm_ConcreteJob *concreteJob =3D NULL; bool completed =3D false; const char *resourceUri =3D MSVM_COMPUTERSYSTEM_V2_RESOURCE_URI; @@ -1553,7 +1552,7 @@ hypervMsvmComputerSystemFromDomain(virDomainPtr domai= n, { hypervPrivate *priv =3D domain->conn->privateData; char uuid_string[VIR_UUID_STRING_BUFLEN]; - virBuffer query =3D VIR_BUFFER_INITIALIZER; + g_auto(virBuffer) query =3D VIR_BUFFER_INITIALIZER; =20 if (computerSystem =3D=3D NULL || *computerSystem !=3D NULL) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Invalid argument")= ); @@ -1588,7 +1587,7 @@ int hypervGetMsvmVirtualSystemSettingDataFromUUID(hypervPrivate *priv, const char *uuid_string, Msvm_VirtualSystemSettingData **list) { - virBuffer query =3D VIR_BUFFER_INITIALIZER; + g_auto(virBuffer) query =3D VIR_BUFFER_INITIALIZER; =20 virBufferAsprintf(&query, "associators of " @@ -1614,7 +1613,7 @@ int hypervGetMsvmMemorySettingDataFromVSSD(hypervPrivate *priv, const char *vssd_instanceid, Msvm_MemorySettingData **list) { - virBuffer query =3D VIR_BUFFER_INITIALIZER; + g_auto(virBuffer) query =3D VIR_BUFFER_INITIALIZER; =20 virBufferAsprintf(&query, "associators of " --=20 2.25.4 From nobody Mon May 6 01:10:47 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 205.139.110.120 as permitted sender) client-ip=205.139.110.120; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.120 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=1594006934; cv=none; d=zohomail.com; s=zohoarc; b=G5mpYKV5oGPPYtBGjQGmg00OgJQn5KP2nRiS+Au8/M+l7g5qBHRxsI5YIyuWuk3Z/OKt4BT0EYMbWDRdzLAW4ok2fW8hvlzDVrUFqA+AhpNyj1OWk5ZrrFXxzfTKTIMEH/J6qqfsL22yNMVpH9bNYtWNpD+agM68sCoC/yMhdxk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1594006934; 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=M4Yj8Fd+5VDcIay3RVXVGVx6HwjVI8fo9fNR6t+in1Y=; b=QIbwVQlMNPnmf8Y7JU/j7olRgnjXSoe0e/l+SNuG7Oql7C/ySoV/nzYk5FaHL0OuOfE1Z/rFCiBrpz+YpLzohmMrRb91smYGC289eGIuqxJQuOLWOhDFJWaa5MSU1jbSrdEZLlBKXv9JMcbG+Ex0iBitwkxr8g+XRG1IVCkr+60= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.120 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-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) by mx.zohomail.com with SMTPS id 15940069341704.336823878937594; Sun, 5 Jul 2020 20:42:14 -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-18-uK1SNaQsPXermGJ-5RiShw-1; Sun, 05 Jul 2020 23:42:10 -0400 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 3D572108BD0D; Mon, 6 Jul 2020 03:42:05 +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 1AB67CF94F; Mon, 6 Jul 2020 03:42:05 +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 E10C41800433; Mon, 6 Jul 2020 03:42:04 +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 0663fgk2004426 for ; Sun, 5 Jul 2020 23:41:42 -0400 Received: by smtp.corp.redhat.com (Postfix) id 4741971678; Mon, 6 Jul 2020 03:41:42 +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 F14B9275E20 for ; Mon, 6 Jul 2020 03:41:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1594006933; 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=M4Yj8Fd+5VDcIay3RVXVGVx6HwjVI8fo9fNR6t+in1Y=; b=XlnYqPy3cKMoUyHCAozpGBQO7f1GDtKZX8OHNcGIjWhq/MkzIg/mOAEdOhYQCvGRzm93nw 1H4yJgMjNUF2pot0W8CJ3IdehVZDSX615K+XKXL+JfNxF8ScPtKII+q80oPddnQU7APw25 x/oWfGirCwYUmY8PK1s+TMjIXM0Bqcc= X-MC-Unique: uK1SNaQsPXermGJ-5RiShw-1 From: Laine Stump To: libvir-list@redhat.com Subject: [PATCH 04/32] libxl: use g_auto() for all virBuffers Date: Sun, 5 Jul 2020 23:40:59 -0400 Message-Id: <20200706034127.1117504-5-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.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-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/libxl/libxl_conf.c | 6 ++---- src/libxl/libxl_driver.c | 2 +- src/libxl/libxl_migration.c | 2 +- src/libxl/xen_common.c | 12 +++++------- src/libxl/xen_xl.c | 19 +++++++------------ src/libxl/xen_xm.c | 3 +-- 6 files changed, 17 insertions(+), 27 deletions(-) diff --git a/src/libxl/libxl_conf.c b/src/libxl/libxl_conf.c index a0059fc2a7..124e08d598 100644 --- a/src/libxl/libxl_conf.c +++ b/src/libxl/libxl_conf.c @@ -911,7 +911,7 @@ libxlMakeNetworkDiskSrcStr(virStorageSourcePtr src, const char *secret) { char *ret =3D NULL; - virBuffer buf =3D VIR_BUFFER_INITIALIZER; + g_auto(virBuffer) buf =3D VIR_BUFFER_INITIALIZER; size_t i; =20 switch ((virStorageNetProtocol) src->protocol) { @@ -978,7 +978,6 @@ libxlMakeNetworkDiskSrcStr(virStorageSourcePtr src, } =20 cleanup: - virBufferFreeAndReset(&buf); return ret; } =20 @@ -1241,7 +1240,7 @@ libxlMakeNic(virDomainDefPtr def, const virNetDevBandwidth *actual_bw; const virNetDevVPortProfile *port_profile; const virNetDevVlan *virt_vlan; - virBuffer buf =3D VIR_BUFFER_INITIALIZER; + g_auto(virBuffer) buf =3D VIR_BUFFER_INITIALIZER; size_t i; const char *script =3D NULL; int ret =3D -1; @@ -1434,7 +1433,6 @@ libxlMakeNic(virDomainDefPtr def, ret =3D 0; =20 cleanup: - virBufferFreeAndReset(&buf); virObjectUnref(network); virObjectUnref(conn); =20 diff --git a/src/libxl/libxl_driver.c b/src/libxl/libxl_driver.c index a80bc3fe3a..9b9713df2c 100644 --- a/src/libxl/libxl_driver.c +++ b/src/libxl/libxl_driver.c @@ -942,7 +942,7 @@ static char * libxlConnectGetSysinfo(virConnectPtr conn, unsigned int flags) { libxlDriverPrivatePtr driver =3D conn->privateData; - virBuffer buf =3D VIR_BUFFER_INITIALIZER; + g_auto(virBuffer) buf =3D VIR_BUFFER_INITIALIZER; =20 virCheckFlags(0, NULL); =20 diff --git a/src/libxl/libxl_migration.c b/src/libxl/libxl_migration.c index 9d253346eb..87cd5337ba 100644 --- a/src/libxl/libxl_migration.c +++ b/src/libxl/libxl_migration.c @@ -117,7 +117,7 @@ libxlMigrationBakeCookie(libxlMigrationCookiePtr mig, char **cookieout, int *cookieoutlen) { - virBuffer buf =3D VIR_BUFFER_INITIALIZER; + g_auto(virBuffer) buf =3D VIR_BUFFER_INITIALIZER; char uuidstr[VIR_UUID_STRING_BUFLEN]; =20 if (!cookieout || !cookieoutlen) diff --git a/src/libxl/xen_common.c b/src/libxl/xen_common.c index 5c37e431eb..6b16752c8a 100644 --- a/src/libxl/xen_common.c +++ b/src/libxl/xen_common.c @@ -1633,7 +1633,7 @@ xenFormatSxprChr(virDomainChrDefPtr def, static int xenFormatSerial(virConfValuePtr list, virDomainChrDefPtr serial) { - virBuffer buf =3D VIR_BUFFER_INITIALIZER; + g_auto(virBuffer) buf =3D VIR_BUFFER_INITIALIZER; virConfValuePtr val, tmp; int ret; =20 @@ -1661,7 +1661,6 @@ xenFormatSerial(virConfValuePtr list, virDomainChrDef= Ptr serial) return 0; =20 cleanup: - virBufferFreeAndReset(&buf); return -1; } =20 @@ -1694,7 +1693,7 @@ xenFormatNet(virConnectPtr conn, int hvm, const char *vif_typename) { - virBuffer buf =3D VIR_BUFFER_INITIALIZER; + g_auto(virBuffer) buf =3D VIR_BUFFER_INITIALIZER; virConfValuePtr val, tmp; char macaddr[VIR_MAC_STRING_BUFLEN]; =20 @@ -1826,7 +1825,6 @@ xenFormatNet(virConnectPtr conn, return 0; =20 cleanup: - virBufferFreeAndReset(&buf); return -1; } =20 @@ -2034,7 +2032,7 @@ xenFormatCharDev(virConfPtr conf, virDomainDefPtr def, =20 if (def->os.type =3D=3D VIR_DOMAIN_OSTYPE_HVM) { if (def->nparallels) { - virBuffer buf =3D VIR_BUFFER_INITIALIZER; + g_auto(virBuffer) buf =3D VIR_BUFFER_INITIALIZER; char *str; int ret; =20 @@ -2052,7 +2050,7 @@ xenFormatCharDev(virConfPtr conf, virDomainDefPtr def, =20 if (def->nserials) { if ((def->nserials =3D=3D 1) && (def->serials[0]->target.port = =3D=3D 0)) { - virBuffer buf =3D VIR_BUFFER_INITIALIZER; + g_auto(virBuffer) buf =3D VIR_BUFFER_INITIALIZER; char *str; int ret; =20 @@ -2329,7 +2327,7 @@ xenFormatVfb(virConfPtr conf, virDomainDefPtr def) } else { virConfValuePtr vfb, disp; char *vfbstr =3D NULL; - virBuffer buf =3D VIR_BUFFER_INITIALIZER; + g_auto(virBuffer) buf =3D VIR_BUFFER_INITIALIZER; =20 if (def->graphics[0]->type =3D=3D VIR_DOMAIN_GRAPHICS_TYPE_SDL= ) { virBufferAddLit(&buf, "type=3Dsdl"); diff --git a/src/libxl/xen_xl.c b/src/libxl/xen_xl.c index d40c2e1d8e..ec5e4791a3 100644 --- a/src/libxl/xen_xl.c +++ b/src/libxl/xen_xl.c @@ -1445,7 +1445,7 @@ xenFormatXLVnuma(virConfValuePtr list, int ret =3D -1; size_t i; =20 - virBuffer buf =3D VIR_BUFFER_INITIALIZER; + g_auto(virBuffer) buf =3D VIR_BUFFER_INITIALIZER; virConfValuePtr numaVnode, tmp; =20 size_t nodeSize =3D virDomainNumaGetNodeMemorySize(numa, node) / 1024; @@ -1563,7 +1563,7 @@ static char * xenFormatXLDiskSrcNet(virStorageSourcePtr src) { char *ret =3D NULL; - virBuffer buf =3D VIR_BUFFER_INITIALIZER; + g_auto(virBuffer) buf =3D VIR_BUFFER_INITIALIZER; size_t i; =20 switch ((virStorageNetProtocol) src->protocol) { @@ -1620,8 +1620,6 @@ xenFormatXLDiskSrcNet(virStorageSourcePtr src) } =20 cleanup: - virBufferFreeAndReset(&buf); - return ret; } =20 @@ -1662,7 +1660,7 @@ xenFormatXLDiskSrc(virStorageSourcePtr src, char **sr= cstr) static int xenFormatXLDisk(virConfValuePtr list, virDomainDiskDefPtr disk) { - virBuffer buf =3D VIR_BUFFER_INITIALIZER; + g_auto(virBuffer) buf =3D VIR_BUFFER_INITIALIZER; virConfValuePtr val, tmp; int format =3D virDomainDiskGetFormat(disk); const char *driver =3D virDomainDiskGetDriver(disk); @@ -1754,7 +1752,6 @@ xenFormatXLDisk(virConfValuePtr list, virDomainDiskDe= fPtr disk) =20 cleanup: VIR_FREE(target); - virBufferFreeAndReset(&buf); return ret; } =20 @@ -1976,7 +1973,7 @@ xenFormatXLUSBController(virConfPtr conf, for (i =3D 0; i < def->ncontrollers; i++) { if (def->controllers[i]->type =3D=3D VIR_DOMAIN_CONTROLLER_TYPE_US= B) { virConfValuePtr val, tmp; - virBuffer buf =3D VIR_BUFFER_INITIALIZER; + g_auto(virBuffer) buf =3D VIR_BUFFER_INITIALIZER; =20 if (def->controllers[i]->model !=3D -1) { switch (def->controllers[i]->model) { @@ -1997,10 +1994,9 @@ xenFormatXLUSBController(virConfPtr conf, virBufferAsprintf(&buf, "ports=3D%x", def->controllers[i]->opts.usbopts.ports); =20 - if (VIR_ALLOC(val) < 0) { - virBufferFreeAndReset(&buf); + if (VIR_ALLOC(val) < 0) goto error; - } + val->type =3D VIR_CONF_STRING; val->str =3D virBufferContentAndReset(&buf); tmp =3D usbctrlVal->list; @@ -2098,7 +2094,7 @@ xenFormatXLUSB(virConfPtr conf, static int xenFormatXLChannel(virConfValuePtr list, virDomainChrDefPtr channel) { - virBuffer buf =3D VIR_BUFFER_INITIALIZER; + g_auto(virBuffer) buf =3D VIR_BUFFER_INITIALIZER; int sourceType =3D channel->source->type; virConfValuePtr val, tmp; =20 @@ -2137,7 +2133,6 @@ xenFormatXLChannel(virConfValuePtr list, virDomainChr= DefPtr channel) return 0; =20 cleanup: - virBufferFreeAndReset(&buf); return -1; } =20 diff --git a/src/libxl/xen_xm.c b/src/libxl/xen_xm.c index 3883725efc..f28326ade8 100644 --- a/src/libxl/xen_xm.c +++ b/src/libxl/xen_xm.c @@ -290,7 +290,7 @@ static int xenFormatXMDisk(virConfValuePtr list, virDomainDiskDefPtr disk) { - virBuffer buf =3D VIR_BUFFER_INITIALIZER; + g_auto(virBuffer) buf =3D VIR_BUFFER_INITIALIZER; virConfValuePtr val, tmp; const char *src =3D virDomainDiskGetSource(disk); int format =3D virDomainDiskGetFormat(disk); @@ -361,7 +361,6 @@ xenFormatXMDisk(virConfValuePtr list, return 0; =20 cleanup: - virBufferFreeAndReset(&buf); return -1; } =20 --=20 2.25.4 From nobody Mon May 6 01:10:47 2024 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=1594006987; cv=none; d=zohomail.com; s=zohoarc; b=VK6JFEEE3tO9hHM1DdoZxPqj82ZBu0EBf2rsydEIRw0oFDRLpeROTVW1PqWPvciW34cSuSSlFa6Fw1G/V/L/GgoGrBl+38VBhFqq2wYkMvXXYZpXy6T6M27aJmKSzcd/3pnF9armCdRliCuH5Uq7ttuLEN3YmZqUlZVaouwTttU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1594006987; 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=CuST70lRm+1QIXjMCpbzkvJEzhH83v2hWC7Ivmh/5Oc=; b=Wcs3btHAcCI61Rw0kRkUiiSJ4kgklCohBwIlv9uCWR/uhfSAA6dWUjhIW1+075yqEOJhwSl8er0arQCAjeiPVJ1Wm6cPJKp6VBcViJAQ4+7PnzqCHoWJzKP+ONIvD0F+ViUHMDdL9GogVAUF+av+icJJjwgs748Tu5VY/vEYYpk= 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 1594006987832497.6444180468503; Sun, 5 Jul 2020 20:43:07 -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-358-KEqTFFMoNr-LEDDdnoTi2w-1; Sun, 05 Jul 2020 23:42:14 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 6B26C1007B16; Mon, 6 Jul 2020 03:42:09 +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 4AB2C28550; Mon, 6 Jul 2020 03:42:09 +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 18A06180043C; Mon, 6 Jul 2020 03:42:09 +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 0663fgr1004433 for ; Sun, 5 Jul 2020 23:41:42 -0400 Received: by smtp.corp.redhat.com (Postfix) id C073571678; Mon, 6 Jul 2020 03:41:42 +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 763DC275E25 for ; Mon, 6 Jul 2020 03:41:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1594006986; 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=CuST70lRm+1QIXjMCpbzkvJEzhH83v2hWC7Ivmh/5Oc=; b=gr7w8j9U/yIHRQR90JoecA2+aRzVdCCqy4pPWf4KNLQm+w2bdFANfrDG2pgPMkwktq1T42 s7l+OfDs4NIwgpH1xMyO0xlLPyIGCOUATDoA4MbJUYw7nUYcNLHgZYZ7xu94svI0UyFdWF FdHel1ANWHTz1sskpanVhBKk4pTxLLw= X-MC-Unique: KEqTFFMoNr-LEDDdnoTi2w-1 From: Laine Stump To: libvir-list@redhat.com Subject: [PATCH 05/32] lxc: use g_auto() for all virBuffers Date: Sun, 5 Jul 2020 23:41:00 -0400 Message-Id: <20200706034127.1117504-6-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.23 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/lxc/lxc_container.c | 4 +--- src/lxc/lxc_controller.c | 3 +-- src/lxc/lxc_driver.c | 2 +- src/lxc/lxc_fuse.c | 3 +-- 4 files changed, 4 insertions(+), 8 deletions(-) diff --git a/src/lxc/lxc_container.c b/src/lxc/lxc_container.c index c22b7b0709..24a3b6d626 100644 --- a/src/lxc/lxc_container.c +++ b/src/lxc/lxc_container.c @@ -174,7 +174,7 @@ static virCommandPtr lxcContainerBuildInitCmd(virDomain= DefPtr vmDef, { char uuidstr[VIR_UUID_STRING_BUFLEN]; virCommandPtr cmd; - virBuffer buf =3D VIR_BUFFER_INITIALIZER; + g_auto(virBuffer) buf =3D VIR_BUFFER_INITIALIZER; size_t i; =20 /* 'container_ptys' must exclude the PTY associated with @@ -185,7 +185,6 @@ static virCommandPtr lxcContainerBuildInitCmd(virDomain= DefPtr vmDef, virReportError(VIR_ERR_INTERNAL_ERROR, _("Expected a /dev path for '%s'"), ttyPaths[i]); - virBufferFreeAndReset(&buf); return NULL; } virBufferAdd(&buf, ttyPaths[i] + 5, -1); @@ -219,7 +218,6 @@ static virCommandPtr lxcContainerBuildInitCmd(virDomain= DefPtr vmDef, vmDef->os.initenv[i]->value); } =20 - virBufferFreeAndReset(&buf); return cmd; } =20 diff --git a/src/lxc/lxc_controller.c b/src/lxc/lxc_controller.c index 89f9773b2c..01cdeb29db 100644 --- a/src/lxc/lxc_controller.c +++ b/src/lxc/lxc_controller.c @@ -1378,7 +1378,7 @@ virLXCControllerSetupUsernsMap(virDomainIdMapEntryPtr= map, int num, char *path) { - virBuffer map_value =3D VIR_BUFFER_INITIALIZER; + g_auto(virBuffer) map_value =3D VIR_BUFFER_INITIALIZER; size_t i; int ret =3D -1; =20 @@ -1402,7 +1402,6 @@ virLXCControllerSetupUsernsMap(virDomainIdMapEntryPtr= map, =20 ret =3D 0; cleanup: - virBufferFreeAndReset(&map_value); return ret; } =20 diff --git a/src/lxc/lxc_driver.c b/src/lxc/lxc_driver.c index 46a182be45..1cdd6ee455 100644 --- a/src/lxc/lxc_driver.c +++ b/src/lxc/lxc_driver.c @@ -4618,7 +4618,7 @@ static char * lxcConnectGetSysinfo(virConnectPtr conn, unsigned int flags) { virLXCDriverPtr driver =3D conn->privateData; - virBuffer buf =3D VIR_BUFFER_INITIALIZER; + g_auto(virBuffer) buf =3D VIR_BUFFER_INITIALIZER; =20 virCheckFlags(0, NULL); =20 diff --git a/src/lxc/lxc_fuse.c b/src/lxc/lxc_fuse.c index 146629f67e..6e23361617 100644 --- a/src/lxc/lxc_fuse.c +++ b/src/lxc/lxc_fuse.c @@ -124,7 +124,7 @@ static int lxcProcReadMeminfo(char *hostpath, virDomain= DefPtr def, g_autofree char *line =3D NULL; size_t n; struct virLXCMeminfo meminfo; - virBuffer buffer =3D VIR_BUFFER_INITIALIZER; + g_auto(virBuffer) buffer =3D VIR_BUFFER_INITIALIZER; virBufferPtr new_meminfo =3D &buffer; =20 if (virLXCCgroupGetMeminfo(&meminfo) < 0) { @@ -223,7 +223,6 @@ static int lxcProcReadMeminfo(char *hostpath, virDomain= DefPtr def, memcpy(buf, virBufferCurrentContent(new_meminfo), res); =20 cleanup: - virBufferFreeAndReset(new_meminfo); VIR_FORCE_FCLOSE(fd); return res; } --=20 2.25.4 From nobody Mon May 6 01:10:47 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 207.211.31.120 as permitted sender) client-ip=207.211.31.120; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.120 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=1594006990; cv=none; d=zohomail.com; s=zohoarc; b=Hsjo43Y2btRv0MR0NLE/v/hvAJRSW4fGUKmPVc4gJZnjQOycb10Ld+xjyGOgLIuX5M7OLWmpOsFKHiXRLXv8EhyzNUxe2FfC8OGVQ2JfdamQe7Zh+toP6yHnrSnf4Nlk240YKkZOw2MxTxfQRQbegqEr/sMagSE/IeIOcFqDcJ8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1594006990; 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=g0oWWQwqOmGTca1oXJLL66PnWYxyW4IIw+wCOteall8=; b=FhUsA9FbkYXFXE0PvyHO4GtfeYhwoNmg+aLD9MnMnE9rB25kqPA5tP4aah2SVeIgT3gGCuE66VxB5j5+hppsxKTZL880ojWSx/unNVAD6VMRI+Fu9oWEpCaoWAX1R9Qvu91pmjTqQPIAE63YmT/nQKWmvWvdyZj01OoC0FIAtaU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.120 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-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) by mx.zohomail.com with SMTPS id 1594006990557774.4813924310273; Sun, 5 Jul 2020 20:43:10 -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-246-RhdAro2kPkOnzRKuPbjXgw-1; Sun, 05 Jul 2020 23:42:15 -0400 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 7B35918CA277; Mon, 6 Jul 2020 03:42:09 +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 4A1645D9D7; Mon, 6 Jul 2020 03:42:09 +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 1B211180043D; Mon, 6 Jul 2020 03:42:09 +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 0663fhOL004438 for ; Sun, 5 Jul 2020 23:41:43 -0400 Received: by smtp.corp.redhat.com (Postfix) id 462237AC9F; Mon, 6 Jul 2020 03:41:43 +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 F05E971678 for ; Mon, 6 Jul 2020 03:41:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1594006989; 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=g0oWWQwqOmGTca1oXJLL66PnWYxyW4IIw+wCOteall8=; b=CM4N+J1gfAKNxnWX+Yd3bW719oTt2lvcE+vgky+X5SDZcL1MQP9VowK5WKaWkYP5KecMsy 8OHR5u8E5HI/FFj1QsmKheqwYkxO4DSFY9L9FDhVyM1/E0qCA1Sh7DGcj72Q5x2nbLM0RX 5gGb4a9NYK/wI7BbnnWqG7939swMRQY= X-MC-Unique: RhdAro2kPkOnzRKuPbjXgw-1 From: Laine Stump To: libvir-list@redhat.com Subject: [PATCH 06/32] qemu: use g_auto() for all virBuffers Date: Sun, 5 Jul 2020 23:41:01 -0400 Message-Id: <20200706034127.1117504-7-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.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) Content-Type: text/plain; charset="utf-8" Signed-off-by: Laine Stump Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_agent.c | 2 +- src/qemu/qemu_block.c | 2 +- src/qemu/qemu_capabilities.c | 2 +- src/qemu/qemu_command.c | 4 ++-- src/qemu/qemu_dbus.c | 2 +- src/qemu/qemu_domain.c | 4 ++-- src/qemu/qemu_driver.c | 5 ++--- src/qemu/qemu_migration.c | 2 +- src/qemu/qemu_migration_cookie.c | 6 ++---- src/qemu/qemu_monitor.c | 2 +- 10 files changed, 14 insertions(+), 17 deletions(-) diff --git a/src/qemu/qemu_agent.c b/src/qemu/qemu_agent.c index 6fa48c06e3..37b5451e33 100644 --- a/src/qemu/qemu_agent.c +++ b/src/qemu/qemu_agent.c @@ -155,7 +155,7 @@ static char * qemuAgentEscapeNonPrintable(const char *text) { size_t i; - virBuffer buf =3D VIR_BUFFER_INITIALIZER; + g_auto(virBuffer) buf =3D VIR_BUFFER_INITIALIZER; for (i =3D 0; text[i] !=3D '\0'; i++) { if (text[i] =3D=3D '\\') virBufferAddLit(&buf, "\\\\"); diff --git a/src/qemu/qemu_block.c b/src/qemu/qemu_block.c index b00694c96f..a727366373 100644 --- a/src/qemu/qemu_block.c +++ b/src/qemu/qemu_block.c @@ -3271,7 +3271,7 @@ qemuBlockStorageSourceNeedsStorageSliceLayer(const vi= rStorageSource *src) char * qemuBlockStorageSourceGetCookieString(virStorageSourcePtr src) { - virBuffer buf =3D VIR_BUFFER_INITIALIZER; + g_auto(virBuffer) buf =3D VIR_BUFFER_INITIALIZER; size_t i; =20 for (i =3D 0; i < src->ncookies; i++) { diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index efc42aac17..0cf9165ecc 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -4602,7 +4602,7 @@ virQEMUCapsFormatSEVInfo(virQEMUCapsPtr qemuCaps, vir= BufferPtr buf) char * virQEMUCapsFormatCache(virQEMUCapsPtr qemuCaps) { - virBuffer buf =3D VIR_BUFFER_INITIALIZER; + g_auto(virBuffer) buf =3D VIR_BUFFER_INITIALIZER; size_t i; =20 virBufferAddLit(&buf, "\n"); diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 6e7fd59561..789c5b8f56 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -5477,7 +5477,7 @@ qemuBuildRNGCommandLine(virLogManagerPtr logManager, =20 for (i =3D 0; i < def->nrngs; i++) { g_autoptr(virJSONValue) props =3D NULL; - virBuffer buf =3D VIR_BUFFER_INITIALIZER; + g_auto(virBuffer) buf =3D VIR_BUFFER_INITIALIZER; virDomainRNGDefPtr rng =3D def->rngs[i]; g_autofree char *chardev =3D NULL; g_autofree char *devstr =3D NULL; @@ -6155,7 +6155,7 @@ qemuBuildBootCommandLine(virCommandPtr cmd, if (def->os.dtb) virCommandAddArgList(cmd, "-dtb", def->os.dtb, NULL); if (def->os.slic_table) { - virBuffer buf =3D VIR_BUFFER_INITIALIZER; + g_auto(virBuffer) buf =3D VIR_BUFFER_INITIALIZER; virCommandAddArg(cmd, "-acpitable"); virBufferAddLit(&buf, "sig=3DSLIC,file=3D"); virQEMUBuildBufferEscapeComma(&buf, def->os.slic_table); diff --git a/src/qemu/qemu_dbus.c b/src/qemu/qemu_dbus.c index 53f6c45986..51f6c94e3e 100644 --- a/src/qemu/qemu_dbus.c +++ b/src/qemu/qemu_dbus.c @@ -100,7 +100,7 @@ qemuDBusGetAddress(virQEMUDriverPtr driver, static int qemuDBusWriteConfig(const char *filename, const char *path) { - virBuffer buf =3D VIR_BUFFER_INITIALIZER; + g_auto(virBuffer) buf =3D VIR_BUFFER_INITIALIZER; g_autofree char *config =3D NULL; =20 virBufferAddLit(&buf, "deviceType !=3D VIR_DOMAIN_CHR_DEVICE_TYPE_CHANNEL || @@ -6001,7 +6001,7 @@ qemuDomainDefFormatXMLInternal(virQEMUDriverPtr drive= r, virCPUDefPtr origCPU, unsigned int flags) { - virBuffer buf =3D VIR_BUFFER_INITIALIZER; + g_auto(virBuffer) buf =3D VIR_BUFFER_INITIALIZER; =20 if (qemuDomainDefFormatBufInternal(driver, qemuCaps, def, origCPU, fla= gs, &buf) < 0) return NULL; diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index a5b38b3d24..247baa9b8d 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -1272,7 +1272,7 @@ static char * qemuConnectGetSysinfo(virConnectPtr conn, unsigned int flags) { virQEMUDriverPtr driver =3D conn->privateData; - virBuffer buf =3D VIR_BUFFER_INITIALIZER; + g_auto(virBuffer) buf =3D VIR_BUFFER_INITIALIZER; =20 virCheckFlags(0, NULL); =20 @@ -14398,7 +14398,7 @@ qemuDomainSnapshotCreateInactiveExternal(virQEMUDri= verPtr driver, virBitmapPtr created =3D NULL; g_autoptr(virQEMUDriverConfig) cfg =3D virQEMUDriverGetConfig(driver); int ret =3D -1; - virBuffer buf =3D VIR_BUFFER_INITIALIZER; + g_auto(virBuffer) buf =3D VIR_BUFFER_INITIALIZER; virDomainSnapshotDefPtr snapdef =3D virDomainSnapshotObjGetDef(snap); =20 if (!(qemuImgPath =3D qemuFindQemuImgBinary(driver))) @@ -14485,7 +14485,6 @@ qemuDomainSnapshotCreateInactiveExternal(virQEMUDri= verPtr driver, ret =3D 0; =20 cleanup: - virBufferFreeAndReset(&buf); virCommandFree(cmd); =20 /* unlink images if creation has failed */ diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c index 13427c1203..b7dbadb728 100644 --- a/src/qemu/qemu_migration.c +++ b/src/qemu/qemu_migration.c @@ -178,7 +178,7 @@ qemuMigrationDstPrecreateDisk(virConnectPtr conn, virStorageVolPtr vol =3D NULL; char *volName =3D NULL, *basePath =3D NULL; char *volStr =3D NULL; - virBuffer buf =3D VIR_BUFFER_INITIALIZER; + g_auto(virBuffer) buf =3D VIR_BUFFER_INITIALIZER; const char *format =3D NULL; unsigned int flags =3D 0; =20 diff --git a/src/qemu/qemu_migration_cookie.c b/src/qemu/qemu_migration_coo= kie.c index fb8b5bcd92..2e48d1b524 100644 --- a/src/qemu/qemu_migration_cookie.c +++ b/src/qemu/qemu_migration_cookie.c @@ -869,12 +869,10 @@ qemuMigrationCookieXMLFormatStr(virQEMUDriverPtr driv= er, virQEMUCapsPtr qemuCaps, qemuMigrationCookiePtr mig) { - virBuffer buf =3D VIR_BUFFER_INITIALIZER; + g_auto(virBuffer) buf =3D VIR_BUFFER_INITIALIZER; =20 - if (qemuMigrationCookieXMLFormat(driver, qemuCaps, &buf, mig) < 0) { - virBufferFreeAndReset(&buf); + if (qemuMigrationCookieXMLFormat(driver, qemuCaps, &buf, mig) < 0) return NULL; - } =20 return virBufferContentAndReset(&buf); } diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c index 5033cbeabf..157ebb43e8 100644 --- a/src/qemu/qemu_monitor.c +++ b/src/qemu/qemu_monitor.c @@ -203,7 +203,7 @@ static char * qemuMonitorEscapeNonPrintable(const char *text) { size_t i; - virBuffer buf =3D VIR_BUFFER_INITIALIZER; + g_auto(virBuffer) buf =3D VIR_BUFFER_INITIALIZER; for (i =3D 0; text[i] !=3D '\0'; i++) { if (g_ascii_isprint(text[i]) || text[i] =3D=3D '\n' || --=20 2.25.4 From nobody Mon May 6 01:10:47 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 205.139.110.120 as permitted sender) client-ip=205.139.110.120; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.120 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=1594006943; cv=none; d=zohomail.com; s=zohoarc; b=AFbJuQeHC/G3av9vhWw4sv/d7ocKecKEpiZN5gDtNY5bS24ENMfJITtdosaHO8pCHoXeI6Q2td4Tv9WcVSVEtT5yhtVy9/oHH6NJCpmemYkys4WU7pOyGVT8XJl10J7QgYhrcETD+h/4OaM9eACkG4YLzgAG240vWVi/qY1xw34= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1594006943; 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=HF7hzNhB0mnRb2SnEgtCksc90l+FY2gD6sKrl3JmcI8=; b=mZNV/r5TB5i7pfyv4NjDTrguEBFeXc5RvWV4rcfaZH4O4xOyeds8ufqllPFcSGqrHNs+YOfWyZCILgHxa2jzHX1MqvX8DP14QAjdjQIIpebaLaL7/moeWdzv1eBX1uuUrw/Vlj0y1Y89LHlFEOcE26zNkkYXrPsu1qwiY0wR+sY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.120 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-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) by mx.zohomail.com with SMTPS id 1594006943176274.46635104923234; Sun, 5 Jul 2020 20:42:23 -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-160-SjOwkI-KMrK0Gja2t_9cyA-1; Sun, 05 Jul 2020 23:42:19 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id B2BE68015F5; Mon, 6 Jul 2020 03:42:12 +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 8FC1360CC0; Mon, 6 Jul 2020 03:42:12 +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 6094E93F77; Mon, 6 Jul 2020 03:42:12 +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 0663fhhj004453 for ; Sun, 5 Jul 2020 23:41:43 -0400 Received: by smtp.corp.redhat.com (Postfix) id DAD327AC9F; Mon, 6 Jul 2020 03:41:43 +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 763E471678 for ; Mon, 6 Jul 2020 03:41:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1594006941; 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=HF7hzNhB0mnRb2SnEgtCksc90l+FY2gD6sKrl3JmcI8=; b=c/WkIrh+JQTkrjBwnaXJ/iII/HStNspWhFRy5JqqdDgBeuT2rHdXk6id3ksgfsYdiElTgu WOyakZqZsg1Cw5cQX8NKh4pUvDThRueus/THnQ/cjY1CDRVK9vVZjCUkEyNlDFaT3Krjzd dYc60HAxMMUccbZ81EjHA4xiShIGimI= X-MC-Unique: SjOwkI-KMrK0Gja2t_9cyA-1 From: Laine Stump To: libvir-list@redhat.com Subject: [PATCH 07/32] tests: use g_auto for all virBuffers Date: Sun, 5 Jul 2020 23:41:02 -0400 Message-Id: <20200706034127.1117504-8-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.79 on 10.5.11.12 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 --- tests/commandtest.c | 3 +-- tests/cputest.c | 2 +- tests/networkxml2firewalltest.c | 3 +-- tests/nodedevmdevctltest.c | 6 ++---- tests/nwfilterebiptablestest.c | 21 +++++++-------------- tests/nwfilterxml2firewalltest.c | 3 +-- tests/qemublocktest.c | 2 +- tests/qemucommandutiltest.c | 2 +- tests/qemumigparamstest.c | 6 ++---- tests/qemumonitorjsontest.c | 9 ++++----- tests/qemumonitortestutils.c | 2 +- tests/testutils.c | 2 +- tests/vboxsnapshotxmltest.c | 3 +-- tests/virbuftest.c | 23 ++++++++++------------- tests/vircgrouptest.c | 3 +-- tests/virfirewalltest.c | 30 ++++++++++-------------------- tests/virhostcputest.c | 3 +-- tests/virkmodtest.c | 4 ++-- tests/virnetdevbandwidthtest.c | 3 +-- 19 files changed, 49 insertions(+), 81 deletions(-) diff --git a/tests/commandtest.c b/tests/commandtest.c index d5092b7dd0..f0e60ee5fe 100644 --- a/tests/commandtest.c +++ b/tests/commandtest.c @@ -390,7 +390,7 @@ static int test9(const void *unused G_GNUC_UNUSED) { virCommandPtr cmd =3D virCommandNew(abs_builddir "/commandhelper"); const char* const args[] =3D { "arg1", "arg2", NULL }; - virBuffer buf =3D VIR_BUFFER_INITIALIZER; + g_auto(virBuffer) buf =3D VIR_BUFFER_INITIALIZER; =20 virCommandAddArg(cmd, "-version"); virCommandAddArgPair(cmd, "-log", "bar.log"); @@ -402,7 +402,6 @@ static int test9(const void *unused G_GNUC_UNUSED) =20 if (virBufferUse(&buf)) { printf("Buffer not transferred\n"); - virBufferFreeAndReset(&buf); virCommandFree(cmd); return -1; } diff --git a/tests/cputest.c b/tests/cputest.c index 0cf6870574..83d63bf495 100644 --- a/tests/cputest.c +++ b/tests/cputest.c @@ -237,7 +237,7 @@ cpuTestGuestCPU(const void *arg) virCPUDefPtr host =3D NULL; virCPUDefPtr cpu =3D NULL; virCPUCompareResult cmpResult; - virBuffer buf =3D VIR_BUFFER_INITIALIZER; + g_auto(virBuffer) buf =3D VIR_BUFFER_INITIALIZER; char *result =3D NULL; =20 if (!(host =3D cpuTestLoadXML(data->arch, data->host)) || diff --git a/tests/networkxml2firewalltest.c b/tests/networkxml2firewalltes= t.c index 69fadd55c4..29e7d8bc38 100644 --- a/tests/networkxml2firewalltest.c +++ b/tests/networkxml2firewalltest.c @@ -62,7 +62,7 @@ static int testCompareXMLToArgvFiles(const char *xml, const char *baseargs) { char *actualargv =3D NULL; - virBuffer buf =3D VIR_BUFFER_INITIALIZER; + g_auto(virBuffer) buf =3D VIR_BUFFER_INITIALIZER; virNetworkDefPtr def =3D NULL; int ret =3D -1; char *actual; @@ -92,7 +92,6 @@ static int testCompareXMLToArgvFiles(const char *xml, ret =3D 0; =20 cleanup: - virBufferFreeAndReset(&buf); VIR_FREE(actualargv); virNetworkDefFree(def); return ret; diff --git a/tests/nodedevmdevctltest.c b/tests/nodedevmdevctltest.c index f5bcf5227d..9780553a3a 100644 --- a/tests/nodedevmdevctltest.c +++ b/tests/nodedevmdevctltest.c @@ -54,7 +54,7 @@ testMdevctlStart(const char *virt_type, { g_autoptr(virNodeDeviceDef) def =3D NULL; virNodeDeviceObjPtr obj =3D NULL; - virBuffer buf =3D VIR_BUFFER_INITIALIZER; + g_auto(virBuffer) buf =3D VIR_BUFFER_INITIALIZER; const char *actualCmdline =3D NULL; int ret =3D -1; g_autofree char *uuid =3D NULL; @@ -87,7 +87,6 @@ testMdevctlStart(const char *virt_type, ret =3D 0; =20 cleanup: - virBufferFreeAndReset(&buf); virCommandSetDryRun(NULL, NULL, NULL); virNodeDeviceObjEndAPI(&obj); return ret; @@ -114,7 +113,7 @@ static int testMdevctlStop(const void *data) { const char *uuid =3D data; - virBuffer buf =3D VIR_BUFFER_INITIALIZER; + g_auto(virBuffer) buf =3D VIR_BUFFER_INITIALIZER; const char *actualCmdline =3D NULL; int ret =3D -1; g_autoptr(virCommand) cmd =3D NULL; @@ -140,7 +139,6 @@ testMdevctlStop(const void *data) ret =3D 0; =20 cleanup: - virBufferFreeAndReset(&buf); virCommandSetDryRun(NULL, NULL, NULL); return ret; } diff --git a/tests/nwfilterebiptablestest.c b/tests/nwfilterebiptablestest.c index 3e6c335d4e..4d8791023c 100644 --- a/tests/nwfilterebiptablestest.c +++ b/tests/nwfilterebiptablestest.c @@ -68,7 +68,7 @@ static int testNWFilterEBIPTablesAllTeardown(const void *opaque G_GNUC_UNUSED) { - virBuffer buf =3D VIR_BUFFER_INITIALIZER; + g_auto(virBuffer) buf =3D VIR_BUFFER_INITIALIZER; const char *expected =3D VIR_NWFILTER_NEW_RULES_TEARDOWN "iptables -D libvirt-out -m physdev --physdev-is-bridged --physdev= -out vnet0 -g FO-vnet0\n" @@ -120,7 +120,6 @@ testNWFilterEBIPTablesAllTeardown(const void *opaque G_= GNUC_UNUSED) ret =3D 0; cleanup: virCommandSetDryRun(NULL, NULL, NULL); - virBufferFreeAndReset(&buf); VIR_FREE(actual); return ret; } @@ -129,7 +128,7 @@ testNWFilterEBIPTablesAllTeardown(const void *opaque G_= GNUC_UNUSED) static int testNWFilterEBIPTablesTearOldRules(const void *opaque G_GNUC_UNUSED) { - virBuffer buf =3D VIR_BUFFER_INITIALIZER; + g_auto(virBuffer) buf =3D VIR_BUFFER_INITIALIZER; const char *expected =3D "iptables -D libvirt-out -m physdev --physdev-is-bridged --physdev= -out vnet0 -g FO-vnet0\n" "iptables -D libvirt-out -m physdev --physdev-out vnet0 -g FO-vnet= 0\n" @@ -188,7 +187,6 @@ testNWFilterEBIPTablesTearOldRules(const void *opaque G= _GNUC_UNUSED) ret =3D 0; cleanup: virCommandSetDryRun(NULL, NULL, NULL); - virBufferFreeAndReset(&buf); VIR_FREE(actual); return ret; } @@ -197,7 +195,7 @@ testNWFilterEBIPTablesTearOldRules(const void *opaque G= _GNUC_UNUSED) static int testNWFilterEBIPTablesRemoveBasicRules(const void *opaque G_GNUC_UNUSED) { - virBuffer buf =3D VIR_BUFFER_INITIALIZER; + g_auto(virBuffer) buf =3D VIR_BUFFER_INITIALIZER; const char *expected =3D "ebtables -t nat -D PREROUTING -i vnet0 -j libvirt-I-vnet0\n" "ebtables -t nat -D POSTROUTING -o vnet0 -j libvirt-O-vnet0\n" @@ -234,7 +232,6 @@ testNWFilterEBIPTablesRemoveBasicRules(const void *opaq= ue G_GNUC_UNUSED) ret =3D 0; cleanup: virCommandSetDryRun(NULL, NULL, NULL); - virBufferFreeAndReset(&buf); VIR_FREE(actual); return ret; } @@ -243,7 +240,7 @@ testNWFilterEBIPTablesRemoveBasicRules(const void *opaq= ue G_GNUC_UNUSED) static int testNWFilterEBIPTablesTearNewRules(const void *opaque G_GNUC_UNUSED) { - virBuffer buf =3D VIR_BUFFER_INITIALIZER; + g_auto(virBuffer) buf =3D VIR_BUFFER_INITIALIZER; const char *expected =3D VIR_NWFILTER_NEW_RULES_TEARDOWN; char *actual =3D NULL; @@ -265,7 +262,6 @@ testNWFilterEBIPTablesTearNewRules(const void *opaque G= _GNUC_UNUSED) ret =3D 0; cleanup: virCommandSetDryRun(NULL, NULL, NULL); - virBufferFreeAndReset(&buf); VIR_FREE(actual); return ret; } @@ -274,7 +270,7 @@ testNWFilterEBIPTablesTearNewRules(const void *opaque G= _GNUC_UNUSED) static int testNWFilterEBIPTablesApplyBasicRules(const void *opaque G_GNUC_UNUSED) { - virBuffer buf =3D VIR_BUFFER_INITIALIZER; + g_auto(virBuffer) buf =3D VIR_BUFFER_INITIALIZER; const char *expected =3D VIR_NWFILTER_NEW_RULES_TEARDOWN "iptables -D libvirt-out -m physdev --physdev-is-bridged --physdev= -out vnet0 -g FO-vnet0\n" @@ -334,7 +330,6 @@ testNWFilterEBIPTablesApplyBasicRules(const void *opaqu= e G_GNUC_UNUSED) ret =3D 0; cleanup: virCommandSetDryRun(NULL, NULL, NULL); - virBufferFreeAndReset(&buf); VIR_FREE(actual); return ret; } @@ -343,7 +338,7 @@ testNWFilterEBIPTablesApplyBasicRules(const void *opaqu= e G_GNUC_UNUSED) static int testNWFilterEBIPTablesApplyDHCPOnlyRules(const void *opaque G_GNUC_UNUSED) { - virBuffer buf =3D VIR_BUFFER_INITIALIZER; + g_auto(virBuffer) buf =3D VIR_BUFFER_INITIALIZER; const char *expected =3D VIR_NWFILTER_NEW_RULES_TEARDOWN "iptables -D libvirt-out -m physdev --physdev-is-bridged --physdev= -out vnet0 -g FO-vnet0\n" @@ -421,7 +416,6 @@ testNWFilterEBIPTablesApplyDHCPOnlyRules(const void *op= aque G_GNUC_UNUSED) ret =3D 0; cleanup: virCommandSetDryRun(NULL, NULL, NULL); - virBufferFreeAndReset(&buf); VIR_FREE(actual); return ret; } @@ -431,7 +425,7 @@ testNWFilterEBIPTablesApplyDHCPOnlyRules(const void *op= aque G_GNUC_UNUSED) static int testNWFilterEBIPTablesApplyDropAllRules(const void *opaque G_GNUC_UNUSED) { - virBuffer buf =3D VIR_BUFFER_INITIALIZER; + g_auto(virBuffer) buf =3D VIR_BUFFER_INITIALIZER; const char *expected =3D VIR_NWFILTER_NEW_RULES_TEARDOWN "iptables -D libvirt-out -m physdev --physdev-is-bridged --physdev= -out vnet0 -g FO-vnet0\n" @@ -491,7 +485,6 @@ testNWFilterEBIPTablesApplyDropAllRules(const void *opa= que G_GNUC_UNUSED) ret =3D 0; cleanup: virCommandSetDryRun(NULL, NULL, NULL); - virBufferFreeAndReset(&buf); VIR_FREE(actual); return ret; } diff --git a/tests/nwfilterxml2firewalltest.c b/tests/nwfilterxml2firewallt= est.c index da86ec9463..dff2b62028 100644 --- a/tests/nwfilterxml2firewalltest.c +++ b/tests/nwfilterxml2firewalltest.c @@ -368,7 +368,7 @@ static int testCompareXMLToArgvFiles(const char *xml, const char *cmdline) { char *actualargv =3D NULL; - virBuffer buf =3D VIR_BUFFER_INITIALIZER; + g_auto(virBuffer) buf =3D VIR_BUFFER_INITIALIZER; virHashTablePtr vars =3D virNWFilterHashTableCreate(0); virNWFilterInst inst; int ret =3D -1; @@ -403,7 +403,6 @@ static int testCompareXMLToArgvFiles(const char *xml, ret =3D 0; =20 cleanup: - virBufferFreeAndReset(&buf); VIR_FREE(actualargv); virNWFilterInstReset(&inst); virHashFree(vars); diff --git a/tests/qemublocktest.c b/tests/qemublocktest.c index 0ab599dd67..51283793e9 100644 --- a/tests/qemublocktest.c +++ b/tests/qemublocktest.c @@ -383,7 +383,7 @@ static int testQemuDiskXMLToPropsValidateFile(const void *opaque) { struct testQemuDiskXMLToJSONData *data =3D (void *) opaque; - virBuffer buf =3D VIR_BUFFER_INITIALIZER; + g_auto(virBuffer) buf =3D VIR_BUFFER_INITIALIZER; g_autofree char *jsonpath =3D NULL; g_autofree char *actual =3D NULL; size_t i; diff --git a/tests/qemucommandutiltest.c b/tests/qemucommandutiltest.c index 049fd2f0b0..305f59e76b 100644 --- a/tests/qemucommandutiltest.c +++ b/tests/qemucommandutiltest.c @@ -38,7 +38,7 @@ testQemuCommandBuildFromJSON(const void *opaque) { const testQemuCommandBuildObjectFromJSONData *data =3D opaque; virJSONValuePtr val =3D NULL; - virBuffer buf =3D VIR_BUFFER_INITIALIZER; + g_auto(virBuffer) buf =3D VIR_BUFFER_INITIALIZER; char *result =3D NULL; int ret =3D -1; =20 diff --git a/tests/qemumigparamstest.c b/tests/qemumigparamstest.c index 954cd1c578..057cde5e72 100644 --- a/tests/qemumigparamstest.c +++ b/tests/qemumigparamstest.c @@ -58,7 +58,7 @@ static int qemuMigParamsTestXML2XML(const void *opaque) { const qemuMigParamsData *data =3D opaque; - virBuffer buf =3D VIR_BUFFER_INITIALIZER; + g_auto(virBuffer) buf =3D VIR_BUFFER_INITIALIZER; char *xmlFile =3D NULL; xmlDocPtr doc =3D NULL; xmlXPathContextPtr ctxt =3D NULL; @@ -89,7 +89,6 @@ qemuMigParamsTestXML2XML(const void *opaque) VIR_FREE(xmlFile); VIR_FREE(actualXML); qemuMigrationParamsFree(migParams); - virBufferFreeAndReset(&buf); xmlXPathFreeContext(ctxt); xmlFreeDoc(doc); return ret; @@ -100,7 +99,7 @@ static int qemuMigParamsTestXML(const void *opaque) { const qemuMigParamsData *data =3D opaque; - virBuffer buf =3D VIR_BUFFER_INITIALIZER; + g_auto(virBuffer) buf =3D VIR_BUFFER_INITIALIZER; char *replyFile =3D NULL; char *xmlFile =3D NULL; qemuMonitorTestPtr mon =3D NULL; @@ -140,7 +139,6 @@ qemuMigParamsTestXML(const void *opaque) VIR_FREE(actualXML); virJSONValueFree(params); qemuMigrationParamsFree(migParams); - virBufferFreeAndReset(&buf); qemuMonitorTestFree(mon); return ret; } diff --git a/tests/qemumonitorjsontest.c b/tests/qemumonitorjsontest.c index d2cd054dbf..741e36a491 100644 --- a/tests/qemumonitorjsontest.c +++ b/tests/qemumonitorjsontest.c @@ -2603,7 +2603,7 @@ static char * testQemuMonitorCPUInfoFormat(qemuMonitorCPUInfoPtr vcpus, size_t nvcpus) { - virBuffer buf =3D VIR_BUFFER_INITIALIZER; + g_auto(virBuffer) buf =3D VIR_BUFFER_INITIALIZER; qemuMonitorCPUInfoPtr vcpu; size_t i; =20 @@ -2781,7 +2781,7 @@ testBlockNodeNameDetect(const void *opaque) virJSONValuePtr namedNodesJson =3D NULL; virJSONValuePtr blockstatsJson =3D NULL; virHashTablePtr nodedata =3D NULL; - virBuffer buf =3D VIR_BUFFER_INITIALIZER; + g_auto(virBuffer) buf =3D VIR_BUFFER_INITIALIZER; int ret =3D -1; =20 resultFile =3D g_strdup_printf("%s/%s%s.result", abs_srcdir, pathprefi= x, @@ -2855,7 +2855,7 @@ static int testQAPISchemaValidate(const void *opaque) { const struct testQAPISchemaData *data =3D opaque; - virBuffer debug =3D VIR_BUFFER_INITIALIZER; + g_auto(virBuffer) debug =3D VIR_BUFFER_INITIALIZER; virJSONValuePtr schemaroot; virJSONValuePtr json =3D NULL; int ret =3D -1; @@ -2883,7 +2883,6 @@ testQAPISchemaValidate(const void *opaque) =20 =20 cleanup: - virBufferFreeAndReset(&debug); virJSONValueFree(json); return ret; } @@ -2918,7 +2917,7 @@ testQueryJobs(const void *opaque) g_autofree char *filenameResult =3D NULL; g_autofree char *actual =3D NULL; qemuMonitorJobInfoPtr *jobs =3D NULL; - virBuffer buf =3D VIR_BUFFER_INITIALIZER; + g_auto(virBuffer) buf =3D VIR_BUFFER_INITIALIZER; size_t njobs =3D 0; size_t i; int ret =3D -1; diff --git a/tests/qemumonitortestutils.c b/tests/qemumonitortestutils.c index 6be7555dc0..180ac15a15 100644 --- a/tests/qemumonitortestutils.c +++ b/tests/qemumonitortestutils.c @@ -133,7 +133,7 @@ static int qemuMonitorTestAddErrorResponseInternal(qemuMonitorTestPtr test, const char *usermsg) { - virBuffer buf =3D VIR_BUFFER_INITIALIZER; + g_auto(virBuffer) buf =3D VIR_BUFFER_INITIALIZER; g_autofree char *escapemsg =3D NULL; g_autofree char *jsonmsg =3D NULL; char *tmp; diff --git a/tests/testutils.c b/tests/testutils.c index 7f1776b244..a1cd093e4e 100644 --- a/tests/testutils.c +++ b/tests/testutils.c @@ -251,7 +251,7 @@ static char * virTestLoadFileGetPath(const char *p, va_list ap) { - virBuffer buf =3D VIR_BUFFER_INITIALIZER; + g_auto(virBuffer) buf =3D VIR_BUFFER_INITIALIZER; char *path =3D NULL; =20 virBufferAddLit(&buf, abs_srcdir "/"); diff --git a/tests/vboxsnapshotxmltest.c b/tests/vboxsnapshotxmltest.c index 2ea460d8bd..054e2a8e0d 100644 --- a/tests/vboxsnapshotxmltest.c +++ b/tests/vboxsnapshotxmltest.c @@ -18,7 +18,7 @@ GRegex *testSnapshotXMLVariableLineRegex =3D NULL; static char * testFilterXML(char *xml) { - virBuffer buf =3D VIR_BUFFER_INITIALIZER; + g_auto(virBuffer) buf =3D VIR_BUFFER_INITIALIZER; char **xmlLines =3D NULL; char **xmlLine; char *ret =3D NULL; @@ -39,7 +39,6 @@ testFilterXML(char *xml) ret =3D virBufferContentAndReset(&buf); =20 cleanup: - virBufferFreeAndReset(&buf); virStringListFree(xmlLines); return ret; } diff --git a/tests/virbuftest.c b/tests/virbuftest.c index f9d19ff1a1..39ae7c2b9d 100644 --- a/tests/virbuftest.c +++ b/tests/virbuftest.c @@ -17,7 +17,7 @@ struct testBufAddStrData { =20 static int testBufAutoIndent(const void *data G_GNUC_UNUSED) { - virBuffer bufinit =3D VIR_BUFFER_INITIALIZER; + g_auto(virBuffer) bufinit =3D VIR_BUFFER_INITIALIZER; virBufferPtr buf =3D &bufinit; const char expected[] =3D " 1\n 2\n 3\n 4\n 5\n 6\n 7\n &\n 8\n 9\n 10\n ' 1= 1'\n"; @@ -96,7 +96,7 @@ static int testBufAutoIndent(const void *data G_GNUC_UNUS= ED) =20 static int testBufTrim(const void *data G_GNUC_UNUSED) { - virBuffer bufinit =3D VIR_BUFFER_INITIALIZER; + g_auto(virBuffer) bufinit =3D VIR_BUFFER_INITIALIZER; virBufferPtr buf =3D NULL; g_autofree char *result =3D NULL; const char *expected =3D "a,b"; @@ -126,7 +126,6 @@ static int testBufTrim(const void *data G_GNUC_UNUSED) ret =3D 0; =20 cleanup: - virBufferFreeAndReset(buf); return ret; } =20 @@ -134,7 +133,7 @@ static int testBufTrimChars(const void *opaque) { const struct testBufAddStrData *data =3D opaque; - virBuffer buf =3D VIR_BUFFER_INITIALIZER; + g_auto(virBuffer) buf =3D VIR_BUFFER_INITIALIZER; g_autofree char *actual =3D NULL; =20 virBufferAddStr(&buf, data->data); @@ -156,9 +155,9 @@ testBufTrimChars(const void *opaque) =20 static int testBufAddBuffer(const void *data G_GNUC_UNUSED) { - virBuffer buf1 =3D VIR_BUFFER_INITIALIZER; - virBuffer buf2 =3D VIR_BUFFER_INITIALIZER; - virBuffer buf3 =3D VIR_BUFFER_INITIALIZER; + g_auto(virBuffer) buf1 =3D VIR_BUFFER_INITIALIZER; + g_auto(virBuffer) buf2 =3D VIR_BUFFER_INITIALIZER; + g_auto(virBuffer) buf3 =3D VIR_BUFFER_INITIALIZER; int ret =3D -1; g_autofree char *result =3D NULL; const char *expected =3D \ @@ -259,8 +258,6 @@ static int testBufAddBuffer(const void *data G_GNUC_UNU= SED) =20 ret =3D 0; cleanup: - virBufferFreeAndReset(&buf1); - virBufferFreeAndReset(&buf2); return ret; } =20 @@ -268,7 +265,7 @@ static int testBufAddStr(const void *opaque) { const struct testBufAddStrData *data =3D opaque; - virBuffer buf =3D VIR_BUFFER_INITIALIZER; + g_auto(virBuffer) buf =3D VIR_BUFFER_INITIALIZER; g_autofree char *actual =3D NULL; =20 virBufferAddLit(&buf, "\n"); @@ -296,7 +293,7 @@ static int testBufEscapeStr(const void *opaque) { const struct testBufAddStrData *data =3D opaque; - virBuffer buf =3D VIR_BUFFER_INITIALIZER; + g_auto(virBuffer) buf =3D VIR_BUFFER_INITIALIZER; g_autofree char *actual =3D NULL; =20 virBufferAddLit(&buf, "\n"); @@ -324,7 +321,7 @@ static int testBufEscapeRegex(const void *opaque) { const struct testBufAddStrData *data =3D opaque; - virBuffer buf =3D VIR_BUFFER_INITIALIZER; + g_auto(virBuffer) buf =3D VIR_BUFFER_INITIALIZER; g_autofree char *actual =3D NULL; =20 virBufferEscapeRegex(&buf, "%s", data->data); @@ -347,7 +344,7 @@ testBufEscapeRegex(const void *opaque) static int testBufSetIndent(const void *opaque G_GNUC_UNUSED) { - virBuffer buf =3D VIR_BUFFER_INITIALIZER; + g_auto(virBuffer) buf =3D VIR_BUFFER_INITIALIZER; g_autofree char *actual =3D NULL; =20 virBufferSetIndent(&buf, 11); diff --git a/tests/vircgrouptest.c b/tests/vircgrouptest.c index 2d6f52fb6e..44e72cbfa9 100644 --- a/tests/vircgrouptest.c +++ b/tests/vircgrouptest.c @@ -184,7 +184,7 @@ testCgroupDetectMounts(const void *args) char *parsed =3D NULL; const char *actual; virCgroupPtr group =3D NULL; - virBuffer buf =3D VIR_BUFFER_INITIALIZER; + g_auto(virBuffer) buf =3D VIR_BUFFER_INITIALIZER; size_t i; =20 g_setenv("VIR_CGROUP_MOCK_FILENAME", data->file, TRUE); @@ -218,7 +218,6 @@ testCgroupDetectMounts(const void *args) g_unsetenv("VIR_CGROUP_MOCK_FILENAME"); VIR_FREE(parsed); virCgroupFree(&group); - virBufferFreeAndReset(&buf); return result; } =20 diff --git a/tests/virfirewalltest.c b/tests/virfirewalltest.c index c4827918c3..4105c1867e 100644 --- a/tests/virfirewalltest.c +++ b/tests/virfirewalltest.c @@ -199,7 +199,7 @@ struct testFirewallData { static int testFirewallSingleGroup(const void *opaque) { - virBuffer cmdbuf =3D VIR_BUFFER_INITIALIZER; + g_auto(virBuffer) cmdbuf =3D VIR_BUFFER_INITIALIZER; virFirewallPtr fw =3D NULL; int ret =3D -1; const char *actual =3D NULL; @@ -244,7 +244,6 @@ testFirewallSingleGroup(const void *opaque) =20 ret =3D 0; cleanup: - virBufferFreeAndReset(&cmdbuf); fwBuf =3D NULL; virCommandSetDryRun(NULL, NULL, NULL); virFirewallFree(fw); @@ -255,7 +254,7 @@ testFirewallSingleGroup(const void *opaque) static int testFirewallRemoveRule(const void *opaque) { - virBuffer cmdbuf =3D VIR_BUFFER_INITIALIZER; + g_auto(virBuffer) cmdbuf =3D VIR_BUFFER_INITIALIZER; virFirewallPtr fw =3D NULL; int ret =3D -1; const char *actual =3D NULL; @@ -307,7 +306,6 @@ testFirewallRemoveRule(const void *opaque) =20 ret =3D 0; cleanup: - virBufferFreeAndReset(&cmdbuf); fwBuf =3D NULL; virCommandSetDryRun(NULL, NULL, NULL); virFirewallFree(fw); @@ -318,7 +316,7 @@ testFirewallRemoveRule(const void *opaque) static int testFirewallManyGroups(const void *opaque G_GNUC_UNUSED) { - virBuffer cmdbuf =3D VIR_BUFFER_INITIALIZER; + g_auto(virBuffer) cmdbuf =3D VIR_BUFFER_INITIALIZER; virFirewallPtr fw =3D NULL; int ret =3D -1; const char *actual =3D NULL; @@ -377,7 +375,6 @@ testFirewallManyGroups(const void *opaque G_GNUC_UNUSED) =20 ret =3D 0; cleanup: - virBufferFreeAndReset(&cmdbuf); fwBuf =3D NULL; virCommandSetDryRun(NULL, NULL, NULL); virFirewallFree(fw); @@ -409,7 +406,7 @@ testFirewallRollbackHook(const char *const*args, static int testFirewallIgnoreFailGroup(const void *opaque G_GNUC_UNUSED) { - virBuffer cmdbuf =3D VIR_BUFFER_INITIALIZER; + g_auto(virBuffer) cmdbuf =3D VIR_BUFFER_INITIALIZER; virFirewallPtr fw =3D NULL; int ret =3D -1; const char *actual =3D NULL; @@ -470,7 +467,6 @@ testFirewallIgnoreFailGroup(const void *opaque G_GNUC_U= NUSED) =20 ret =3D 0; cleanup: - virBufferFreeAndReset(&cmdbuf); fwBuf =3D NULL; virCommandSetDryRun(NULL, NULL, NULL); virFirewallFree(fw); @@ -481,7 +477,7 @@ testFirewallIgnoreFailGroup(const void *opaque G_GNUC_U= NUSED) static int testFirewallIgnoreFailRule(const void *opaque G_GNUC_UNUSED) { - virBuffer cmdbuf =3D VIR_BUFFER_INITIALIZER; + g_auto(virBuffer) cmdbuf =3D VIR_BUFFER_INITIALIZER; virFirewallPtr fw =3D NULL; int ret =3D -1; const char *actual =3D NULL; @@ -541,7 +537,6 @@ testFirewallIgnoreFailRule(const void *opaque G_GNUC_UN= USED) =20 ret =3D 0; cleanup: - virBufferFreeAndReset(&cmdbuf); fwBuf =3D NULL; virCommandSetDryRun(NULL, NULL, NULL); virFirewallFree(fw); @@ -552,7 +547,7 @@ testFirewallIgnoreFailRule(const void *opaque G_GNUC_UN= USED) static int testFirewallNoRollback(const void *opaque G_GNUC_UNUSED) { - virBuffer cmdbuf =3D VIR_BUFFER_INITIALIZER; + g_auto(virBuffer) cmdbuf =3D VIR_BUFFER_INITIALIZER; virFirewallPtr fw =3D NULL; int ret =3D -1; const char *actual =3D NULL; @@ -606,7 +601,6 @@ testFirewallNoRollback(const void *opaque G_GNUC_UNUSED) =20 ret =3D 0; cleanup: - virBufferFreeAndReset(&cmdbuf); fwBuf =3D NULL; virCommandSetDryRun(NULL, NULL, NULL); virFirewallFree(fw); @@ -616,7 +610,7 @@ testFirewallNoRollback(const void *opaque G_GNUC_UNUSED) static int testFirewallSingleRollback(const void *opaque G_GNUC_UNUSED) { - virBuffer cmdbuf =3D VIR_BUFFER_INITIALIZER; + g_auto(virBuffer) cmdbuf =3D VIR_BUFFER_INITIALIZER; virFirewallPtr fw =3D NULL; int ret =3D -1; const char *actual =3D NULL; @@ -690,7 +684,6 @@ testFirewallSingleRollback(const void *opaque G_GNUC_UN= USED) =20 ret =3D 0; cleanup: - virBufferFreeAndReset(&cmdbuf); fwBuf =3D NULL; virCommandSetDryRun(NULL, NULL, NULL); virFirewallFree(fw); @@ -700,7 +693,7 @@ testFirewallSingleRollback(const void *opaque G_GNUC_UN= USED) static int testFirewallManyRollback(const void *opaque G_GNUC_UNUSED) { - virBuffer cmdbuf =3D VIR_BUFFER_INITIALIZER; + g_auto(virBuffer) cmdbuf =3D VIR_BUFFER_INITIALIZER; virFirewallPtr fw =3D NULL; int ret =3D -1; const char *actual =3D NULL; @@ -777,7 +770,6 @@ testFirewallManyRollback(const void *opaque G_GNUC_UNUS= ED) =20 ret =3D 0; cleanup: - virBufferFreeAndReset(&cmdbuf); fwBuf =3D NULL; virCommandSetDryRun(NULL, NULL, NULL); virFirewallFree(fw); @@ -787,7 +779,7 @@ testFirewallManyRollback(const void *opaque G_GNUC_UNUS= ED) static int testFirewallChainedRollback(const void *opaque G_GNUC_UNUSED) { - virBuffer cmdbuf =3D VIR_BUFFER_INITIALIZER; + g_auto(virBuffer) cmdbuf =3D VIR_BUFFER_INITIALIZER; virFirewallPtr fw =3D NULL; int ret =3D -1; const char *actual =3D NULL; @@ -894,7 +886,6 @@ testFirewallChainedRollback(const void *opaque G_GNUC_U= NUSED) =20 ret =3D 0; cleanup: - virBufferFreeAndReset(&cmdbuf); fwBuf =3D NULL; virCommandSetDryRun(NULL, NULL, NULL); virFirewallFree(fw); @@ -981,7 +972,7 @@ testFirewallQueryCallback(virFirewallPtr fw, static int testFirewallQuery(const void *opaque G_GNUC_UNUSED) { - virBuffer cmdbuf =3D VIR_BUFFER_INITIALIZER; + g_auto(virBuffer) cmdbuf =3D VIR_BUFFER_INITIALIZER; virFirewallPtr fw =3D NULL; int ret =3D -1; const char *actual =3D NULL; @@ -1073,7 +1064,6 @@ testFirewallQuery(const void *opaque G_GNUC_UNUSED) =20 ret =3D 0; cleanup: - virBufferFreeAndReset(&cmdbuf); fwBuf =3D NULL; virCommandSetDryRun(NULL, NULL, NULL); virFirewallFree(fw); diff --git a/tests/virhostcputest.c b/tests/virhostcputest.c index 62bacddefb..7b83c7ae5d 100644 --- a/tests/virhostcputest.c +++ b/tests/virhostcputest.c @@ -112,7 +112,7 @@ linuxCPUStatsCompareFiles(const char *cpustatfile, char *actualData =3D NULL; FILE *cpustat =3D NULL; virNodeCPUStatsPtr params =3D NULL; - virBuffer buf =3D VIR_BUFFER_INITIALIZER; + g_auto(virBuffer) buf =3D VIR_BUFFER_INITIALIZER; size_t i; int nparams =3D 0; =20 @@ -153,7 +153,6 @@ linuxCPUStatsCompareFiles(const char *cpustatfile, ret =3D 0; =20 fail: - virBufferFreeAndReset(&buf); VIR_FORCE_FCLOSE(cpustat); VIR_FREE(actualData); VIR_FREE(params); diff --git a/tests/virkmodtest.c b/tests/virkmodtest.c index 3ba8c542d1..369eb8baca 100644 --- a/tests/virkmodtest.c +++ b/tests/virkmodtest.c @@ -60,7 +60,7 @@ testKModLoad(const void *args G_GNUC_UNUSED) { int ret =3D -1; char *errbuf =3D NULL; - virBuffer buf =3D VIR_BUFFER_INITIALIZER; + g_auto(virBuffer) buf =3D VIR_BUFFER_INITIALIZER; =20 virCommandSetDryRun(&buf, NULL, NULL); =20 @@ -87,7 +87,7 @@ testKModUnload(const void *args G_GNUC_UNUSED) { int ret =3D -1; char *errbuf =3D NULL; - virBuffer buf =3D VIR_BUFFER_INITIALIZER; + g_auto(virBuffer) buf =3D VIR_BUFFER_INITIALIZER; =20 virCommandSetDryRun(&buf, NULL, NULL); =20 diff --git a/tests/virnetdevbandwidthtest.c b/tests/virnetdevbandwidthtest.c index 8039fedbc4..5cbdd6ffea 100644 --- a/tests/virnetdevbandwidthtest.c +++ b/tests/virnetdevbandwidthtest.c @@ -70,7 +70,7 @@ testVirNetDevBandwidthSet(const void *data) const struct testSetStruct *info =3D data; const char *iface =3D info->iface; virNetDevBandwidthPtr band =3D NULL; - virBuffer buf =3D VIR_BUFFER_INITIALIZER; + g_auto(virBuffer) buf =3D VIR_BUFFER_INITIALIZER; char *actual_cmd =3D NULL; =20 PARSE(info->band, band); @@ -99,7 +99,6 @@ testVirNetDevBandwidthSet(const void *data) cleanup: virCommandSetDryRun(NULL, NULL, NULL); virNetDevBandwidthFree(band); - virBufferFreeAndReset(&buf); VIR_FREE(actual_cmd); return ret; } --=20 2.25.4 From nobody Mon May 6 01:10:47 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 205.139.110.61 as permitted sender) client-ip=205.139.110.61; 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 205.139.110.61 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=1594006941; cv=none; d=zohomail.com; s=zohoarc; b=S920nzMoKuF2FBsfNU7xJiv9d44SUTiQQDavOVpSWt87IQinBOXBML7OFTaEo3jZ0i0SoIFdqVoMw0Nz5Ym3t63O3hxUIfLkFc1/Nx1waImd17ROt9GG9qyV7ffitd2U1I5p5sVEzzlsFXAXOEMFGGr+cCKXOAYEroKsgp3iJas= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1594006941; 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=ta14DHLWhWXWjJ8+WnIpKP+smrQsQH9ZVZTbhywrdWw=; b=RYdSamFu/ITaC9/QCUHW2rRyhJTGnqKIZ7BGnaVsDgnDmUu0rvWxQgSRg0RH381xwHX80mSrQFewWFmFh10MICveg8HB/8BM0f8ygcix68ge8qIx3VaYUWMjqrlAefsfi0F0urkg50aE+S0T+3pvoNAni601Ei1YuiFnU1U4AGw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.61 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 [205.139.110.61]) by mx.zohomail.com with SMTPS id 1594006941534614.3074369327223; Sun, 5 Jul 2020 20:42:21 -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-30-Lz9pJ-z-POWrU6OtwQ6TgA-1; Sun, 05 Jul 2020 23:42:17 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 36277107ACCA; Mon, 6 Jul 2020 03:42:12 +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 1256028550; Mon, 6 Jul 2020 03:42:12 +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 D7AF593F70; Mon, 6 Jul 2020 03:42:11 +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 0663fi0S004465 for ; Sun, 5 Jul 2020 23:41:44 -0400 Received: by smtp.corp.redhat.com (Postfix) id 5FA527AC9F; Mon, 6 Jul 2020 03:41:44 +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 1605671678 for ; Mon, 6 Jul 2020 03:41:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1594006940; 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=ta14DHLWhWXWjJ8+WnIpKP+smrQsQH9ZVZTbhywrdWw=; b=f7yze9CPTqjOdpWU4ITPBtGBjwtnrGOoPkmKMedXw91nrRRhl4ds0gfUoQ9+lmDjPm2BW1 nyLUBlkinxNFVVqLEX2wb9HAhQoQlBCSobRouwSTSdX+ojkYtOVI4uxLZ69Pjx3be2O7Et 1DkJt4HVuqQFWk3MsVSJ33rkuxTYxAg= X-MC-Unique: Lz9pJ-z-POWrU6OtwQ6TgA-1 From: Laine Stump To: libvir-list@redhat.com Subject: [PATCH 08/32] tools: use g_auto() for all virBuffers Date: Sun, 5 Jul 2020 23:41:03 -0400 Message-Id: <20200706034127.1117504-9-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.23 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 --- tools/virsh-checkpoint.c | 3 +- tools/virsh-domain-monitor.c | 3 +- tools/virsh-domain.c | 58 +++++++++++++++++------------------- tools/virsh-pool.c | 6 ++-- tools/virsh-secret.c | 2 +- tools/virsh-snapshot.c | 3 +- tools/virsh-volume.c | 3 +- tools/vsh-table.c | 2 +- tools/vsh.c | 15 ++++------ 9 files changed, 42 insertions(+), 53 deletions(-) diff --git a/tools/virsh-checkpoint.c b/tools/virsh-checkpoint.c index 853fe05fc4..821212f86b 100644 --- a/tools/virsh-checkpoint.c +++ b/tools/virsh-checkpoint.c @@ -235,7 +235,7 @@ cmdCheckpointCreateAs(vshControl *ctl, char *buffer =3D NULL; const char *name =3D NULL; const char *desc =3D NULL; - virBuffer buf =3D VIR_BUFFER_INITIALIZER; + g_auto(virBuffer) buf =3D VIR_BUFFER_INITIALIZER; unsigned int flags =3D 0; const vshCmdOpt *opt =3D NULL; =20 @@ -278,7 +278,6 @@ cmdCheckpointCreateAs(vshControl *ctl, ret =3D virshCheckpointCreate(ctl, dom, buffer, flags, NULL); =20 cleanup: - virBufferFreeAndReset(&buf); VIR_FREE(buffer); virshDomainFree(dom); =20 diff --git a/tools/virsh-domain-monitor.c b/tools/virsh-domain-monitor.c index 9b8c69fa9d..d8333a2f44 100644 --- a/tools/virsh-domain-monitor.c +++ b/tools/virsh-domain-monitor.c @@ -2413,7 +2413,7 @@ cmdDomIfAddr(vshControl *ctl, const vshCmd *cmd) } =20 for (j =3D 0; j < iface->naddrs; j++) { - virBuffer buf =3D VIR_BUFFER_INITIALIZER; + g_auto(virBuffer) buf =3D VIR_BUFFER_INITIALIZER; =20 switch (iface->addrs[j].type) { case VIR_IP_ADDR_TYPE_IPV4: @@ -2442,7 +2442,6 @@ cmdDomIfAddr(vshControl *ctl, const vshCmd *cmd) vshPrint(ctl, " %-10s %-17s %s\n", "-", "-", ip_addr_str); =20 - virBufferFreeAndReset(&buf); VIR_FREE(ip_addr_str); } } diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c index 085b88b097..f0f3456b77 100644 --- a/tools/virsh-domain.c +++ b/tools/virsh-domain.c @@ -575,7 +575,7 @@ cmdAttachDisk(vshControl *ctl, const vshCmd *cmd) int ret; unsigned int flags =3D VIR_DOMAIN_AFFECT_CURRENT; const char *stype =3D NULL; - virBuffer buf =3D VIR_BUFFER_INITIALIZER; + g_auto(virBuffer) buf =3D VIR_BUFFER_INITIALIZER; char *xml =3D NULL; struct stat st; bool current =3D vshCommandOptBool(cmd, "current"); @@ -778,7 +778,6 @@ cmdAttachDisk(vshControl *ctl, const vshCmd *cmd) cleanup: VIR_FREE(xml); virshDomainFree(dom); - virBufferFreeAndReset(&buf); return functionReturn; } =20 @@ -905,7 +904,7 @@ cmdAttachInterface(vshControl *ctl, const vshCmd *cmd) virDomainNetType typ; int ret; bool functionReturn =3D false; - virBuffer buf =3D VIR_BUFFER_INITIALIZER; + g_auto(virBuffer) buf =3D VIR_BUFFER_INITIALIZER; char *xml =3D NULL; unsigned int flags =3D VIR_DOMAIN_AFFECT_CURRENT; bool current =3D vshCommandOptBool(cmd, "current"); @@ -1091,7 +1090,6 @@ cmdAttachInterface(vshControl *ctl, const vshCmd *cmd) cleanup: VIR_FREE(xml); virshDomainFree(dom); - virBufferFreeAndReset(&buf); return functionReturn; } =20 @@ -2412,7 +2410,7 @@ cmdBlockcopy(vshControl *ctl, const vshCmd *cmd) } =20 if (!xmlstr) { - virBuffer buf =3D VIR_BUFFER_INITIALIZER; + g_auto(virBuffer) buf =3D VIR_BUFFER_INITIALIZER; virBufferAsprintf(&buf, "\n", blockdev ? "block" : "file"); virBufferAdjustIndent(&buf, 2); @@ -8504,7 +8502,7 @@ cmdDesc(vshControl *ctl, const vshCmd *cmd) char *tmp =3D NULL; char *tmpstr; const vshCmdOpt *opt =3D NULL; - virBuffer buf =3D VIR_BUFFER_INITIALIZER; + g_auto(virBuffer) buf =3D VIR_BUFFER_INITIALIZER; bool ret =3D false; unsigned int flags =3D VIR_DOMAIN_AFFECT_CURRENT; =20 @@ -9642,7 +9640,7 @@ cmdQemuMonitorCommand(vshControl *ctl, const vshCmd *= cmd) g_autoptr(virJSONValue) resultjson =3D NULL; unsigned int flags =3D 0; const vshCmdOpt *opt =3D NULL; - virBuffer buf =3D VIR_BUFFER_INITIALIZER; + g_auto(virBuffer) buf =3D VIR_BUFFER_INITIALIZER; bool pretty =3D vshCommandOptBool(cmd, "pretty"); bool returnval =3D vshCommandOptBool(cmd, "return-value"); virJSONValuePtr formatjson; @@ -9956,7 +9954,7 @@ cmdQemuAgentCommand(vshControl *ctl, const vshCmd *cm= d) int judge =3D 0; unsigned int flags =3D 0; const vshCmdOpt *opt =3D NULL; - virBuffer buf =3D VIR_BUFFER_INITIALIZER; + g_auto(virBuffer) buf =3D VIR_BUFFER_INITIALIZER; virJSONValuePtr pretty =3D NULL; =20 dom =3D virshCommandOptDomain(ctl, cmd, NULL); @@ -11506,7 +11504,7 @@ cmdDomDisplay(vshControl *ctl, const vshCmd *cmd) xmlDocPtr xml =3D NULL; xmlXPathContextPtr ctxt =3D NULL; virDomainPtr dom; - virBuffer buf =3D VIR_BUFFER_INITIALIZER; + g_auto(virBuffer) buf =3D VIR_BUFFER_INITIALIZER; bool ret =3D false; char *xpath =3D NULL; char *listen_addr =3D NULL; @@ -13202,7 +13200,7 @@ virshEventGenericPrint(virConnectPtr conn G_GNUC_UN= USED, virDomainPtr dom, void *opaque) { - virBuffer buf =3D VIR_BUFFER_INITIALIZER; + g_auto(virBuffer) buf =3D VIR_BUFFER_INITIALIZER; =20 virBufferAsprintf(&buf, _("event '%s' for domain %s\n"), ((virshDomEventData *) opaque)->cb->name, @@ -13217,7 +13215,7 @@ virshEventLifecyclePrint(virConnectPtr conn G_GNUC_= UNUSED, int detail, void *opaque) { - virBuffer buf =3D VIR_BUFFER_INITIALIZER; + g_auto(virBuffer) buf =3D VIR_BUFFER_INITIALIZER; =20 virBufferAsprintf(&buf, _("event 'lifecycle' for domain %s: %s %s\n"), virDomainGetName(dom), @@ -13232,7 +13230,7 @@ virshEventRTCChangePrint(virConnectPtr conn G_GNUC_= UNUSED, long long utcoffset, void *opaque) { - virBuffer buf =3D VIR_BUFFER_INITIALIZER; + g_auto(virBuffer) buf =3D VIR_BUFFER_INITIALIZER; =20 virBufferAsprintf(&buf, _("event 'rtc-change' for domain %s: %lld\n"), virDomainGetName(dom), @@ -13246,7 +13244,7 @@ virshEventWatchdogPrint(virConnectPtr conn G_GNUC_U= NUSED, int action, void *opaque) { - virBuffer buf =3D VIR_BUFFER_INITIALIZER; + g_auto(virBuffer) buf =3D VIR_BUFFER_INITIALIZER; =20 virBufferAsprintf(&buf, _("event 'watchdog' for domain %s: %s\n"), virDomainGetName(dom), @@ -13262,7 +13260,7 @@ virshEventIOErrorPrint(virConnectPtr conn G_GNUC_UN= USED, int action, void *opaque) { - virBuffer buf =3D VIR_BUFFER_INITIALIZER; + g_auto(virBuffer) buf =3D VIR_BUFFER_INITIALIZER; =20 virBufferAsprintf(&buf, _("event 'io-error' for domain %s: %s (%s) %s\= n"), virDomainGetName(dom), @@ -13282,7 +13280,7 @@ virshEventGraphicsPrint(virConnectPtr conn G_GNUC_U= NUSED, const virDomainEventGraphicsSubject *subject, void *opaque) { - virBuffer buf =3D VIR_BUFFER_INITIALIZER; + g_auto(virBuffer) buf =3D VIR_BUFFER_INITIALIZER; size_t i; =20 virBufferAsprintf(&buf, _("event 'graphics' for domain %s: " @@ -13313,7 +13311,7 @@ virshEventIOErrorReasonPrint(virConnectPtr conn G_G= NUC_UNUSED, const char *reason, void *opaque) { - virBuffer buf =3D VIR_BUFFER_INITIALIZER; + g_auto(virBuffer) buf =3D VIR_BUFFER_INITIALIZER; =20 virBufferAsprintf(&buf, _("event 'io-error-reason' for domain %s: " "%s (%s) %s due to %s\n"), @@ -13333,7 +13331,7 @@ virshEventBlockJobPrint(virConnectPtr conn G_GNUC_U= NUSED, int status, void *opaque) { - virBuffer buf =3D VIR_BUFFER_INITIALIZER; + g_auto(virBuffer) buf =3D VIR_BUFFER_INITIALIZER; =20 virBufferAsprintf(&buf, _("event '%s' for domain %s: %s for %s %s\n"), ((virshDomEventData *) opaque)->cb->name, @@ -13353,7 +13351,7 @@ virshEventDiskChangePrint(virConnectPtr conn G_GNUC= _UNUSED, int reason, void *opaque) { - virBuffer buf =3D VIR_BUFFER_INITIALIZER; + g_auto(virBuffer) buf =3D VIR_BUFFER_INITIALIZER; =20 virBufferAsprintf(&buf, _("event 'disk-change' for domain %s disk %s: " "%s -> %s: %s\n"), @@ -13372,7 +13370,7 @@ virshEventTrayChangePrint(virConnectPtr conn G_GNUC= _UNUSED, int reason, void *opaque) { - virBuffer buf =3D VIR_BUFFER_INITIALIZER; + g_auto(virBuffer) buf =3D VIR_BUFFER_INITIALIZER; =20 virBufferAsprintf(&buf, _("event 'tray-change' for domain %s disk %s: = %s\n"), virDomainGetName(dom), @@ -13398,7 +13396,7 @@ virshEventBalloonChangePrint(virConnectPtr conn G_G= NUC_UNUSED, unsigned long long actual, void *opaque) { - virBuffer buf =3D VIR_BUFFER_INITIALIZER; + g_auto(virBuffer) buf =3D VIR_BUFFER_INITIALIZER; =20 virBufferAsprintf(&buf, _("event 'balloon-change' for domain %s: %lluK= iB\n"), virDomainGetName(dom), @@ -13412,7 +13410,7 @@ virshEventDeviceRemovedPrint(virConnectPtr conn G_G= NUC_UNUSED, const char *alias, void *opaque) { - virBuffer buf =3D VIR_BUFFER_INITIALIZER; + g_auto(virBuffer) buf =3D VIR_BUFFER_INITIALIZER; =20 virBufferAsprintf(&buf, _("event 'device-removed' for domain %s: %s\n"= ), virDomainGetName(dom), @@ -13426,7 +13424,7 @@ virshEventDeviceAddedPrint(virConnectPtr conn G_GNU= C_UNUSED, const char *alias, void *opaque) { - virBuffer buf =3D VIR_BUFFER_INITIALIZER; + g_auto(virBuffer) buf =3D VIR_BUFFER_INITIALIZER; =20 virBufferAsprintf(&buf, _("event 'device-added' for domain %s: %s\n"), virDomainGetName(dom), @@ -13441,7 +13439,7 @@ virshEventTunablePrint(virConnectPtr conn G_GNUC_UN= USED, int nparams, void *opaque) { - virBuffer buf =3D VIR_BUFFER_INITIALIZER; + g_auto(virBuffer) buf =3D VIR_BUFFER_INITIALIZER; size_t i; char *value; =20 @@ -13479,7 +13477,7 @@ virshEventAgentLifecyclePrint(virConnectPtr conn G_= GNUC_UNUSED, int reason, void *opaque) { - virBuffer buf =3D VIR_BUFFER_INITIALIZER; + g_auto(virBuffer) buf =3D VIR_BUFFER_INITIALIZER; =20 virBufferAsprintf(&buf, _("event 'agent-lifecycle' for domain %s: stat= e: " "'%s' reason: '%s'\n"), @@ -13495,7 +13493,7 @@ virshEventMigrationIterationPrint(virConnectPtr con= n G_GNUC_UNUSED, int iteration, void *opaque) { - virBuffer buf =3D VIR_BUFFER_INITIALIZER; + g_auto(virBuffer) buf =3D VIR_BUFFER_INITIALIZER; =20 virBufferAsprintf(&buf, _("event 'migration-iteration' for domain %s: " "iteration: '%d'\n"), @@ -13512,7 +13510,7 @@ virshEventJobCompletedPrint(virConnectPtr conn G_GN= UC_UNUSED, int nparams, void *opaque) { - virBuffer buf =3D VIR_BUFFER_INITIALIZER; + g_auto(virBuffer) buf =3D VIR_BUFFER_INITIALIZER; size_t i; char *value; =20 @@ -13535,7 +13533,7 @@ virshEventDeviceRemovalFailedPrint(virConnectPtr co= nn G_GNUC_UNUSED, const char *alias, void *opaque) { - virBuffer buf =3D VIR_BUFFER_INITIALIZER; + g_auto(virBuffer) buf =3D VIR_BUFFER_INITIALIZER; =20 virBufferAsprintf(&buf, _("event 'device-removal-failed' for domain %s= : %s\n"), virDomainGetName(dom), @@ -13557,7 +13555,7 @@ virshEventMetadataChangePrint(virConnectPtr conn G_= GNUC_UNUSED, const char *nsuri, void *opaque) { - virBuffer buf =3D VIR_BUFFER_INITIALIZER; + g_auto(virBuffer) buf =3D VIR_BUFFER_INITIALIZER; =20 virBufferAsprintf(&buf, _("event 'metadata-change' for domain %s: %s %= s\n"), virDomainGetName(dom), @@ -13576,7 +13574,7 @@ virshEventBlockThresholdPrint(virConnectPtr conn G_= GNUC_UNUSED, unsigned long long excess, void *opaque) { - virBuffer buf =3D VIR_BUFFER_INITIALIZER; + g_auto(virBuffer) buf =3D VIR_BUFFER_INITIALIZER; =20 virBufferAsprintf(&buf, _("event 'block-threshold' for domain %s: " "dev: %s(%s) %llu %llu\n"), @@ -14167,7 +14165,7 @@ cmdDomFSInfo(vshControl *ctl, const vshCmd *cmd) goto cleanup; =20 for (i =3D 0; i < ninfos; i++) { - virBuffer targetsBuff =3D VIR_BUFFER_INITIALIZER; + g_auto(virBuffer) targetsBuff =3D VIR_BUFFER_INITIALIZER; g_autofree char *targets =3D NULL; =20 for (j =3D 0; j < info[i]->ndevAlias; j++) diff --git a/tools/virsh-pool.c b/tools/virsh-pool.c index d190eed2b1..885e000ed2 100644 --- a/tools/virsh-pool.c +++ b/tools/virsh-pool.c @@ -325,7 +325,7 @@ virshBuildPoolXML(vshControl *ctl, *adapterWwnn =3D NULL, *adapterWwpn =3D NULL, *secretUUID = =3D NULL, *adapterParentWwnn =3D NULL, *adapterParentWwpn =3D NULL, *adapterParentFabricWwn =3D NULL, *protoVer =3D NULL; - virBuffer buf =3D VIR_BUFFER_INITIALIZER; + g_auto(virBuffer) buf =3D VIR_BUFFER_INITIALIZER; =20 VSH_EXCLUSIVE_OPTIONS("secret-usage", "secret-uuid"); =20 @@ -421,7 +421,6 @@ virshBuildPoolXML(vshControl *ctl, return true; =20 cleanup: - virBufferFreeAndReset(&buf); return false; } =20 @@ -1450,11 +1449,10 @@ cmdPoolDiscoverSourcesAs(vshControl * ctl, const vs= hCmd * cmd G_GNUC_UNUSED) =20 if (host) { const char *port =3D NULL; - virBuffer buf =3D VIR_BUFFER_INITIALIZER; + g_auto(virBuffer) buf =3D VIR_BUFFER_INITIALIZER; =20 if (vshCommandOptStringReq(ctl, cmd, "port", &port) < 0) { vshError(ctl, "%s", _("missing argument")); - virBufferFreeAndReset(&buf); return false; } virBufferAddLit(&buf, "\n"); diff --git a/tools/virsh-secret.c b/tools/virsh-secret.c index be4adc416e..7bd0acda58 100644 --- a/tools/virsh-secret.c +++ b/tools/virsh-secret.c @@ -585,7 +585,7 @@ cmdSecretList(vshControl *ctl, const vshCmd *cmd G_GNUC= _UNUSED) int usageType =3D virSecretGetUsageType(sec); const char *usageStr =3D virSecretUsageTypeToString(usageType); char uuid[VIR_UUID_STRING_BUFLEN]; - virBuffer buf =3D VIR_BUFFER_INITIALIZER; + g_auto(virBuffer) buf =3D VIR_BUFFER_INITIALIZER; g_autofree char *usage =3D NULL; =20 if (virSecretGetUUIDString(sec, uuid) < 0) { diff --git a/tools/virsh-snapshot.c b/tools/virsh-snapshot.c index d5e68e4b18..4ac6cb1dcd 100644 --- a/tools/virsh-snapshot.c +++ b/tools/virsh-snapshot.c @@ -395,7 +395,7 @@ cmdSnapshotCreateAs(vshControl *ctl, const vshCmd *cmd) const char *name =3D NULL; const char *desc =3D NULL; const char *memspec =3D NULL; - virBuffer buf =3D VIR_BUFFER_INITIALIZER; + g_auto(virBuffer) buf =3D VIR_BUFFER_INITIALIZER; unsigned int flags =3D VIR_DOMAIN_SNAPSHOT_CREATE_VALIDATE; const vshCmdOpt *opt =3D NULL; =20 @@ -456,7 +456,6 @@ cmdSnapshotCreateAs(vshControl *ctl, const vshCmd *cmd) ret =3D virshSnapshotCreate(ctl, dom, buffer, flags, NULL); =20 cleanup: - virBufferFreeAndReset(&buf); VIR_FREE(buffer); virshDomainFree(dom); =20 diff --git a/tools/virsh-volume.c b/tools/virsh-volume.c index 72394915d8..fec8278a5d 100644 --- a/tools/virsh-volume.c +++ b/tools/virsh-volume.c @@ -226,7 +226,7 @@ cmdVolCreateAs(vshControl *ctl, const vshCmd *cmd) const char *name, *capacityStr =3D NULL, *allocationStr =3D NULL, *for= mat =3D NULL; const char *snapshotStrVol =3D NULL, *snapshotStrFormat =3D NULL; unsigned long long capacity, allocation =3D 0; - virBuffer buf =3D VIR_BUFFER_INITIALIZER; + g_auto(virBuffer) buf =3D VIR_BUFFER_INITIALIZER; unsigned long flags =3D 0; virshControlPtr priv =3D ctl->privData; bool ret =3D false; @@ -356,7 +356,6 @@ cmdVolCreateAs(vshControl *ctl, const vshCmd *cmd) ret =3D true; =20 cleanup: - virBufferFreeAndReset(&buf); if (vol) virStorageVolFree(vol); virStoragePoolFree(pool); diff --git a/tools/vsh-table.c b/tools/vsh-table.c index e21514e86f..60554b7b2f 100644 --- a/tools/vsh-table.c +++ b/tools/vsh-table.c @@ -368,7 +368,7 @@ vshTablePrint(vshTablePtr table, bool header) size_t j; size_t *maxwidths; size_t **widths; - virBuffer buf =3D VIR_BUFFER_INITIALIZER; + g_auto(virBuffer) buf =3D VIR_BUFFER_INITIALIZER; char *ret =3D NULL; =20 if (VIR_ALLOC_N(maxwidths, table->rows[0]->ncells)) diff --git a/tools/vsh.c b/tools/vsh.c index 58bb1e6a3c..527c135424 100644 --- a/tools/vsh.c +++ b/tools/vsh.c @@ -2183,7 +2183,7 @@ void vshOutputLogFile(vshControl *ctl, int log_level, const char *msg_format, va_list ap) { - virBuffer buf =3D VIR_BUFFER_INITIALIZER; + g_auto(virBuffer) buf =3D VIR_BUFFER_INITIALIZER; char *str =3D NULL; size_t len; const char *lvl =3D ""; @@ -2241,7 +2241,6 @@ vshOutputLogFile(vshControl *ctl, int log_level, cons= t char *msg_format, error: vshCloseLogFile(ctl); vshError(ctl, "%s", _("failed to write the log file")); - virBufferFreeAndReset(&buf); VIR_FREE(str); } =20 @@ -2531,13 +2530,12 @@ vshTreePrint(vshControl *ctl, vshTreeLookup lookup,= void *opaque, int num_devices, int devid) { int ret; - virBuffer indent =3D VIR_BUFFER_INITIALIZER; + g_auto(virBuffer) indent =3D VIR_BUFFER_INITIALIZER; =20 ret =3D vshTreePrintInternal(ctl, lookup, opaque, num_devices, devid, devid, true, &indent); if (ret < 0) vshError(ctl, "%s", _("Failed to complete tree listing")); - virBufferFreeAndReset(&indent); return ret; } =20 @@ -2806,7 +2804,7 @@ vshReadlineParse(const char *text, int state) =20 if (ret && !rl_completion_quote_character) { - virBuffer buf =3D VIR_BUFFER_INITIALIZER; + g_auto(virBuffer) buf =3D VIR_BUFFER_INITIALIZER; virBufferEscapeShell(&buf, ret); VIR_FREE(ret); ret =3D virBufferContentAndReset(&buf); @@ -3217,7 +3215,7 @@ cmdEcho(vshControl *ctl, const vshCmd *cmd) int count =3D 0; const vshCmdOpt *opt =3D NULL; char *arg; - virBuffer buf =3D VIR_BUFFER_INITIALIZER; + g_auto(virBuffer) buf =3D VIR_BUFFER_INITIALIZER; =20 if (vshCommandOptBool(cmd, "shell")) shell =3D true; @@ -3228,7 +3226,7 @@ cmdEcho(vshControl *ctl, const vshCmd *cmd) =20 while ((opt =3D vshCommandOptArgv(ctl, cmd, opt))) { char *str; - virBuffer xmlbuf =3D VIR_BUFFER_INITIALIZER; + g_auto(virBuffer) xmlbuf =3D VIR_BUFFER_INITIALIZER; =20 arg =3D opt->data; =20 @@ -3366,7 +3364,7 @@ cmdComplete(vshControl *ctl, const vshCmd *cmd) const char *arg =3D ""; const vshCmdOpt *opt =3D NULL; char **matches =3D NULL, **iter; - virBuffer buf =3D VIR_BUFFER_INITIALIZER; + g_auto(virBuffer) buf =3D VIR_BUFFER_INITIALIZER; =20 if (vshCommandOptStringQuiet(ctl, cmd, "string", &arg) <=3D 0) goto cleanup; @@ -3406,7 +3404,6 @@ cmdComplete(vshControl *ctl, const vshCmd *cmd) =20 ret =3D true; cleanup: - virBufferFreeAndReset(&buf); virStringListFree(matches); return ret; } --=20 2.25.4 From nobody Mon May 6 01:10:47 2024 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=1594006949; cv=none; d=zohomail.com; s=zohoarc; b=dwmyHDUD6oLTaQtqbIx1J5EfrZo94DhBrgfE6Yv681OzT5GB1iJ0sI96lP9D1/YHaNxSBbNqXhrUmIuPMRyvZNhAFSTBln1dytDBgzrLrQSRH439dH3vu+ewdmUQ6uf6v5NRGAARQI7OGU6HMPLpCWay5spJqWi+KU1XyIHWDog= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1594006949; 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=RD9ggq3niSWf6FtGE1AinGVmeBnRXIEs+AsUMUI1Xuo=; b=FbEqIJcSJlErPx8TegpqER4NF+KCxBCEOC0gK13+DUdJf4B3OKddr3ZK+al2HZbwGVS6RVBsJBa6jH9n23oDIx02xm8OTBkZkkmHNq7SjQOwz5XQXZOqu96ldh9HYN/WOZSanRr0nvEAV14qy1PGwSosYxISsFzfHjg+yEFOxB4= 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 1594006949266956.7610123287402; Sun, 5 Jul 2020 20:42:29 -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-291--R08cbNHMDiqHGZZ8NXSVg-1; Sun, 05 Jul 2020 23:42:23 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id D5E908015FD; Mon, 6 Jul 2020 03:42:17 +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 667D67BEAF; Mon, 6 Jul 2020 03:42:17 +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 394FF93F7B; Mon, 6 Jul 2020 03:42:17 +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 0663fibP004471 for ; Sun, 5 Jul 2020 23:41:44 -0400 Received: by smtp.corp.redhat.com (Postfix) id DB8CF7AC9F; Mon, 6 Jul 2020 03:41:44 +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 9148971678 for ; Mon, 6 Jul 2020 03:41:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1594006946; 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=RD9ggq3niSWf6FtGE1AinGVmeBnRXIEs+AsUMUI1Xuo=; b=L7xvpr49HcDeWSaLYYtuW3OLCFD39ZqlS8DrkdSe6jXZjsQuU1bNW36M/Kni25grtcW7go Ya4At0IYxE2tLU9XH44gOIB2k4jg+icGcAIM/QZjMce85UH7Hjw2SpkjN/PZYEJE5R5qnn 0SU/d1Y2yEiKN7hy/P0NMjm6LHqwiZ4= X-MC-Unique: -R08cbNHMDiqHGZZ8NXSVg-1 From: Laine Stump To: libvir-list@redhat.com Subject: [PATCH 09/32] conf: use g_auto() for all virBuffers Date: Sun, 5 Jul 2020 23:41:04 -0400 Message-Id: <20200706034127.1117504-10-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.79 on 10.5.11.13 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/conf/capabilities.c | 8 +++----- src/conf/checkpoint_conf.c | 2 +- src/conf/cpu_conf.c | 9 +++------ src/conf/domain_addr.c | 2 +- src/conf/domain_capabilities.c | 2 +- src/conf/domain_conf.c | 12 ++++++------ src/conf/interface_conf.c | 7 +++---- src/conf/network_conf.c | 3 +-- src/conf/node_device_conf.c | 2 +- src/conf/nwfilter_conf.c | 7 +++---- src/conf/secret_conf.c | 3 +-- src/conf/snapshot_conf.c | 2 +- src/conf/storage_capabilities.c | 6 ++---- src/conf/storage_conf.c | 11 ++++------- src/conf/virnetworkobj.c | 3 +-- src/conf/virnetworkportdef.c | 6 ++---- src/conf/virnwfilterbindingdef.c | 6 ++---- src/conf/virnwfilterbindingobj.c | 6 ++---- src/conf/virsavecookie.c | 3 +-- 19 files changed, 39 insertions(+), 61 deletions(-) diff --git a/src/conf/capabilities.c b/src/conf/capabilities.c index 99b69aebb5..6a48af1fca 100644 --- a/src/conf/capabilities.c +++ b/src/conf/capabilities.c @@ -705,7 +705,7 @@ virCapabilitiesDomainDataLookupInternal(virCapsPtr caps, =20 /* XXX check default_emulator, see how it uses this */ if (!foundguest) { - virBuffer buf =3D VIR_BUFFER_INITIALIZER; + g_auto(virBuffer) buf =3D VIR_BUFFER_INITIALIZER; if (ostype) virBufferAsprintf(&buf, "ostype=3D%s ", virDomainOSTypeToString(ostype)); @@ -725,7 +725,6 @@ virCapabilitiesDomainDataLookupInternal(virCapsPtr caps, virReportError(VIR_ERR_INVALID_ARG, _("could not find capabilities for %s"), virBufferCurrentContent(&buf)); - virBufferFreeAndReset(&buf); return ret; } =20 @@ -901,7 +900,7 @@ virCapabilitiesFormatResctrlMonitor(virBufferPtr buf, virResctrlInfoMonPtr monitor) { size_t i =3D 0; - virBuffer childrenBuf =3D VIR_BUFFER_INIT_CHILD(buf); + g_auto(virBuffer) childrenBuf =3D VIR_BUFFER_INIT_CHILD(buf); =20 /* monitor not supported, no capability */ if (!monitor) @@ -1335,7 +1334,7 @@ virCapabilitiesFormatStoragePoolXML(virCapsStoragePoo= lPtr *pools, char * virCapabilitiesFormatXML(virCapsPtr caps) { - virBuffer buf =3D VIR_BUFFER_INITIALIZER; + g_auto(virBuffer) buf =3D VIR_BUFFER_INITIALIZER; =20 virBufferAddLit(&buf, "\n\n"); virBufferAdjustIndent(&buf, 2); @@ -1353,7 +1352,6 @@ virCapabilitiesFormatXML(virCapsPtr caps) return virBufferContentAndReset(&buf); =20 error: - virBufferFreeAndReset(&buf); return NULL; } =20 diff --git a/src/conf/checkpoint_conf.c b/src/conf/checkpoint_conf.c index d557fada49..e0dce9c2ed 100644 --- a/src/conf/checkpoint_conf.c +++ b/src/conf/checkpoint_conf.c @@ -502,7 +502,7 @@ virDomainCheckpointDefFormat(virDomainCheckpointDefPtr = def, virDomainXMLOptionPtr xmlopt, unsigned int flags) { - virBuffer buf =3D VIR_BUFFER_INITIALIZER; + g_auto(virBuffer) buf =3D VIR_BUFFER_INITIALIZER; =20 virCheckFlags(VIR_DOMAIN_CHECKPOINT_FORMAT_SECURE | VIR_DOMAIN_CHECKPOINT_FORMAT_NO_DOMAIN | diff --git a/src/conf/cpu_conf.c b/src/conf/cpu_conf.c index e1b0a5653f..dd3db00bc8 100644 --- a/src/conf/cpu_conf.c +++ b/src/conf/cpu_conf.c @@ -668,7 +668,7 @@ char * virCPUDefFormat(virCPUDefPtr def, virDomainNumaPtr numa) { - virBuffer buf =3D VIR_BUFFER_INITIALIZER; + g_auto(virBuffer) buf =3D VIR_BUFFER_INITIALIZER; =20 if (virCPUDefFormatBufFull(&buf, def, numa) < 0) goto cleanup; @@ -676,7 +676,6 @@ virCPUDefFormat(virCPUDefPtr def, return virBufferContentAndReset(&buf); =20 cleanup: - virBufferFreeAndReset(&buf); return NULL; } =20 @@ -687,8 +686,8 @@ virCPUDefFormatBufFull(virBufferPtr buf, virDomainNumaPtr numa) { int ret =3D -1; - virBuffer attributeBuf =3D VIR_BUFFER_INITIALIZER; - virBuffer childrenBuf =3D VIR_BUFFER_INIT_CHILD(buf); + g_auto(virBuffer) attributeBuf =3D VIR_BUFFER_INITIALIZER; + g_auto(virBuffer) childrenBuf =3D VIR_BUFFER_INIT_CHILD(buf); =20 if (!def) return 0; @@ -755,8 +754,6 @@ virCPUDefFormatBufFull(virBufferPtr buf, =20 ret =3D 0; cleanup: - virBufferFreeAndReset(&attributeBuf); - virBufferFreeAndReset(&childrenBuf); return ret; } =20 diff --git a/src/conf/domain_addr.c b/src/conf/domain_addr.c index 2f9ff899d7..1068cbf1d2 100644 --- a/src/conf/domain_addr.c +++ b/src/conf/domain_addr.c @@ -1941,7 +1941,7 @@ virDomainUSBAddressPortFormatBuf(virBufferPtr buf, static char * ATTRIBUTE_NONNULL(1) virDomainUSBAddressPortFormat(unsigned int *port) { - virBuffer buf =3D VIR_BUFFER_INITIALIZER; + g_auto(virBuffer) buf =3D VIR_BUFFER_INITIALIZER; virDomainUSBAddressPortFormatBuf(&buf, port); return virBufferContentAndReset(&buf); } diff --git a/src/conf/domain_capabilities.c b/src/conf/domain_capabilities.c index 0fa8aee78e..837b004334 100644 --- a/src/conf/domain_capabilities.c +++ b/src/conf/domain_capabilities.c @@ -596,7 +596,7 @@ virDomainCapsFormatFeatures(const virDomainCaps *caps, char * virDomainCapsFormat(const virDomainCaps *caps) { - virBuffer buf =3D VIR_BUFFER_INITIALIZER; + g_auto(virBuffer) buf =3D VIR_BUFFER_INITIALIZER; const char *virttype_str =3D virDomainVirtTypeToString(caps->virttype); const char *arch_str =3D virArchToString(caps->arch); =20 diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index f076c0718c..c02d1c8bd2 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -25332,7 +25332,7 @@ static int virDomainDiskDefFormatIotune(virBufferPtr buf, virDomainDiskDefPtr disk) { - virBuffer childBuf =3D VIR_BUFFER_INIT_CHILD(buf); + g_auto(virBuffer) childBuf =3D VIR_BUFFER_INIT_CHILD(buf); =20 FORMAT_IOTUNE(total_bytes_sec); FORMAT_IOTUNE(read_bytes_sec); @@ -25377,7 +25377,7 @@ static int virDomainDiskDefFormatDriver(virBufferPtr buf, virDomainDiskDefPtr disk) { - virBuffer driverBuf =3D VIR_BUFFER_INITIALIZER; + g_auto(virBuffer) driverBuf =3D VIR_BUFFER_INITIALIZER; =20 virBufferEscapeString(&driverBuf, " name=3D'%s'", virDomainDiskGetDriv= er(disk)); =20 @@ -26361,7 +26361,7 @@ static int virDomainVirtioNetGuestOptsFormat(char **outstr, virDomainNetDefPtr def) { - virBuffer buf =3D VIR_BUFFER_INITIALIZER; + g_auto(virBuffer) buf =3D VIR_BUFFER_INITIALIZER; if (def->driver.virtio.guest.csum) { virBufferAsprintf(&buf, "csum=3D'%s' ", virTristateSwitchTypeToString(def->driver.virtio= .guest.csum)); @@ -26393,7 +26393,7 @@ static int virDomainVirtioNetHostOptsFormat(char **outstr, virDomainNetDefPtr def) { - virBuffer buf =3D VIR_BUFFER_INITIALIZER; + g_auto(virBuffer) buf =3D VIR_BUFFER_INITIALIZER; if (def->driver.virtio.host.csum) { virBufferAsprintf(&buf, "csum=3D'%s' ", virTristateSwitchTypeToString(def->driver.virtio= .host.csum)); @@ -26433,7 +26433,7 @@ static int virDomainVirtioNetDriverFormat(char **outstr, virDomainNetDefPtr def) { - virBuffer buf =3D VIR_BUFFER_INITIALIZER; + g_auto(virBuffer) buf =3D VIR_BUFFER_INITIALIZER; if (def->driver.virtio.name) { virBufferAsprintf(&buf, " name=3D'%s'", virDomainNetBackendTypeToString(def->driver.virt= io.name)); @@ -30065,7 +30065,7 @@ virDomainDefFormat(virDomainDefPtr def, virDomainXMLOptionPtr xmlopt, unsigned int flags) { - virBuffer buf =3D VIR_BUFFER_INITIALIZER; + g_auto(virBuffer) buf =3D VIR_BUFFER_INITIALIZER; =20 virCheckFlags(VIR_DOMAIN_DEF_FORMAT_COMMON_FLAGS, NULL); if (virDomainDefFormatInternal(def, xmlopt, &buf, flags) < 0) diff --git a/src/conf/interface_conf.c b/src/conf/interface_conf.c index be5e1133a2..76f7054721 100644 --- a/src/conf/interface_conf.c +++ b/src/conf/interface_conf.c @@ -1122,11 +1122,10 @@ virInterfaceDefDevFormat(virBufferPtr buf, char * virInterfaceDefFormat(const virInterfaceDef *def) { - virBuffer buf =3D VIR_BUFFER_INITIALIZER; + g_auto(virBuffer) buf =3D VIR_BUFFER_INITIALIZER; =20 - if (virInterfaceDefDevFormat(&buf, def, VIR_INTERFACE_TYPE_LAST) < 0) { - virBufferFreeAndReset(&buf); + if (virInterfaceDefDevFormat(&buf, def, VIR_INTERFACE_TYPE_LAST) < 0) return NULL; - } + return virBufferContentAndReset(&buf); } diff --git a/src/conf/network_conf.c b/src/conf/network_conf.c index 4ebad1483c..99f11fdf05 100644 --- a/src/conf/network_conf.c +++ b/src/conf/network_conf.c @@ -2718,7 +2718,7 @@ virNetworkDefFormat(const virNetworkDef *def, virNetworkXMLOptionPtr xmlopt, unsigned int flags) { - virBuffer buf =3D VIR_BUFFER_INITIALIZER; + g_auto(virBuffer) buf =3D VIR_BUFFER_INITIALIZER; =20 if (virNetworkDefFormatBuf(&buf, def, xmlopt, flags) < 0) goto error; @@ -2726,7 +2726,6 @@ virNetworkDefFormat(const virNetworkDef *def, return virBufferContentAndReset(&buf); =20 error: - virBufferFreeAndReset(&buf); return NULL; } =20 diff --git a/src/conf/node_device_conf.c b/src/conf/node_device_conf.c index 78a537d0ea..c54015336a 100644 --- a/src/conf/node_device_conf.c +++ b/src/conf/node_device_conf.c @@ -520,7 +520,7 @@ virNodeDeviceCapMdevDefFormat(virBufferPtr buf, char * virNodeDeviceDefFormat(const virNodeDeviceDef *def) { - virBuffer buf =3D VIR_BUFFER_INITIALIZER; + g_auto(virBuffer) buf =3D VIR_BUFFER_INITIALIZER; virNodeDevCapsDefPtr caps; size_t i =3D 0; =20 diff --git a/src/conf/nwfilter_conf.c b/src/conf/nwfilter_conf.c index 732c05ac89..3827c65462 100644 --- a/src/conf/nwfilter_conf.c +++ b/src/conf/nwfilter_conf.c @@ -948,7 +948,7 @@ printTCPFlags(virBufferPtr buf, char * virNWFilterPrintTCPFlags(uint8_t flags) { - virBuffer buf =3D VIR_BUFFER_INITIALIZER; + g_auto(virBuffer) buf =3D VIR_BUFFER_INITIALIZER; printTCPFlags(&buf, flags); return virBufferContentAndReset(&buf); } @@ -2561,7 +2561,7 @@ virNWFilterIsAllowedChain(const char *chainname) virNWFilterChainSuffixType i; const char *name; char *msg; - virBuffer buf =3D VIR_BUFFER_INITIALIZER; + g_auto(virBuffer) buf =3D VIR_BUFFER_INITIALIZER; bool printed =3D false; =20 if (!virNWFilterIsValidChainName(chainname)) @@ -3044,7 +3044,7 @@ virNWFilterEntryFormat(virBufferPtr buf, char * virNWFilterDefFormat(const virNWFilterDef *def) { - virBuffer buf =3D VIR_BUFFER_INITIALIZER; + g_auto(virBuffer) buf =3D VIR_BUFFER_INITIALIZER; char uuid[VIR_UUID_STRING_BUFLEN]; size_t i; =20 @@ -3071,7 +3071,6 @@ virNWFilterDefFormat(const virNWFilterDef *def) return virBufferContentAndReset(&buf); =20 err_exit: - virBufferFreeAndReset(&buf); return NULL; } =20 diff --git a/src/conf/secret_conf.c b/src/conf/secret_conf.c index 0ec9bce987..3960cf04ad 100644 --- a/src/conf/secret_conf.c +++ b/src/conf/secret_conf.c @@ -277,7 +277,7 @@ virSecretDefFormatUsage(virBufferPtr buf, char * virSecretDefFormat(const virSecretDef *def) { - virBuffer buf =3D VIR_BUFFER_INITIALIZER; + g_auto(virBuffer) buf =3D VIR_BUFFER_INITIALIZER; const unsigned char *uuid; char uuidstr[VIR_UUID_STRING_BUFLEN]; =20 @@ -301,6 +301,5 @@ virSecretDefFormat(const virSecretDef *def) return virBufferContentAndReset(&buf); =20 error: - virBufferFreeAndReset(&buf); return NULL; } diff --git a/src/conf/snapshot_conf.c b/src/conf/snapshot_conf.c index f73eeb06c7..9767592bfc 100644 --- a/src/conf/snapshot_conf.c +++ b/src/conf/snapshot_conf.c @@ -927,7 +927,7 @@ virDomainSnapshotDefFormat(const char *uuidstr, virDomainXMLOptionPtr xmlopt, unsigned int flags) { - virBuffer buf =3D VIR_BUFFER_INITIALIZER; + g_auto(virBuffer) buf =3D VIR_BUFFER_INITIALIZER; =20 virCheckFlags(VIR_DOMAIN_SNAPSHOT_FORMAT_SECURE | VIR_DOMAIN_SNAPSHOT_FORMAT_INTERNAL | diff --git a/src/conf/storage_capabilities.c b/src/conf/storage_capabilitie= s.c index 1a3417f90b..cac238c4f2 100644 --- a/src/conf/storage_capabilities.c +++ b/src/conf/storage_capabilities.c @@ -117,16 +117,14 @@ virStoragePoolCapsFormatPool(virBufferPtr buf, char * virStoragePoolCapsFormat(const virStoragePoolCaps *caps) { - virBuffer buf =3D VIR_BUFFER_INITIALIZER; + g_auto(virBuffer) buf =3D VIR_BUFFER_INITIALIZER; size_t i; =20 virBufferAddLit(&buf, "\n"); virBufferAdjustIndent(&buf, 2); for (i =3D 0; i < VIR_STORAGE_POOL_LAST; i++) { - if (virStoragePoolCapsFormatPool(&buf, i, caps) < 0) { - virBufferFreeAndReset(&buf); + if (virStoragePoolCapsFormatPool(&buf, i, caps) < 0) return NULL; - } } virBufferAdjustIndent(&buf, -2); virBufferAddLit(&buf, "\n"); diff --git a/src/conf/storage_conf.c b/src/conf/storage_conf.c index 5669b92f8d..7bc743887c 100644 --- a/src/conf/storage_conf.c +++ b/src/conf/storage_conf.c @@ -1223,7 +1223,7 @@ virStoragePoolDefFormatBuf(virBufferPtr buf, char * virStoragePoolDefFormat(virStoragePoolDefPtr def) { - virBuffer buf =3D VIR_BUFFER_INITIALIZER; + g_auto(virBuffer) buf =3D VIR_BUFFER_INITIALIZER; =20 if (virStoragePoolDefFormatBuf(&buf, def) < 0) goto error; @@ -1231,7 +1231,6 @@ virStoragePoolDefFormat(virStoragePoolDefPtr def) return virBufferContentAndReset(&buf); =20 error: - virBufferFreeAndReset(&buf); return NULL; } =20 @@ -1594,7 +1593,7 @@ virStorageVolDefFormat(virStoragePoolDefPtr pool, virStorageVolDefPtr def) { virStorageVolOptionsPtr options; - virBuffer buf =3D VIR_BUFFER_INITIALIZER; + g_auto(virBuffer) buf =3D VIR_BUFFER_INITIALIZER; =20 options =3D virStorageVolOptionsForPoolType(pool->type); if (options =3D=3D NULL) @@ -1663,7 +1662,6 @@ virStorageVolDefFormat(virStoragePoolDefPtr pool, return virBufferContentAndReset(&buf); =20 cleanup: - virBufferFreeAndReset(&buf); return NULL; } =20 @@ -1686,7 +1684,7 @@ int virStoragePoolSaveState(const char *stateFile, virStoragePoolDefPtr def) { - virBuffer buf =3D VIR_BUFFER_INITIALIZER; + g_auto(virBuffer) buf =3D VIR_BUFFER_INITIALIZER; g_autofree char *xml =3D NULL; =20 virBufferAddLit(&buf, "\n"); @@ -1743,7 +1741,7 @@ char * virStoragePoolSourceListFormat(virStoragePoolSourceListPtr def) { virStoragePoolOptionsPtr options; - virBuffer buf =3D VIR_BUFFER_INITIALIZER; + g_auto(virBuffer) buf =3D VIR_BUFFER_INITIALIZER; const char *type; size_t i; =20 @@ -1770,6 +1768,5 @@ virStoragePoolSourceListFormat(virStoragePoolSourceLi= stPtr def) return virBufferContentAndReset(&buf); =20 cleanup: - virBufferFreeAndReset(&buf); return NULL; } diff --git a/src/conf/virnetworkobj.c b/src/conf/virnetworkobj.c index b2affaacd3..5d90dec2bc 100644 --- a/src/conf/virnetworkobj.c +++ b/src/conf/virnetworkobj.c @@ -815,7 +815,7 @@ virNetworkObjFormat(virNetworkObjPtr obj, virNetworkXMLOptionPtr xmlopt, unsigned int flags) { - virBuffer buf =3D VIR_BUFFER_INITIALIZER; + g_auto(virBuffer) buf =3D VIR_BUFFER_INITIALIZER; char *classIdStr =3D virBitmapFormat(obj->classIdMap); size_t i; =20 @@ -843,7 +843,6 @@ virNetworkObjFormat(virNetworkObjPtr obj, return virBufferContentAndReset(&buf); =20 error: - virBufferFreeAndReset(&buf); return NULL; } =20 diff --git a/src/conf/virnetworkportdef.c b/src/conf/virnetworkportdef.c index 2013e11dff..1db3dc69e2 100644 --- a/src/conf/virnetworkportdef.c +++ b/src/conf/virnetworkportdef.c @@ -324,12 +324,10 @@ virNetworkPortDefParseFile(const char *filename) char * virNetworkPortDefFormat(const virNetworkPortDef *def) { - virBuffer buf =3D VIR_BUFFER_INITIALIZER; + g_auto(virBuffer) buf =3D VIR_BUFFER_INITIALIZER; =20 - if (virNetworkPortDefFormatBuf(&buf, def) < 0) { - virBufferFreeAndReset(&buf); + if (virNetworkPortDefFormatBuf(&buf, def) < 0) return NULL; - } =20 return virBufferContentAndReset(&buf); } diff --git a/src/conf/virnwfilterbindingdef.c b/src/conf/virnwfilterbinding= def.c index 7d813353ef..f286bdd840 100644 --- a/src/conf/virnwfilterbindingdef.c +++ b/src/conf/virnwfilterbindingdef.c @@ -223,12 +223,10 @@ virNWFilterBindingDefParseFile(const char *filename) char * virNWFilterBindingDefFormat(const virNWFilterBindingDef *def) { - virBuffer buf =3D VIR_BUFFER_INITIALIZER; + g_auto(virBuffer) buf =3D VIR_BUFFER_INITIALIZER; =20 - if (virNWFilterBindingDefFormatBuf(&buf, def) < 0) { - virBufferFreeAndReset(&buf); + if (virNWFilterBindingDefFormatBuf(&buf, def) < 0) return NULL; - } =20 return virBufferContentAndReset(&buf); } diff --git a/src/conf/virnwfilterbindingobj.c b/src/conf/virnwfilterbinding= obj.c index 7cfc2e9efa..584721f8b6 100644 --- a/src/conf/virnwfilterbindingobj.c +++ b/src/conf/virnwfilterbindingobj.c @@ -284,16 +284,14 @@ virNWFilterBindingObjParseFile(const char *filename) char * virNWFilterBindingObjFormat(const virNWFilterBindingObj *obj) { - virBuffer buf =3D VIR_BUFFER_INITIALIZER; + g_auto(virBuffer) buf =3D VIR_BUFFER_INITIALIZER; =20 virBufferAddLit(&buf, "\n"); =20 virBufferAdjustIndent(&buf, 2); =20 - if (virNWFilterBindingDefFormatBuf(&buf, obj->def) < 0) { - virBufferFreeAndReset(&buf); + if (virNWFilterBindingDefFormatBuf(&buf, obj->def) < 0) return NULL; - } =20 virBufferAdjustIndent(&buf, -2); virBufferAddLit(&buf, "\n"); diff --git a/src/conf/virsavecookie.c b/src/conf/virsavecookie.c index 7fc951afe2..429daf69be 100644 --- a/src/conf/virsavecookie.c +++ b/src/conf/virsavecookie.c @@ -127,7 +127,7 @@ char * virSaveCookieFormat(virObjectPtr obj, virSaveCookieCallbacksPtr saveCookie) { - virBuffer buf =3D VIR_BUFFER_INITIALIZER; + g_auto(virBuffer) buf =3D VIR_BUFFER_INITIALIZER; =20 if (virSaveCookieFormatBuf(&buf, obj, saveCookie) < 0) goto error; @@ -135,6 +135,5 @@ virSaveCookieFormat(virObjectPtr obj, return virBufferContentAndReset(&buf); =20 error: - virBufferFreeAndReset(&buf); return NULL; } --=20 2.25.4 From nobody Mon May 6 01:10:47 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 205.139.110.61 as permitted sender) client-ip=205.139.110.61; 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 205.139.110.61 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=1594007110; cv=none; d=zohomail.com; s=zohoarc; b=UNbEqMg+Gf+BcKsijVWIMylkgafQOHD1LocdWy1F5ewTle5xI5TzU7s1Sj7HKrQ5rVVRCaFpWocVXbchxmwoUba8LgD6tXQbgAGVgKGd7ADCe3F3Bhkf2CyTKaX5Zo0URiHy0qonihJg89LXIPZw03IDPO7wYN3CpAbrf1LDzms= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1594007110; 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=KfecOwj0fr0Q45asK1XBZRPmhjccQO24H3vjDIaCeZ8=; b=K1YrkjrdjlyqnLFtGkgtgZ6NA6usED3Hn0rsjHku3iKoJRxt8ZIOo2EA5LB6ACohebfyFqli1nksiJQ+jYJjevqjXYt2ZBiiJpuR5Bm44yPsKgY5CS3+S3ZVbdhgsA42m735aCnG5qnkrX9wufg3YMnJ1AeM2M4WQJ1dyfQiTYo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.61 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 [205.139.110.61]) by mx.zohomail.com with SMTPS id 1594007110068317.9671679414952; Sun, 5 Jul 2020 20:45:10 -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-421-S9l0WXrAOI2ngaJcXOSMnA-1; Sun, 05 Jul 2020 23:42:19 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 5F941108BD0A; Mon, 6 Jul 2020 03:42:14 +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 3FA052DE74; Mon, 6 Jul 2020 03:42:14 +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 122C0180597C; Mon, 6 Jul 2020 03:42:14 +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 0663fjDi004480 for ; Sun, 5 Jul 2020 23:41:45 -0400 Received: by smtp.corp.redhat.com (Postfix) id 62A4971678; Mon, 6 Jul 2020 03:41:45 +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 17A91275E20 for ; Mon, 6 Jul 2020 03:41:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1594007108; 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=KfecOwj0fr0Q45asK1XBZRPmhjccQO24H3vjDIaCeZ8=; b=WPqXq9JQkMpMwJxkBQv5ZBDop5zL2wuyoJ309hwA6v3oN0y58z2w1xnhnGre9ZvpvQkLgE 4pKy5v/rb2momaRkWJ+ynzazW9uTmGH4Pp3BuD2TgPfVJUx+o6Vs4D32c0ahHMDHZrtOo+ msLKkcYA9ig+w/d6mG/VD26aCmUJZpw= X-MC-Unique: S9l0WXrAOI2ngaJcXOSMnA-1 From: Laine Stump To: libvir-list@redhat.com Subject: [PATCH 10/32] util: use g_auto() for all virBuffers Date: Sun, 5 Jul 2020 23:41:05 -0400 Message-Id: <20200706034127.1117504-11-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.23 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/util/virbitmap.c | 4 ++-- src/util/vircommand.c | 3 +-- src/util/virconf.c | 5 ++--- src/util/virdnsmasq.c | 6 ++---- src/util/virfile.c | 2 +- src/util/virfilecache.c | 2 +- src/util/virfirewall.c | 2 +- src/util/virlog.c | 5 ++--- src/util/virnetdevip.c | 3 +-- src/util/virpidfile.c | 2 +- src/util/virqemu.c | 3 +-- src/util/virresctrl.c | 10 +++------- src/util/virsocketaddr.c | 3 +-- src/util/virstoragefile.c | 2 +- src/util/virstring.c | 4 ++-- src/util/virsysinfo.c | 4 ++-- src/util/virsystemd.c | 4 ++-- src/util/viruri.c | 2 +- src/util/virxml.c | 3 +-- 19 files changed, 28 insertions(+), 41 deletions(-) diff --git a/src/util/virbitmap.c b/src/util/virbitmap.c index d38a2dd7e9..60fd8491dd 100644 --- a/src/util/virbitmap.c +++ b/src/util/virbitmap.c @@ -345,7 +345,7 @@ virBitmapToString(virBitmapPtr bitmap, bool prefix, bool trim) { - virBuffer buf =3D VIR_BUFFER_INITIALIZER; + g_auto(virBuffer) buf =3D VIR_BUFFER_INITIALIZER; size_t sz; size_t len; size_t diff; @@ -404,7 +404,7 @@ virBitmapToString(virBitmapPtr bitmap, char * virBitmapFormat(virBitmapPtr bitmap) { - virBuffer buf =3D VIR_BUFFER_INITIALIZER; + g_auto(virBuffer) buf =3D VIR_BUFFER_INITIALIZER; bool first =3D true; int start, cur, prev; =20 diff --git a/src/util/vircommand.c b/src/util/vircommand.c index aae0ddb730..e21116b232 100644 --- a/src/util/vircommand.c +++ b/src/util/vircommand.c @@ -2080,7 +2080,7 @@ char * virCommandToString(virCommandPtr cmd, bool linebreaks) { size_t i; - virBuffer buf =3D VIR_BUFFER_INITIALIZER; + g_auto(virBuffer) buf =3D VIR_BUFFER_INITIALIZER; bool prevopt =3D false; =20 /* Cannot assume virCommandRun will be called; so report the error @@ -2101,7 +2101,6 @@ virCommandToString(virCommandPtr cmd, bool linebreaks) char *eq =3D strchr(cmd->env[i], '=3D'); =20 if (!eq) { - virBufferFreeAndReset(&buf); virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("invalid use of command API")); return NULL; diff --git a/src/util/virconf.c b/src/util/virconf.c index f79024f07a..77ca3f9b79 100644 --- a/src/util/virconf.c +++ b/src/util/virconf.c @@ -1419,7 +1419,7 @@ int virConfWalk(virConfPtr conf, int virConfWriteFile(const char *filename, virConfPtr conf) { - virBuffer buf =3D VIR_BUFFER_INITIALIZER; + g_auto(virBuffer) buf =3D VIR_BUFFER_INITIALIZER; virConfEntryPtr cur; int ret; int fd; @@ -1437,7 +1437,6 @@ virConfWriteFile(const char *filename, virConfPtr con= f) =20 fd =3D open(filename, O_WRONLY | O_CREAT | O_TRUNC, S_IRUSR | S_IWUSR); if (fd < 0) { - virBufferFreeAndReset(&buf); virConfError(NULL, VIR_ERR_WRITE_FAILED, _("failed to open file")); return -1; } @@ -1471,7 +1470,7 @@ virConfWriteFile(const char *filename, virConfPtr con= f) int virConfWriteMem(char *memory, int *len, virConfPtr conf) { - virBuffer buf =3D VIR_BUFFER_INITIALIZER; + g_auto(virBuffer) buf =3D VIR_BUFFER_INITIALIZER; virConfEntryPtr cur; char *content; unsigned int use; diff --git a/src/util/virdnsmasq.c b/src/util/virdnsmasq.c index 818219fbeb..b22d4622d5 100644 --- a/src/util/virdnsmasq.c +++ b/src/util/virdnsmasq.c @@ -139,7 +139,7 @@ addnhostsNew(const char *name, const char *config_dir) { dnsmasqAddnHostsfile *addnhostsfile; - virBuffer buf =3D VIR_BUFFER_INITIALIZER; + g_auto(virBuffer) buf =3D VIR_BUFFER_INITIALIZER; =20 if (VIR_ALLOC(addnhostsfile) < 0) return NULL; @@ -157,7 +157,6 @@ addnhostsNew(const char *name, return addnhostsfile; =20 error: - virBufferFreeAndReset(&buf); addnhostsFree(addnhostsfile); return NULL; } @@ -342,7 +341,7 @@ hostsfileNew(const char *name, const char *config_dir) { dnsmasqHostsfile *hostsfile; - virBuffer buf =3D VIR_BUFFER_INITIALIZER; + g_auto(virBuffer) buf =3D VIR_BUFFER_INITIALIZER; =20 if (VIR_ALLOC(hostsfile) < 0) return NULL; @@ -359,7 +358,6 @@ hostsfileNew(const char *name, return hostsfile; =20 error: - virBufferFreeAndReset(&buf); hostsfileFree(hostsfile); return NULL; } diff --git a/src/util/virfile.c b/src/util/virfile.c index c034df5931..213acdbcaa 100644 --- a/src/util/virfile.c +++ b/src/util/virfile.c @@ -1303,7 +1303,7 @@ int virBuildPathInternal(char **path, ...) { char *path_component =3D NULL; - virBuffer buf =3D VIR_BUFFER_INITIALIZER; + g_auto(virBuffer) buf =3D VIR_BUFFER_INITIALIZER; va_list ap; int ret =3D 0; =20 diff --git a/src/util/virfilecache.c b/src/util/virfilecache.c index 2162917b11..195587e6bd 100644 --- a/src/util/virfilecache.c +++ b/src/util/virfilecache.c @@ -101,7 +101,7 @@ virFileCacheGetFileName(virFileCachePtr cache, const char *name) { g_autofree char *namehash =3D NULL; - virBuffer buf =3D VIR_BUFFER_INITIALIZER; + g_auto(virBuffer) buf =3D VIR_BUFFER_INITIALIZER; =20 if (virCryptoHashString(VIR_CRYPTO_HASH_SHA256, name, &namehash) < 0) return NULL; diff --git a/src/util/virfirewall.c b/src/util/virfirewall.c index 22760e6389..12905165d4 100644 --- a/src/util/virfirewall.c +++ b/src/util/virfirewall.c @@ -641,7 +641,7 @@ static char * virFirewallRuleToString(virFirewallRulePtr rule) { const char *bin =3D virFirewallLayerCommandTypeToString(rule->layer); - virBuffer buf =3D VIR_BUFFER_INITIALIZER; + g_auto(virBuffer) buf =3D VIR_BUFFER_INITIALIZER; size_t i; =20 virBufferAdd(&buf, bin, -1); diff --git a/src/util/virlog.c b/src/util/virlog.c index 2c18eeed03..dabfe7e501 100644 --- a/src/util/virlog.c +++ b/src/util/virlog.c @@ -1071,7 +1071,7 @@ char * virLogGetFilters(void) { size_t i; - virBuffer filterbuf =3D VIR_BUFFER_INITIALIZER; + g_auto(virBuffer) filterbuf =3D VIR_BUFFER_INITIALIZER; =20 virLogLock(); for (i =3D 0; i < virLogNbFilters; i++) { @@ -1098,7 +1098,7 @@ char * virLogGetOutputs(void) { size_t i; - virBuffer outputbuf =3D VIR_BUFFER_INITIALIZER; + g_auto(virBuffer) outputbuf =3D VIR_BUFFER_INITIALIZER; =20 virLogLock(); for (i =3D 0; i < virLogNbOutputs; i++) { @@ -1131,7 +1131,6 @@ virLogGetOutputs(void) =20 error: virLogUnlock(); - virBufferFreeAndReset(&outputbuf); return NULL; } =20 diff --git a/src/util/virnetdevip.c b/src/util/virnetdevip.c index cb624c7eec..ba9e567e5a 100644 --- a/src/util/virnetdevip.c +++ b/src/util/virnetdevip.c @@ -660,7 +660,7 @@ virNetDevIPCheckIPv6Forwarding(void) } =20 if (!valid) { - virBuffer buf =3D VIR_BUFFER_INITIALIZER; + g_auto(virBuffer) buf =3D VIR_BUFFER_INITIALIZER; for (i =3D 0; i < data.ndevices; i++) { virBufferAdd(&buf, data.devices[i], -1); if (i < data.ndevices - 1) @@ -672,7 +672,6 @@ virNetDevIPCheckIPv6Forwarding(void) "RA routes without accept_ra set to 2 is likely t= o cause " "routes loss. Interfaces to look at: %s"), virBufferCurrentContent(&buf)); - virBufferFreeAndReset(&buf); } =20 cleanup: diff --git a/src/util/virpidfile.c b/src/util/virpidfile.c index 1a6fbdc552..895eb83ea9 100644 --- a/src/util/virpidfile.c +++ b/src/util/virpidfile.c @@ -42,7 +42,7 @@ VIR_LOG_INIT("util.pidfile"); =20 char *virPidFileBuildPath(const char *dir, const char* name) { - virBuffer buf =3D VIR_BUFFER_INITIALIZER; + g_auto(virBuffer) buf =3D VIR_BUFFER_INITIALIZER; =20 virBufferAsprintf(&buf, "%s", dir); virBufferEscapeString(&buf, "/%s.pid", name); diff --git a/src/util/virqemu.c b/src/util/virqemu.c index 321ddeb7e3..52f3a2ca12 100644 --- a/src/util/virqemu.c +++ b/src/util/virqemu.c @@ -360,7 +360,7 @@ virQEMUBuildObjectCommandlineFromJSON(virBufferPtr buf, char * virQEMUBuildDriveCommandlineFromJSON(virJSONValuePtr srcdef) { - virBuffer buf =3D VIR_BUFFER_INITIALIZER; + g_auto(virBuffer) buf =3D VIR_BUFFER_INITIALIZER; char *ret =3D NULL; =20 if (virQEMUBuildCommandLineJSON(srcdef, &buf, NULL, false, @@ -370,7 +370,6 @@ virQEMUBuildDriveCommandlineFromJSON(virJSONValuePtr sr= cdef) ret =3D virBufferContentAndReset(&buf); =20 cleanup: - virBufferFreeAndReset(&buf); return ret; } =20 diff --git a/src/util/virresctrl.c b/src/util/virresctrl.c index e17f6bd1bd..33044da3a1 100644 --- a/src/util/virresctrl.c +++ b/src/util/virresctrl.c @@ -1587,20 +1587,16 @@ virResctrlAllocFormatCache(virResctrlAllocPtr alloc, char * virResctrlAllocFormat(virResctrlAllocPtr alloc) { - virBuffer buf =3D VIR_BUFFER_INITIALIZER; + g_auto(virBuffer) buf =3D VIR_BUFFER_INITIALIZER; =20 if (!alloc) return NULL; =20 - if (virResctrlAllocFormatCache(alloc, &buf) < 0) { - virBufferFreeAndReset(&buf); + if (virResctrlAllocFormatCache(alloc, &buf) < 0) return NULL; - } =20 - if (virResctrlAllocMemoryBandwidthFormat(alloc, &buf) < 0) { - virBufferFreeAndReset(&buf); + if (virResctrlAllocMemoryBandwidthFormat(alloc, &buf) < 0) return NULL; - } =20 return virBufferContentAndReset(&buf); } diff --git a/src/util/virsocketaddr.c b/src/util/virsocketaddr.c index a858a69204..0fda8e101b 100644 --- a/src/util/virsocketaddr.c +++ b/src/util/virsocketaddr.c @@ -1263,7 +1263,7 @@ virSocketAddrPTRDomain(const virSocketAddr *addr, unsigned int prefix, char **ptr) { - virBuffer buf =3D VIR_BUFFER_INITIALIZER; + g_auto(virBuffer) buf =3D VIR_BUFFER_INITIALIZER; size_t i; int ret =3D -1; =20 @@ -1303,7 +1303,6 @@ virSocketAddrPTRDomain(const virSocketAddr *addr, ret =3D 0; =20 cleanup: - virBufferFreeAndReset(&buf); return ret; =20 unsupported: diff --git a/src/util/virstoragefile.c b/src/util/virstoragefile.c index a6357abb08..274883c4bd 100644 --- a/src/util/virstoragefile.c +++ b/src/util/virstoragefile.c @@ -4255,7 +4255,7 @@ virStorageFileCanonicalizeFormatPath(char **component= s, bool beginSlash, bool beginDoubleSlash) { - virBuffer buf =3D VIR_BUFFER_INITIALIZER; + g_auto(virBuffer) buf =3D VIR_BUFFER_INITIALIZER; size_t i; char *ret =3D NULL; =20 diff --git a/src/util/virstring.c b/src/util/virstring.c index e9e792f3bf..2d7ddc4676 100644 --- a/src/util/virstring.c +++ b/src/util/virstring.c @@ -148,7 +148,7 @@ char *virStringListJoin(const char **strings, const char *delim) { char *ret; - virBuffer buf =3D VIR_BUFFER_INITIALIZER; + g_auto(virBuffer) buf =3D VIR_BUFFER_INITIALIZER; while (*strings) { virBufferAdd(&buf, *strings, -1); if (*(strings+1)) @@ -1069,7 +1069,7 @@ virStringReplace(const char *haystack, const char *oldneedle, const char *newneedle) { - virBuffer buf =3D VIR_BUFFER_INITIALIZER; + g_auto(virBuffer) buf =3D VIR_BUFFER_INITIALIZER; const char *tmp1, *tmp2; size_t oldneedlelen =3D strlen(oldneedle); size_t newneedlelen =3D strlen(newneedle); diff --git a/src/util/virsysinfo.c b/src/util/virsysinfo.c index db84339bda..dbca99c1ef 100644 --- a/src/util/virsysinfo.c +++ b/src/util/virsysinfo.c @@ -1573,8 +1573,8 @@ virSysinfoFormatFWCfg(virBufferPtr buf, int virSysinfoFormat(virBufferPtr buf, virSysinfoDefPtr def) { - virBuffer attrBuf =3D VIR_BUFFER_INITIALIZER; - virBuffer childrenBuf =3D VIR_BUFFER_INIT_CHILD(buf); + g_auto(virBuffer) attrBuf =3D VIR_BUFFER_INITIALIZER; + g_auto(virBuffer) childrenBuf =3D VIR_BUFFER_INIT_CHILD(buf); const char *type =3D virSysinfoTypeToString(def->type); =20 if (!type) { diff --git a/src/util/virsystemd.c b/src/util/virsystemd.c index 1d41ed34f7..0d5a54130d 100644 --- a/src/util/virsystemd.c +++ b/src/util/virsystemd.c @@ -100,7 +100,7 @@ char *virSystemdMakeScopeName(const char *name, const char *drivername, bool legacy_behaviour) { - virBuffer buf =3D VIR_BUFFER_INITIALIZER; + g_auto(virBuffer) buf =3D VIR_BUFFER_INITIALIZER; =20 virBufferAddLit(&buf, "machine-"); if (legacy_behaviour) { @@ -116,7 +116,7 @@ char *virSystemdMakeScopeName(const char *name, =20 char *virSystemdMakeSliceName(const char *partition) { - virBuffer buf =3D VIR_BUFFER_INITIALIZER; + g_auto(virBuffer) buf =3D VIR_BUFFER_INITIALIZER; =20 if (*partition =3D=3D '/') partition++; diff --git a/src/util/viruri.c b/src/util/viruri.c index 5fa0a6f0c8..492454a3df 100644 --- a/src/util/viruri.c +++ b/src/util/viruri.c @@ -252,7 +252,7 @@ virURIFormat(virURIPtr uri) =20 char *virURIFormatParams(virURIPtr uri) { - virBuffer buf =3D VIR_BUFFER_INITIALIZER; + g_auto(virBuffer) buf =3D VIR_BUFFER_INITIALIZER; size_t i; bool amp =3D false; =20 diff --git a/src/util/virxml.c b/src/util/virxml.c index 848d549a8b..e9ea9fe1a4 100644 --- a/src/util/virxml.c +++ b/src/util/virxml.c @@ -682,8 +682,7 @@ catchXMLError(void *ctx, const char *msg G_GNUC_UNUSED,= ...) const xmlChar *cur, *base; unsigned int n, col; /* GCC warns if signed, because compared w= ith sizeof() */ int domcode =3D VIR_FROM_XML; - - virBuffer buf =3D VIR_BUFFER_INITIALIZER; + g_auto(virBuffer) buf =3D VIR_BUFFER_INITIALIZER; char *contextstr =3D NULL; char *pointerstr =3D NULL; =20 --=20 2.25.4 From nobody Mon May 6 01:10:47 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 205.139.110.61 as permitted sender) client-ip=205.139.110.61; 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 205.139.110.61 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=1594006950; cv=none; d=zohomail.com; s=zohoarc; b=RuTFQaccrRRspdLfKkz0z9U2er9FyDh0SUi04uo8f3H8Eilu2JjEE5Rpu2HYc7JmCVNLPrvpvSrwQIbR7P5E+BaZNGmkBJgKRWJ4v+LuKzlz11ookUR6MNuPkAJ8NQaWmAIckmfwZdFjkayQ//kxjDgDs86GtTP6aMu0Tvto8GI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1594006950; 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=jqFH/H1u1HcfWbJg4KxrvdQEmI4sL+7naDQVJgB6CZ0=; b=Oeg4kB7JEOLEaSlLqwLvit1xnw6ZdnLo98LVXkeT//9iE9U0aQqyQ0LHkP/BBuimMZCX/zcQXmlHP0cNHTStbnQm4eu7ddPBc5xHT0uGuIf/r+1Tw6IiF+r3SwamkvFaMJ7y3Gh8NvMOtdyuPjfDax9+RyfdKHHxCg9eICskcSQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.61 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 [205.139.110.61]) by mx.zohomail.com with SMTPS id 1594006950046252.7619624329849; Sun, 5 Jul 2020 20:42:30 -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-318-keS8Cmy0N4iQBJh3T0nZzQ-1; Sun, 05 Jul 2020 23:42:26 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id ADD6A107ACF9; Mon, 6 Jul 2020 03:42:20 +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 900627BEAF; Mon, 6 Jul 2020 03:42:20 +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 601B9180954D; Mon, 6 Jul 2020 03:42:20 +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 0663fjjl004492 for ; Sun, 5 Jul 2020 23:41:45 -0400 Received: by smtp.corp.redhat.com (Postfix) id DAEDC7AC9F; Mon, 6 Jul 2020 03:41:45 +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 918AE71678 for ; Mon, 6 Jul 2020 03:41:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1594006948; 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=jqFH/H1u1HcfWbJg4KxrvdQEmI4sL+7naDQVJgB6CZ0=; b=jThUhM/6jhBRQupcIxc2aw8b7aBA7ptW0NVDr2Asj1hFhbVzetYWFRgCumcfwonmi2fi8c nC4V9fEQeC6Y2sdReKl+zax/CsGSjMshRB70bH/ceNr4iIgEemyooFvCA8j7XfXBji2fwR sPOmRgqaey1sbCuyhNbmPVQB5D0AHHc= X-MC-Unique: keS8Cmy0N4iQBJh3T0nZzQ-1 From: Laine Stump To: libvir-list@redhat.com Subject: [PATCH 11/32] cpu: use g_auto() for all virBuffers Date: Sun, 5 Jul 2020 23:41:06 -0400 Message-Id: <20200706034127.1117504-12-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.79 on 10.5.11.13 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/cpu/cpu_map.c | 2 +- src/cpu/cpu_x86.c | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/cpu/cpu_map.c b/src/cpu/cpu_map.c index 4465ebfa7b..d14488f8aa 100644 --- a/src/cpu/cpu_map.c +++ b/src/cpu/cpu_map.c @@ -171,7 +171,7 @@ int cpuMapLoad(const char *arch, { xmlDocPtr xml =3D NULL; xmlXPathContextPtr ctxt =3D NULL; - virBuffer buf =3D VIR_BUFFER_INITIALIZER; + g_auto(virBuffer) buf =3D VIR_BUFFER_INITIALIZER; char *xpath =3D NULL; int ret =3D -1; char *mapfile; diff --git a/src/cpu/cpu_x86.c b/src/cpu/cpu_x86.c index bf26cf4e76..1e5cd93abb 100644 --- a/src/cpu/cpu_x86.c +++ b/src/cpu/cpu_x86.c @@ -972,7 +972,7 @@ x86FeatureNames(virCPUx86MapPtr map, const char *separator, virCPUx86Data *data) { - virBuffer ret =3D VIR_BUFFER_INITIALIZER; + g_auto(virBuffer) ret =3D VIR_BUFFER_INITIALIZER; bool first =3D true; size_t i; =20 @@ -1208,7 +1208,7 @@ virCPUx86SignaturesMatch(virCPUx86SignaturesPtr sigs, static char * virCPUx86SignaturesFormat(virCPUx86SignaturesPtr sigs) { - virBuffer buf =3D VIR_BUFFER_INITIALIZER; + g_auto(virBuffer) buf =3D VIR_BUFFER_INITIALIZER; size_t i; =20 if (!sigs) @@ -1707,7 +1707,7 @@ virCPUx86DataFormat(const virCPUData *data) { virCPUx86DataIterator iter; virCPUx86DataItemPtr item; - virBuffer buf =3D VIR_BUFFER_INITIALIZER; + g_auto(virBuffer) buf =3D VIR_BUFFER_INITIALIZER; =20 virCPUx86DataIteratorInit(&iter, &data->data.x86); =20 --=20 2.25.4 From nobody Mon May 6 01:10:47 2024 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=1594007046; cv=none; d=zohomail.com; s=zohoarc; b=Be69qWtVn94zimkEs5p6HS0CpGic+8oMrfiuvR2Atu/2gpbC2gAXFv01NDRzdLTmyFjo+DPy2FhL1SNvA+ler9XzC7vAWUscRYHLSiSX61+zoCDg2kfb2fULTypTTITsedOxxVd4itNb32dpT5VAzePt1a5TSkoQY+aHWKXfP0o= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1594007046; 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=InDbBmc5knTRhr3WeS87hOwxvHJbkhh5uI33+bfdlUs=; b=Km1AHTux+Y5PhPw+bQEMnI0/UDKDqUyDJp+Ll3r1VdpmKAtz9q3RzDUX9nDDFtcZ7/k+wu22Yh63o1lXAC94KpVPmdxM2aY7wkALbkgKqA/O3p5uo6zPhowx9ZaeDlNom1UXCJ+QB4xmVU81PMwL5yUH4A67PRMF2AENGhvpJOs= 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 1594007046809512.3697461762405; Sun, 5 Jul 2020 20:44:06 -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-382-DjVQoNxXNHq6h_r0QiII7A-1; Sun, 05 Jul 2020 23:42:28 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id EBF25100960F; Mon, 6 Jul 2020 03:42:22 +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 CA72561981; Mon, 6 Jul 2020 03:42:22 +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 9E2011800456; Mon, 6 Jul 2020 03:42:22 +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 0663fkCr004507 for ; Sun, 5 Jul 2020 23:41:46 -0400 Received: by smtp.corp.redhat.com (Postfix) id 6352871678; Mon, 6 Jul 2020 03:41:46 +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 16BAD275E20 for ; Mon, 6 Jul 2020 03:41:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1594007045; 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=InDbBmc5knTRhr3WeS87hOwxvHJbkhh5uI33+bfdlUs=; b=ViKroQ5JX26xTSo7BycgiVYLtqlJ+4k7MYq76avzedVgNmVlbnAbbAj+6nVmQaRnjZznsc c3bqowb0z0nRZSYXRkjsJl84Fo87jeUtkPLRk71tsevLWFLQhcPxWI6XYhjBfmjp9jcF02 ADunZ4hZ24q0aQojqPYeBD2yoW1i6U4= X-MC-Unique: DjVQoNxXNHq6h_r0QiII7A-1 From: Laine Stump To: libvir-list@redhat.com Subject: [PATCH 12/32] rpc: use g_auto() for all virBuffers Date: Sun, 5 Jul 2020 23:41:07 -0400 Message-Id: <20200706034127.1117504-13-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.79 on 10.5.11.12 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/rpc/virnetclient.c | 4 ++-- src/rpc/virnetlibsshsession.c | 7 ++----- src/rpc/virnetsocket.c | 2 +- src/rpc/virnetsshsession.c | 2 +- 4 files changed, 6 insertions(+), 9 deletions(-) diff --git a/src/rpc/virnetclient.c b/src/rpc/virnetclient.c index 1c5bef86a1..441f1502a6 100644 --- a/src/rpc/virnetclient.c +++ b/src/rpc/virnetclient.c @@ -428,7 +428,7 @@ virNetClientPtr virNetClientNewLibSSH2(const char *host, { virNetSocketPtr sock =3D NULL; =20 - virBuffer buf =3D VIR_BUFFER_INITIALIZER; + g_auto(virBuffer) buf =3D VIR_BUFFER_INITIALIZER; g_autofree char *nc =3D NULL; g_autofree char *command =3D NULL; =20 @@ -518,7 +518,7 @@ virNetClientPtr virNetClientNewLibssh(const char *host, { virNetSocketPtr sock =3D NULL; =20 - virBuffer buf =3D VIR_BUFFER_INITIALIZER; + g_auto(virBuffer) buf =3D VIR_BUFFER_INITIALIZER; g_autofree char *nc =3D NULL; g_autofree char *command =3D NULL; =20 diff --git a/src/rpc/virnetlibsshsession.c b/src/rpc/virnetlibsshsession.c index 0a566eaa54..c9b31e9462 100644 --- a/src/rpc/virnetlibsshsession.c +++ b/src/rpc/virnetlibsshsession.c @@ -664,7 +664,7 @@ virNetLibsshAuthenticateKeyboardInteractive(virNetLibss= hSessionPtr sess, while (ret =3D=3D SSH_AUTH_INFO) { const char *name, *instruction; int nprompts, iprompt; - virBuffer buff =3D VIR_BUFFER_INITIALIZER; + g_auto(virBuffer) buff =3D VIR_BUFFER_INITIALIZER; =20 name =3D ssh_userauth_kbdint_getname(sess->session); instruction =3D ssh_userauth_kbdint_getinstruction(sess->session); @@ -706,7 +706,7 @@ virNetLibsshAuthenticateKeyboardInteractive(virNetLibss= hSessionPtr sess, * buffer if specified */ if (virBufferUse(&buff) > 0) { - virBuffer prompt_buff =3D VIR_BUFFER_INITIALIZER; + g_auto(virBuffer) prompt_buff =3D VIR_BUFFER_INITIALIZER; =20 virBufferAddBuffer(&prompt_buff, &buff); virBufferAdd(&prompt_buff, promptStr, promptStrLen); @@ -750,12 +750,9 @@ virNetLibsshAuthenticateKeyboardInteractive(virNetLibs= shSessionPtr sess, =20 prompt_error: VIR_FREE(prompt); - virBufferFreeAndReset(&buff); return SSH_AUTH_ERROR; } =20 - virBufferFreeAndReset(&buff); - ret =3D ssh_userauth_kbdint(sess->session, NULL, NULL); ++try; if (ret =3D=3D SSH_AUTH_DENIED && (priv->tries < 0 || try < priv->= tries)) diff --git a/src/rpc/virnetsocket.c b/src/rpc/virnetsocket.c index 3ea863f625..d1f4c531aa 100644 --- a/src/rpc/virnetsocket.c +++ b/src/rpc/virnetsocket.c @@ -849,7 +849,7 @@ int virNetSocketNewConnectSSH(const char *nodename, { char *quoted; virCommandPtr cmd; - virBuffer buf =3D VIR_BUFFER_INITIALIZER; + g_auto(virBuffer) buf =3D VIR_BUFFER_INITIALIZER; =20 *retsock =3D NULL; =20 diff --git a/src/rpc/virnetsshsession.c b/src/rpc/virnetsshsession.c index b4dea15452..490e9d5c5d 100644 --- a/src/rpc/virnetsshsession.c +++ b/src/rpc/virnetsshsession.c @@ -287,7 +287,7 @@ virNetSSHCheckHostKey(virNetSSHSessionPtr sess) int keyType; size_t keyLength; char *errmsg; - virBuffer buff =3D VIR_BUFFER_INITIALIZER; + g_auto(virBuffer) buff =3D VIR_BUFFER_INITIALIZER; virConnectCredential askKey; struct libssh2_knownhost *knownHostEntry =3D NULL; size_t i; --=20 2.25.4 From nobody Mon May 6 01:10:47 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 207.211.31.120 as permitted sender) client-ip=207.211.31.120; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.120 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=1594007288; cv=none; d=zohomail.com; s=zohoarc; b=nRt92yWwXXMQHB88nIuyWPQUNiKZWNpqH7OUZwx9Xxb7B4hS8SACBU1e+RitFMHo1xEbwE8v/Z48G54m00gvJMT341T2jy8wQLZeaKZlrlLEPqmx68hlrXmmAzu3pXhD3ZEAoP+na2wVc0FZffJEEj1kUHfmU3OH63cf8khU9rk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1594007288; 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=zJ094tPOxQW0SrTbKFcZ612JxLh8ZmLzUaQH+vYo0Hw=; b=lMLWFDYv7CPnJYOfDY/84WpNIffvSNE7PIGyZZi3QxpXulnxfnAiNCP4Uiu+YoXAzERyU/hVnjpOSTEY1PjPV/EWl/i8n0o3EZ3vQnU6ieBvNtTyhkMLkjfkMpCS8cd4Rkai7rHq84D8alIC90hP1/k/uWhass+WAf0Al19Tg84= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.120 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-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) by mx.zohomail.com with SMTPS id 1594007288065745.9445149705405; Sun, 5 Jul 2020 20:48:08 -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-146-LIfkVr_TNFCDdGPN1DzwKw-1; Sun, 05 Jul 2020 23:42:23 -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 987A684E0A6; Mon, 6 Jul 2020 03:42:17 +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 7BD2C5C1D4; Mon, 6 Jul 2020 03:42:17 +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 5045293F7C; Mon, 6 Jul 2020 03:42:17 +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 0663fkYv004515 for ; Sun, 5 Jul 2020 23:41:46 -0400 Received: by smtp.corp.redhat.com (Postfix) id DCDFA7AC9F; Mon, 6 Jul 2020 03:41:46 +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 92BDA71678 for ; Mon, 6 Jul 2020 03:41:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1594007286; 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=zJ094tPOxQW0SrTbKFcZ612JxLh8ZmLzUaQH+vYo0Hw=; b=fOiSgRZdgxvusGjzMsQoXm8dfXk2oZKgV7jDuFIB2+VmUmoAD90kkdd8Qe0/WkOuiBfvDd GX0JfCf/8rrY3y3miEBhQQjfXkx9k8oQESZ54LuGBRBNyW6gd1epdEnY4fPl8TYB7niCVr hMKL5mh8BGs9AQmiG6Lv8WxV5nokZg0= X-MC-Unique: LIfkVr_TNFCDdGPN1DzwKw-1 From: Laine Stump To: libvir-list@redhat.com Subject: [PATCH 13/32] nwfilter: use g_auto() for all virBuffers Date: Sun, 5 Jul 2020 23:41:08 -0400 Message-Id: <20200706034127.1117504-14-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.79 on 10.5.11.16 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/nwfilter/nwfilter_ebiptables_driver.c | 8 +++----- src/nwfilter/nwfilter_gentech_driver.c | 6 ++---- src/nwfilter/nwfilter_learnipaddr.c | 2 +- 3 files changed, 6 insertions(+), 10 deletions(-) diff --git a/src/nwfilter/nwfilter_ebiptables_driver.c b/src/nwfilter/nwfil= ter_ebiptables_driver.c index 6fc8044c8d..dad631f03b 100644 --- a/src/nwfilter/nwfilter_ebiptables_driver.c +++ b/src/nwfilter/nwfilter_ebiptables_driver.c @@ -190,7 +190,7 @@ _printDataType(virNWFilterVarCombIterPtr vars, bool done; char *data; uint8_t ctr; - virBuffer vb =3D VIR_BUFFER_INITIALIZER; + g_auto(virBuffer) vb =3D VIR_BUFFER_INITIALIZER; char *flags; =20 if (printVar(vars, buf, bufsize, item, &done) < 0) @@ -1528,7 +1528,7 @@ _iptablesCreateRuleInstance(virFirewallPtr fw, static int printStateMatchFlags(int32_t flags, char **bufptr) { - virBuffer buf =3D VIR_BUFFER_INITIALIZER; + g_auto(virBuffer) buf =3D VIR_BUFFER_INITIALIZER; virNWFilterPrintStateMatchFlags(&buf, "", flags, @@ -1798,7 +1798,7 @@ ebtablesCreateRuleInstance(virFirewallPtr fw, bool hasMask =3D false; virFirewallRulePtr fwrule; int ret =3D -1; - virBuffer buf =3D VIR_BUFFER_INITIALIZER; + g_auto(virBuffer) buf =3D VIR_BUFFER_INITIALIZER; =20 if (STREQ(chainSuffix, virNWFilterChainSuffixTypeToString( @@ -2423,8 +2423,6 @@ ebtablesCreateRuleInstance(virFirewallPtr fw, =20 ret =3D 0; cleanup: - virBufferFreeAndReset(&buf); - return ret; } =20 diff --git a/src/nwfilter/nwfilter_gentech_driver.c b/src/nwfilter/nwfilter= _gentech_driver.c index 6789a4a3fa..b7633eb10a 100644 --- a/src/nwfilter/nwfilter_gentech_driver.c +++ b/src/nwfilter/nwfilter_gentech_driver.c @@ -426,15 +426,13 @@ virNWFilterDetermineMissingVarsRec(virNWFilterDefPtr = filter, if (!virNWFilterVarAccessIsAvailable(rule->varAccess[j], vars)) { char *varAccess; - virBuffer buf =3D VIR_BUFFER_INITIALIZER; + g_auto(virBuffer) buf =3D VIR_BUFFER_INITIALIZER; =20 virNWFilterVarAccessPrint(rule->varAccess[j], &buf); =20 val =3D virNWFilterVarValueCreateSimpleCopyValue("1"); - if (!val) { - virBufferFreeAndReset(&buf); + if (!val) return -1; - } =20 varAccess =3D virBufferContentAndReset(&buf); rc =3D virHashUpdateEntry(missing_vars, varAccess, val= ); diff --git a/src/nwfilter/nwfilter_learnipaddr.c b/src/nwfilter/nwfilter_le= arnipaddr.c index 4ce8d5ba03..14c66cff35 100644 --- a/src/nwfilter/nwfilter_learnipaddr.c +++ b/src/nwfilter/nwfilter_learnipaddr.c @@ -397,7 +397,7 @@ learnIPAddressThread(void *arg) req->binding->portdevname); int dhcp_opts_len; char macaddr[VIR_MAC_STRING_BUFLEN]; - virBuffer buf =3D VIR_BUFFER_INITIALIZER; + g_auto(virBuffer) buf =3D VIR_BUFFER_INITIALIZER; char *filter =3D NULL; uint16_t etherType; bool showError =3D true; --=20 2.25.4 From nobody Mon May 6 01:10:47 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 207.211.31.120 as permitted sender) client-ip=207.211.31.120; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.120 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=1594007172; cv=none; d=zohomail.com; s=zohoarc; b=eBVp2M9FGPQx6a4W5kxrKSRDlhep5IAmtGPJ51UkQWHX/JTTmu6qu4wP1k9BX5o5kYgczFIr/QnTfKMy3XwI4GAFddnFv4WC+eAModLZR0cDmtn4x9z166VJl+RwkwCkge3ye7NXpkISYfk10hZsxajCSgeqlLGRi84lhdygcBo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1594007172; 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=vBNeBp4f5/gO1ck4Zc+ed+WoKRRBR7TVoWDEMfez0wY=; b=UEaM2y5g2UJ6HhFHtVarcjO5sXFdy9hjKdpqcalpXcLjLGssn7KUXMXzI182s80IY9X2CY6btAPAIFok3YkLN0wu0MhOnS6XXKS79mARcuDpdOpnQ61l2cHVisjmYWNKJKFlLm7UDjEmgJesciEw3xgDxHt/p9LLHgXohmoJuYE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.120 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-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) by mx.zohomail.com with SMTPS id 1594007172895817.8457404439691; Sun, 5 Jul 2020 20:46:12 -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-488-oQ3sTcUFMOusSrsZMxiz9A-1; Sun, 05 Jul 2020 23:42:31 -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 245EC6EAF8; Mon, 6 Jul 2020 03:42:26 +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 05EB94AC; Mon, 6 Jul 2020 03:42:26 +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 CC4FD93F8E; Mon, 6 Jul 2020 03:42:25 +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 0663fl67004520 for ; Sun, 5 Jul 2020 23:41:47 -0400 Received: by smtp.corp.redhat.com (Postfix) id 61E497AC9F; Mon, 6 Jul 2020 03:41:47 +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 1823771678 for ; Mon, 6 Jul 2020 03:41:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1594007171; 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=vBNeBp4f5/gO1ck4Zc+ed+WoKRRBR7TVoWDEMfez0wY=; b=Bv1CEHVFZNM5AHHL4fftAzKGvafJXk6FGX9r2ldBpIt9/9sWY8CB7EsrotMpn2iVcYoc+n 4Os17RQBsg0PSJfT88flp0/RkelYLQiWbYjWcGBdOe8v4P/iXtCSTRzB9BiQkgnJNyXkuP +YWYNlPzbz+HqaacfdgUnTtGgUwknAs= X-MC-Unique: oQ3sTcUFMOusSrsZMxiz9A-1 From: Laine Stump To: libvir-list@redhat.com Subject: [PATCH 14/32] network: use g_auto() for all virBuffers Date: Sun, 5 Jul 2020 23:41:09 -0400 Message-Id: <20200706034127.1117504-15-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.79 on 10.5.11.16 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/network/bridge_driver.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/network/bridge_driver.c b/src/network/bridge_driver.c index 0f5212ce04..9f37d8f558 100644 --- a/src/network/bridge_driver.c +++ b/src/network/bridge_driver.c @@ -332,7 +332,7 @@ networkRunHook(virNetworkObjPtr obj, int sub_op) { virNetworkDefPtr def; - virBuffer buf =3D VIR_BUFFER_INITIALIZER; + g_auto(virBuffer) buf =3D VIR_BUFFER_INITIALIZER; char *xml =3D NULL; int hookret; int ret =3D -1; @@ -370,7 +370,6 @@ networkRunHook(virNetworkObjPtr obj, =20 ret =3D 0; cleanup: - virBufferFreeAndReset(&buf); VIR_FREE(xml); return ret; } @@ -1093,7 +1092,7 @@ networkDnsmasqConfContents(virNetworkObjPtr obj, dnsmasqCapsPtr caps G_GNUC_UNUSED) { virNetworkDefPtr def =3D virNetworkObjGetDef(obj); - virBuffer configbuf =3D VIR_BUFFER_INITIALIZER; + g_auto(virBuffer) configbuf =3D VIR_BUFFER_INITIALIZER; int r, ret =3D -1; int nbleases =3D 0; size_t i; @@ -1577,7 +1576,6 @@ networkDnsmasqConfContents(virNetworkObjPtr obj, cleanup: VIR_FREE(saddr); VIR_FREE(eaddr); - virBufferFreeAndReset(&configbuf); return ret; } =20 @@ -1843,7 +1841,7 @@ networkRadvdConfContents(virNetworkObjPtr obj, char **configstr) { virNetworkDefPtr def =3D virNetworkObjGetDef(obj); - virBuffer configbuf =3D VIR_BUFFER_INITIALIZER; + g_auto(virBuffer) configbuf =3D VIR_BUFFER_INITIALIZER; int ret =3D -1; size_t i; virNetworkIPDefPtr ipdef; @@ -1907,7 +1905,6 @@ networkRadvdConfContents(virNetworkObjPtr obj, =20 ret =3D 0; cleanup: - virBufferFreeAndReset(&configbuf); return ret; } =20 --=20 2.25.4 From nobody Mon May 6 01:10:47 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 205.139.110.61 as permitted sender) client-ip=205.139.110.61; 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 205.139.110.61 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=1594007008; cv=none; d=zohomail.com; s=zohoarc; b=JqZL+cS26MWjn5AJu9P+qJaz8xRNN9JfxllLYHC9VMLk3wd/ce7A0NCMobV2xvUqLmwnYryfdakwewCz+SDjrsX/pnZ145CCpJUTi4f2rs5rbVJdwoFAL/9Z5nnWwsISVCGuCm+rJWjJaLBwSYRE5Xm0fr2ZK8Qt62NPC8ahAkU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1594007008; 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=LY40HJZsvOYm6nysVSt8P9gKf+Aa6HjBnipSu91Hyeo=; b=gfxoVngRfgV+8uY+shOApQaNS5L9l8dEpkSNJymTqqsX16erTFBk2xZQlo+L+hNVeK00FL1/Twr1eE8pQan8WGUmnOBW0HqK4lF5OWhS7Hn3NcU9OiigCyD4OSCJyTzXXkdPIaRrpD8XvbOwubNFfp7uncuYVazas2Xsmud90Hc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.61 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 [205.139.110.61]) by mx.zohomail.com with SMTPS id 1594007008139454.73925647325416; Sun, 5 Jul 2020 20:43:28 -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-270-Wa-7W7N4MM2ZtusAj_mylg-1; Sun, 05 Jul 2020 23:42:28 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 39CEE8064DF; Mon, 6 Jul 2020 03:42:22 +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 138B92DE6A; Mon, 6 Jul 2020 03:42:22 +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 D94D793F86; Mon, 6 Jul 2020 03:42:21 +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 0663flk1004528 for ; Sun, 5 Jul 2020 23:41:47 -0400 Received: by smtp.corp.redhat.com (Postfix) id DC5BB129F95; Mon, 6 Jul 2020 03:41:47 +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 915D27AC9F for ; Mon, 6 Jul 2020 03:41:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1594007006; 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=LY40HJZsvOYm6nysVSt8P9gKf+Aa6HjBnipSu91Hyeo=; b=HeC+vuZmAjpLrWomPy9eAEPOYyG/RQBsz8RYgaFeQfjjAtkOgQJSF+r/ZiMcC9YXeMLFe3 KVaxobJZxt79UCi23ybRAFMP49Y6THthvDVV12UuHeYXtGCnJ361E1Fl4cCUUkY9Jn0KFo vkgGeXYtj2WRAP+ETnqYZM/ayXnYxfU= X-MC-Unique: Wa-7W7N4MM2ZtusAj_mylg-1 From: Laine Stump To: libvir-list@redhat.com Subject: [PATCH 15/32] use g_auto() for all remaining non-g_auto() virBuffers Date: Sun, 5 Jul 2020 23:41:10 -0400 Message-Id: <20200706034127.1117504-16-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.23 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/hypervisor/domain_driver.c | 7 +++---- src/locking/lock_driver_sanlock.c | 2 +- src/node_device/node_device_udev.c | 2 +- src/openvz/openvz_driver.c | 5 ++--- src/security/virt-aa-helper.c | 4 ++-- src/storage/storage_backend_rbd.c | 7 ++----- src/storage/storage_util.c | 9 ++++----- src/vmx/vmx.c | 5 +---- src/vz/vz_driver.c | 4 ++-- 9 files changed, 18 insertions(+), 27 deletions(-) diff --git a/src/hypervisor/domain_driver.c b/src/hypervisor/domain_driver.c index 31821fc712..f5f0f6e2e9 100644 --- a/src/hypervisor/domain_driver.c +++ b/src/hypervisor/domain_driver.c @@ -86,7 +86,7 @@ virDomainDriverGenerateMachineName(const char *drivername, const char *name, bool privileged) { - virBuffer buf =3D VIR_BUFFER_INITIALIZER; + g_auto(virBuffer) buf =3D VIR_BUFFER_INITIALIZER; =20 if (root) { g_autofree char *hash =3D NULL; @@ -100,10 +100,9 @@ virDomainDriverGenerateMachineName(const char *drivern= ame, if (!privileged) { =20 g_autofree char *username =3D NULL; - if (!(username =3D virGetUserName(geteuid()))) { - virBufferFreeAndReset(&buf); + if (!(username =3D virGetUserName(geteuid()))) return NULL; - } + virBufferAsprintf(&buf, "%s-", username); } } diff --git a/src/locking/lock_driver_sanlock.c b/src/locking/lock_driver_sa= nlock.c index 4ebe98e86d..23711a75cb 100644 --- a/src/locking/lock_driver_sanlock.c +++ b/src/locking/lock_driver_sanlock.c @@ -825,7 +825,7 @@ virLockManagerSanlockRegisterKillscript(int sock, const char *uuidstr, virDomainLockFailureAction action) { - virBuffer buf =3D VIR_BUFFER_INITIALIZER; + g_auto(virBuffer) buf =3D VIR_BUFFER_INITIALIZER; char *path; char *args =3D NULL; int ret =3D -1; diff --git a/src/node_device/node_device_udev.c b/src/node_device/node_devi= ce_udev.c index cec99cb898..e389b56302 100644 --- a/src/node_device/node_device_udev.c +++ b/src/node_device/node_device_udev.c @@ -294,7 +294,7 @@ udevGenerateDeviceName(struct udev_device *device, const char *s) { size_t i; - virBuffer buf =3D VIR_BUFFER_INITIALIZER; + g_auto(virBuffer) buf =3D VIR_BUFFER_INITIALIZER; =20 virBufferAsprintf(&buf, "%s_%s", udev_device_get_subsystem(device), diff --git a/src/openvz/openvz_driver.c b/src/openvz/openvz_driver.c index 79a100c343..71e270ea09 100644 --- a/src/openvz/openvz_driver.c +++ b/src/openvz/openvz_driver.c @@ -704,7 +704,7 @@ openvzDomainSetNetwork(virConnectPtr conn, const char *= vpsid, if (net->type =3D=3D VIR_DOMAIN_NET_TYPE_BRIDGE || (net->type =3D=3D VIR_DOMAIN_NET_TYPE_ETHERNET && net->guestIP.nips =3D=3D 0)) { - virBuffer buf =3D VIR_BUFFER_INITIALIZER; + g_auto(virBuffer)buf =3D VIR_BUFFER_INITIALIZER; int veid =3D openvzGetVEID(vpsid); =20 /* if net is ethernet and the user has specified guest interface n= ame, @@ -782,7 +782,7 @@ openvzDomainSetNetworkConfig(virConnectPtr conn, virDomainDefPtr def) { size_t i; - virBuffer buf =3D VIR_BUFFER_INITIALIZER; + g_auto(virBuffer) buf =3D VIR_BUFFER_INITIALIZER; char *param; int first =3D 1; struct openvz_driver *driver =3D conn->privateData; @@ -819,7 +819,6 @@ openvzDomainSetNetworkConfig(virConnectPtr conn, return 0; =20 exit: - virBufferFreeAndReset(&buf); return -1; } =20 diff --git a/src/security/virt-aa-helper.c b/src/security/virt-aa-helper.c index 08eb162b8c..dadb9d1614 100644 --- a/src/security/virt-aa-helper.c +++ b/src/security/virt-aa-helper.c @@ -907,7 +907,7 @@ storage_source_add_files(virStorageSourcePtr src, static int get_files(vahControl * ctl) { - virBuffer buf =3D VIR_BUFFER_INITIALIZER; + g_auto(virBuffer) buf =3D VIR_BUFFER_INITIALIZER; int rc =3D -1; size_t i; char *uuid; @@ -1448,7 +1448,6 @@ int main(int argc, char **argv) { vahControl _ctl, *ctl =3D &_ctl; - virBuffer buf =3D VIR_BUFFER_INITIALIZER; int rc =3D -1; char *profile =3D NULL; char *include_file =3D NULL; @@ -1496,6 +1495,7 @@ main(int argc, char **argv) } } else if (ctl->cmd =3D=3D 'c' || ctl->cmd =3D=3D 'r') { char *included_files =3D NULL; + g_auto(virBuffer) buf =3D VIR_BUFFER_INITIALIZER; =20 if (ctl->cmd =3D=3D 'c' && virFileExists(profile)) vah_error(ctl, 1, _("profile exists")); diff --git a/src/storage/storage_backend_rbd.c b/src/storage/storage_backen= d_rbd.c index f0b7653736..08dc5a19dc 100644 --- a/src/storage/storage_backend_rbd.c +++ b/src/storage/storage_backend_rbd.c @@ -190,7 +190,7 @@ virStorageBackendRBDOpenRADOSConn(virStorageBackendRBDS= tatePtr ptr, unsigned char *secret_value =3D NULL; size_t secret_value_size =3D 0; VIR_AUTODISPOSE_STR rados_key =3D NULL; - virBuffer mon_host =3D VIR_BUFFER_INITIALIZER; + g_auto(virBuffer) mon_host =3D VIR_BUFFER_INITIALIZER; size_t i; const char *client_mount_timeout =3D "30"; const char *mon_op_timeout =3D "30"; @@ -330,7 +330,6 @@ virStorageBackendRBDOpenRADOSConn(virStorageBackendRBDS= tatePtr ptr, VIR_DISPOSE_N(secret_value, secret_value_size); =20 virObjectUnref(conn); - virBufferFreeAndReset(&mon_host); return ret; } =20 @@ -1151,7 +1150,7 @@ virStorageBackendRBDCloneImage(rados_ioctx_t io, uint64_t features; uint64_t stripe_count; uint64_t stripe_unit; - virBuffer snapname =3D VIR_BUFFER_INITIALIZER; + g_auto(virBuffer) snapname =3D VIR_BUFFER_INITIALIZER; rbd_image_t image =3D NULL; g_autofree char *snapname_buff =3D NULL; =20 @@ -1220,8 +1219,6 @@ virStorageBackendRBDCloneImage(rados_ioctx_t io, ret =3D 0; =20 cleanup: - virBufferFreeAndReset(&snapname); - if (image) rbd_close(image); =20 diff --git a/src/storage/storage_util.c b/src/storage/storage_util.c index 1ec1d13625..36b5b21a5b 100644 --- a/src/storage/storage_util.c +++ b/src/storage/storage_util.c @@ -717,7 +717,7 @@ storageBackendCreateQemuImgOpts(virStorageEncryptionInf= oDefPtr encinfo, char **opts, struct _virStorageBackendQemuImgInfo *info) { - virBuffer buf =3D VIR_BUFFER_INITIALIZER; + g_auto(virBuffer) buf =3D VIR_BUFFER_INITIALIZER; =20 if (info->backingPath) virBufferAsprintf(&buf, "backing_fmt=3D%s,", @@ -761,7 +761,6 @@ storageBackendCreateQemuImgOpts(virStorageEncryptionInf= oDefPtr encinfo, return 0; =20 error: - virBufferFreeAndReset(&buf); return -1; } =20 @@ -934,7 +933,7 @@ storageBackendCreateQemuImgSecretObject(virCommandPtr c= md, const char *secretPath, const char *secretAlias) { - virBuffer buf =3D VIR_BUFFER_INITIALIZER; + g_auto(virBuffer) buf =3D VIR_BUFFER_INITIALIZER; g_autofree char *commandStr =3D NULL; =20 virBufferAsprintf(&buf, "secret,id=3D%s,file=3D", secretAlias); @@ -958,7 +957,7 @@ storageBackendResizeQemuImgImageOpts(virCommandPtr cmd, const char *path, const char *secretAlias) { - virBuffer buf =3D VIR_BUFFER_INITIALIZER; + g_auto(virBuffer) buf =3D VIR_BUFFER_INITIALIZER; g_autofree char *commandStr =3D NULL; =20 virBufferAsprintf(&buf, "driver=3Dluks,key-secret=3D%s,file.filename= =3D", @@ -4058,7 +4057,7 @@ virStorageBackendFileSystemMountAddOptions(virCommand= Ptr cmd, const char *providedOpts) { g_autofree char *mountOpts =3D NULL; - virBuffer buf =3D VIR_BUFFER_INITIALIZER; + g_auto(virBuffer) buf =3D VIR_BUFFER_INITIALIZER; =20 if (*default_mount_opts !=3D '\0') virBufferAsprintf(&buf, "%s,", default_mount_opts); diff --git a/src/vmx/vmx.c b/src/vmx/vmx.c index 67bbe27fde..2f2cc19078 100644 --- a/src/vmx/vmx.c +++ b/src/vmx/vmx.c @@ -3060,7 +3060,7 @@ virVMXFormatConfig(virVMXContext *ctx, virDomainXMLOp= tionPtr xmlopt, virDomainDe size_t i; int sched_cpu_affinity_length; unsigned char zero[VIR_UUID_BUFLEN]; - virBuffer buffer =3D VIR_BUFFER_INITIALIZER; + g_auto(virBuffer) buffer =3D VIR_BUFFER_INITIALIZER; char *preliminaryDisplayName =3D NULL; char *displayName =3D NULL; char *annotation =3D NULL; @@ -3445,9 +3445,6 @@ virVMXFormatConfig(virVMXContext *ctx, virDomainXMLOp= tionPtr xmlopt, virDomainDe vmx =3D virBufferContentAndReset(&buffer); =20 cleanup: - if (vmx =3D=3D NULL) - virBufferFreeAndReset(&buffer); - VIR_FREE(preliminaryDisplayName); VIR_FREE(displayName); VIR_FREE(annotation); diff --git a/src/vz/vz_driver.c b/src/vz/vz_driver.c index d882b91def..86fa6f8bef 100644 --- a/src/vz/vz_driver.c +++ b/src/vz/vz_driver.c @@ -456,7 +456,7 @@ vzConnectGetSysinfo(virConnectPtr conn, unsigned int fl= ags) { vzConnPtr privconn =3D conn->privateData; vzDriverPtr driver =3D privconn->driver; - virBuffer buf =3D VIR_BUFFER_INITIALIZER; + g_auto(virBuffer) buf =3D VIR_BUFFER_INITIALIZER; =20 virCheckFlags(0, NULL); =20 @@ -2741,7 +2741,7 @@ vzBakeCookie(vzDriverPtr driver, unsigned int flags) { char uuidstr[VIR_UUID_STRING_BUFLEN]; - virBuffer buf =3D VIR_BUFFER_INITIALIZER; + g_auto(virBuffer) buf =3D VIR_BUFFER_INITIALIZER; =20 if (!cookieout || !cookieoutlen) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", --=20 2.25.4 From nobody Mon May 6 01:10:47 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 205.139.110.120 as permitted sender) client-ip=205.139.110.120; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.120 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=1594006954; cv=none; d=zohomail.com; s=zohoarc; b=VJEYMfDO6jT44ioU8PUCJ72rO6rcOUXXkR2WydXvUmOBDx24M2Ny5E4ZjSfKYQ2LxI5mZgtIGhOKEQ7T6FbzyA/VQGThCPsvtla0UURU2qe1OdWNckSjtzKSeInYWFkpnKYVGkVOpBuKLeuW4ABGMK5CAzUwu6I0CxIfl+k5uxY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1594006954; 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=kvvwQnTxAgJx0ZMTSspTEfQWfklcp1/juAviCM4CCXM=; b=UxZUB+79QGTpEeQ4tOJX1xHQaiBOhsYgwR3POGie8EP/44BQch0cBmToWEuIrtuEC2M9LtoPIA2iC5veTQBFztK58sW+fFa6tA+zgDMwNWd3rslEzlAt+b8xs/jaD1y7KeHbaQtZPqMLWk8gqURUYaH3QjANJH9oIlPz448n05k= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.120 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-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) by mx.zohomail.com with SMTPS id 1594006954121597.4602139592884; Sun, 5 Jul 2020 20:42:34 -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-296-cooe-wFEPmKdZQr8oRw10w-1; Sun, 05 Jul 2020 23:42:30 -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 5800C64AE8; Mon, 6 Jul 2020 03:42:25 +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 3A5C55C1D4; Mon, 6 Jul 2020 03:42:25 +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 0C3E91805310; Mon, 6 Jul 2020 03:42:25 +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 0663fmUW004537 for ; Sun, 5 Jul 2020 23:41:48 -0400 Received: by smtp.corp.redhat.com (Postfix) id 63736129F95; Mon, 6 Jul 2020 03:41:48 +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 183777AC9F for ; Mon, 6 Jul 2020 03:41:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1594006952; 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=kvvwQnTxAgJx0ZMTSspTEfQWfklcp1/juAviCM4CCXM=; b=SyIqJpPezr1hej5RJiUhqwdGS8fdKvIsBlHY/3Ousog06NZHbgCm0m+YKL4UinKiGd38wE eSBJSIxHs9kfnymaf3+erenCU7LSmt3OPzTN1vQbsep0uiAlwfP8JpSTC+v52FD8orDxvX 0knslnONi0UIvGDeiHQ9/zPrRt/jmFE= X-MC-Unique: cooe-wFEPmKdZQr8oRw10w-1 From: Laine Stump To: libvir-list@redhat.com Subject: [PATCH 16/32] qemu: remove unnecessary virBufferFreeAndReset() after virCommandAddArgBuffer() Date: Sun, 5 Jul 2020 23:41:11 -0400 Message-Id: <20200706034127.1117504-17-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.79 on 10.5.11.16 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" The latter function is guaranteed to always clear out the virBuffer anyway, so this is redundant and could add to extra cargo-cult code if used as an example. Signed-off-by: Laine Stump Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_command.c | 1 - 1 file changed, 1 deletion(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 789c5b8f56..73c6997a49 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -8913,7 +8913,6 @@ qemuBuldDomainLoaderPflashCommandLine(virCommandPtr c= md, virCommandAddArgBuffer(cmd, &buf); =20 if (loader->nvram) { - virBufferFreeAndReset(&buf); virBufferAddLit(&buf, "file=3D"); virQEMUBuildBufferEscapeComma(&buf, loader->nvram); virBufferAsprintf(&buf, ",if=3Dpflash,format=3Draw,unit=3D%d", uni= t); --=20 2.25.4 From nobody Mon May 6 01:10:47 2024 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=1594007214; cv=none; d=zohomail.com; s=zohoarc; b=W/Oi55UMH09+E+WnHmwPnBJAlrx1MZG3FfhzgUfUGNAmQQfeXpRgq8KmVEeV3b7wrYfPl3u8wmNZo2vXUkfVJc9gtCd6dxZL8um4oOMX0OcMlpfXmkfbMjF0EQfy/CxXeKtwiB5kXx3aVGl8M94HLrT8zRWJuCwqXvdkxF1+9No= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1594007214; 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=6u8xx1hroVng6VCDonx4VeqQOgGOtkHr17cPvK7lglI=; b=bvUnpIYHAL0Kf3I9t51n9GTIrKYesdYREugf47qWvCERemm6v8kepb5b5Da/Q9mXIGaIV8DAT+PER9PESyD7BE5Cwiy0+Q27XCHGggvF/RLb8zS0DW9K/zyCBzqd6AsM1SCxi0RqSm7etccDfg3dw7U0gQx7PhhUujxRqLll4iU= 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 1594007214739660.4041111648252; Sun, 5 Jul 2020 20:46:54 -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-26-L3t_ZXBJMtaE0GwYCGE0Rw-1; Sun, 05 Jul 2020 23:42:17 -0400 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 AC0518005B0; Mon, 6 Jul 2020 03:42:11 +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 8FEB8B3A61; Mon, 6 Jul 2020 03:42:11 +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 5F4E393F62; Mon, 6 Jul 2020 03:42:11 +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 0663fmb5004554 for ; Sun, 5 Jul 2020 23:41:48 -0400 Received: by smtp.corp.redhat.com (Postfix) id DC8167AC9F; Mon, 6 Jul 2020 03:41:48 +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 91FD3275E25 for ; Mon, 6 Jul 2020 03:41:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1594007213; 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=6u8xx1hroVng6VCDonx4VeqQOgGOtkHr17cPvK7lglI=; b=QdwGXouVgzNTBbR/wgk9aHVDkJ8TUKOcFnHJGUol7r+HQBAa5wEbh2UzOHOD8AlCQPj17U VP+etJWLjDAnLQ4viDm+DxCd1MpeuxUXtnp3idea0McNXif4Yuw3w+QSYHvWldmn5Zc9UO bAMuZZ21ErDVfAzru3bF53G7lVwBjGU= X-MC-Unique: L3t_ZXBJMtaE0GwYCGE0Rw-1 From: Laine Stump To: libvir-list@redhat.com Subject: [PATCH 17/32] conf: consistently check for error when calling virSysinfoFormat() Date: Sun, 5 Jul 2020 23:41:12 -0400 Message-Id: <20200706034127.1117504-18-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.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-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Every other caller of this function checks for an error return and ends their formatting early if there is an error. This function happily continues on its way. Signed-off-by: Laine Stump Reviewed-by: J=C3=A1n Tomko --- src/conf/domain_conf.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index c02d1c8bd2..33bf0a1727 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -29649,8 +29649,10 @@ virDomainDefFormatInternalSetRootName(virDomainDef= Ptr def, if (def->resource) virDomainResourceDefFormat(buf, def->resource); =20 - for (i =3D 0; i < def->nsysinfo; i++) - virSysinfoFormat(buf, def->sysinfo[i]); + for (i =3D 0; i < def->nsysinfo; i++) { + if (virSysinfoFormat(buf, def->sysinfo[i]) < 0) + goto error; + } =20 if (def->os.bootloader) { virBufferEscapeString(buf, "%s\n", --=20 2.25.4 From nobody Mon May 6 01:10:47 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 205.139.110.61 as permitted sender) client-ip=205.139.110.61; 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 205.139.110.61 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=1594006956; cv=none; d=zohomail.com; s=zohoarc; b=delecsZ9r7UsxRMwot4KwhdHewaBxj6sJECpWhfJY832KX/d4groXWIJ4oTAM+3evw+crQhHmhKv0bwtONINAx4kEAIOpESHq7W4llnYADHZVuMoxMi9rLh4rU5hDoKsz+SwzdIZV98yE88gEjOlXruZ6OG+fGh2V5G3p/wzUpg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1594006956; 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=umjbKQ2yAHsnO0iWufuCtIWLQVM7q22TKXbtjylrqdk=; b=bWXDjnhMVYCDIkg1EuzfeLPeaiN4SqQSKMYJT+M6dsoVS3uheYfN4gZ4hGa1pvzAN0kW1jHrJHhkJi2tSbJmPCU0wR28quYTg+cnQSYoTgsDREuGUb6vA2t3hqrJREmvk4kejYGrBnjOX7s56jeBUyaw3uVyEi+wjGfZiPWQuwU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.61 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 [205.139.110.61]) by mx.zohomail.com with SMTPS id 1594006956813777.5601161274044; Sun, 5 Jul 2020 20:42:36 -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-424-fOyJCUf-OmqzsP_kyuacww-1; Sun, 05 Jul 2020 23:42:32 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 9F4A6805EF3; Mon, 6 Jul 2020 03:42:27 +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 7C9552DE81; Mon, 6 Jul 2020 03:42:27 +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 4D28D1805314; Mon, 6 Jul 2020 03:42:27 +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 0663fnnH004565 for ; Sun, 5 Jul 2020 23:41:49 -0400 Received: by smtp.corp.redhat.com (Postfix) id 641B3129F95; Mon, 6 Jul 2020 03:41:49 +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 189A17AC9F for ; Mon, 6 Jul 2020 03:41:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1594006955; 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=umjbKQ2yAHsnO0iWufuCtIWLQVM7q22TKXbtjylrqdk=; b=QLTkJu9Zx77tZiVoEYcO6GXSLG6VufTT1AzYvicb2/0wEjf7epa93qxcjdD1vr58JjlrYX q++3lA21ulYqapnS8T2NPooK8QTj4ZHfSlGfYEhxA38iSuIqIEAQEUOELt9+zSmeQBFQdR pcXOpNgYlAhmOpjAxTP3JhUrI9XP7B0= X-MC-Unique: fOyJCUf-OmqzsP_kyuacww-1 From: Laine Stump To: libvir-list@redhat.com Subject: [PATCH 18/32] remove redundant calls to virBufferFreeAndReset() Date: Sun, 5 Jul 2020 23:41:13 -0400 Message-Id: <20200706034127.1117504-19-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.23 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" There are several calls to virBufferFreeAndReset() when functions encounter an error, but the caller never uses the virBuffer once an error has been encountered (all callers detect error by looking at the function return value, not the contents of the virBuffer being operated on), and now that all virBuffers are auto-freed there is no reason for the lower level functions like these to spend time freeing a buffer that is guaranteed to be freed momentarily anyway. Signed-off-by: Laine Stump Reviewed-by: J=C3=A1n Tomko --- src/conf/checkpoint_conf.c | 1 - src/conf/domain_conf.c | 1 - src/conf/snapshot_conf.c | 1 - src/libxl/xen_xl.c | 1 - src/util/virsysinfo.c | 1 - src/util/virxml.c | 1 - 6 files changed, 6 deletions(-) diff --git a/src/conf/checkpoint_conf.c b/src/conf/checkpoint_conf.c index e0dce9c2ed..41f67bd895 100644 --- a/src/conf/checkpoint_conf.c +++ b/src/conf/checkpoint_conf.c @@ -493,7 +493,6 @@ virDomainCheckpointDefFormatInternal(virBufferPtr buf, return 0; =20 error: - virBufferFreeAndReset(buf); return -1; } =20 diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 33bf0a1727..e5070ed871 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -30038,7 +30038,6 @@ virDomainDefFormatInternalSetRootName(virDomainDefP= tr def, return 0; =20 error: - virBufferFreeAndReset(buf); return -1; } =20 diff --git a/src/conf/snapshot_conf.c b/src/conf/snapshot_conf.c index 9767592bfc..b7ed3b42df 100644 --- a/src/conf/snapshot_conf.c +++ b/src/conf/snapshot_conf.c @@ -916,7 +916,6 @@ virDomainSnapshotDefFormatInternal(virBufferPtr buf, return 0; =20 error: - virBufferFreeAndReset(buf); return -1; } =20 diff --git a/src/libxl/xen_xl.c b/src/libxl/xen_xl.c index ec5e4791a3..4baf5e336e 100644 --- a/src/libxl/xen_xl.c +++ b/src/libxl/xen_xl.c @@ -1432,7 +1432,6 @@ xenFormatXLVnode(virConfValuePtr list, ret =3D 0; =20 cleanup: - virBufferFreeAndReset(buf); return ret; } =20 diff --git a/src/util/virsysinfo.c b/src/util/virsysinfo.c index dbca99c1ef..e69fc51a1e 100644 --- a/src/util/virsysinfo.c +++ b/src/util/virsysinfo.c @@ -1581,7 +1581,6 @@ virSysinfoFormat(virBufferPtr buf, virSysinfoDefPtr d= ef) virReportError(VIR_ERR_INTERNAL_ERROR, _("unexpected sysinfo type model %d"), def->type); - virBufferFreeAndReset(buf); return -1; } =20 diff --git a/src/util/virxml.c b/src/util/virxml.c index e9ea9fe1a4..56e6f67597 100644 --- a/src/util/virxml.c +++ b/src/util/virxml.c @@ -1283,7 +1283,6 @@ virXMLValidatorValidate(virXMLValidatorPtr validator, =20 ret =3D 0; cleanup: - virBufferFreeAndReset(&validator->buf); return ret; } =20 --=20 2.25.4 From nobody Mon May 6 01:10:47 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 205.139.110.61 as permitted sender) client-ip=205.139.110.61; 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 205.139.110.61 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=1594006947; cv=none; d=zohomail.com; s=zohoarc; b=AJ9DVkFrynbzJVNdRk/5BZpIdUOnb0N5loMdkKcliAVtLUfoAfXMtbeiBUr+536tI8no999Py4CXj4w5C2URiZff5eKxareWqAUSZgAD1A8zucKrnZrL4MqgrZnZBEJvWiQ5fiHxjcixicDbU9FZOso/2F2O+ttqGLN7pcTOVHE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1594006947; 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=UQ0qmljKTUnkW9ZrA9hSaVwTvcZq2Eh8EIBkCDwnDYk=; b=QJDf7MPoJYJmgZwmaPj/2sa4VFrwEoPfKqboHf6wgxcYp0YIE95juI3yjA0vWi9EdototRyTh967lK8R8L17OseMH8K2GlIY4UeNz8kj+Gr5ZSVFrjT0xIk13pu1RriYscb/CyP+BgX4qLJ67GrY94uKs/1j7hi8ZdeKERi8jSQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.61 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 [205.139.110.61]) by mx.zohomail.com with SMTPS id 159400694730468.94640327655009; Sun, 5 Jul 2020 20:42:27 -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-40-jFD3IF2UN2KdsXr8srS6Zw-1; Sun, 05 Jul 2020 23:42:19 -0400 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 DC4608015F7; Mon, 6 Jul 2020 03:42:13 +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 BE5D75D9CC; Mon, 6 Jul 2020 03:42:13 +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 917E81806B0D; Mon, 6 Jul 2020 03:42:13 +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 0663fqOV004610 for ; Sun, 5 Jul 2020 23:41:52 -0400 Received: by smtp.corp.redhat.com (Postfix) id B5BE6275E2E; Mon, 6 Jul 2020 03:41:52 +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 6BDA3129F95 for ; Mon, 6 Jul 2020 03:41:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1594006946; 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=UQ0qmljKTUnkW9ZrA9hSaVwTvcZq2Eh8EIBkCDwnDYk=; b=NfbE5X7nfru1OZ6xDzQUG1xgvtbWjitKKoTcQB9xk7pzt/dB+CC7eLFZp9X76z81Cf/TQR riSCLo7kEIEcjvUpZQhiCUIObd4yKgUGY/80Ww8efJXqH9K60qg2eM7HUTicWb/GMEyUlt TFECIaDMnGaYJ7y687pJQA0r0ab80mk= X-MC-Unique: jFD3IF2UN2KdsXr8srS6Zw-1 From: Laine Stump To: libvir-list@redhat.com Subject: [PATCH 19/32] libxml: eliminate extra copy of string Date: Sun, 5 Jul 2020 23:41:14 -0400 Message-Id: <20200706034127.1117504-20-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.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) Content-Type: text/plain; charset="utf-8" libxlMakeNic was calling g_strdup(virBufferCurrentContent(&buf)) to make a copy of the buffer contents, and then later freeing the buffer without ever using it again. Instead of this extra strdup, just transfer ownership of the virBuffer's string with virBufferContentAndReset(), and be done with it. Signed-off-by: Laine Stump Reviewed-by: J=C3=A1n Tomko --- src/libxl/libxl_conf.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libxl/libxl_conf.c b/src/libxl/libxl_conf.c index 124e08d598..fe8ad4a3cb 100644 --- a/src/libxl/libxl_conf.c +++ b/src/libxl/libxl_conf.c @@ -1335,7 +1335,7 @@ libxlMakeNic(virDomainDefPtr def, } } } - x_nic->bridge =3D g_strdup(virBufferCurrentContent(&buf)); + x_nic->bridge =3D virBufferContentAndReset(&buf); G_GNUC_FALLTHROUGH; case VIR_DOMAIN_NET_TYPE_ETHERNET: x_nic->script =3D g_strdup(script); --=20 2.25.4 From nobody Mon May 6 01:10:47 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 207.211.31.120 as permitted sender) client-ip=207.211.31.120; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.120 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=1594006992; cv=none; d=zohomail.com; s=zohoarc; b=JnwfJqbYR72ybIgD115OfejGJPTDaury5b8fNKItnuMyRLYDcmdocc3lCGC187W8Vm/vaO4HVy9A9oqL1yt9/AFQGyQTj2sYCwe2Ku3jgwlzOsVMBkivJ6X6fP04SZKswjJGiOkU0fvGbhgYbPEz5YwNkxgce7jj954nQsdCNAk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1594006992; 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=WBKFtNefpzpaXrnFpcdsO1pPtmOTvxoWOQAKh4R3LFE=; b=YrPT/Talyaz/NGNtktTsvK0uaMqBnpoQaGe/inzDuYEZs4Wen0tfD1MqNfdEq/wQm/3LQ8rXGe/6Qeb/AIsFk0IqvICGnQEXws1wMl9MN+vyVnLZdDecMHqNdfk4NBNCckadkcYBgyEqW60pL2JaN9oQsoO8Zbbdw+0e8KOW428= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.120 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-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) by mx.zohomail.com with SMTPS id 1594006992969330.37742017520395; Sun, 5 Jul 2020 20:43:12 -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-28-1WgA7JSONHGSQVZ70gmJRw-1; Sun, 05 Jul 2020 23:42:34 -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 B8BD3805EFD; Mon, 6 Jul 2020 03:42:28 +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 9C50B5C1D4; Mon, 6 Jul 2020 03:42:28 +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 6D2BB93F91; Mon, 6 Jul 2020 03:42:28 +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 0663g3cV004670 for ; Sun, 5 Jul 2020 23:42:03 -0400 Received: by smtp.corp.redhat.com (Postfix) id BA8D7275E39; Mon, 6 Jul 2020 03:42:03 +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 6E9B9275E36 for ; Mon, 6 Jul 2020 03:41:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1594006991; 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=WBKFtNefpzpaXrnFpcdsO1pPtmOTvxoWOQAKh4R3LFE=; b=Oghb1vqA8AKodWffzVLT8etcRWf0vzeVlgd/zsUDEQ1X15G5lySrj2HuE36LkR51pL3ANb wxrIj2NcoJ0arzWmMkrtH5wOy6KwTy0oA+/sUPvWLGNKQd3WwF/S0m5nL0+oEI6mv+LJ4y UNhJdJrGcvvshaxfMpx7sNPPqW/jJEM= X-MC-Unique: 1WgA7JSONHGSQVZ70gmJRw-1 From: Laine Stump To: libvir-list@redhat.com Subject: [PATCH 20/32] bhyve: eliminate unnecessary labels Date: Sun, 5 Jul 2020 23:41:15 -0400 Message-Id: <20200706034127.1117504-21-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.79 on 10.5.11.16 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/bhyve/bhyve_command.c | 25 ++++++++++--------------- 1 file changed, 10 insertions(+), 15 deletions(-) diff --git a/src/bhyve/bhyve_command.c b/src/bhyve/bhyve_command.c index 9649c2d2a2..22d0b24ec4 100644 --- a/src/bhyve/bhyve_command.c +++ b/src/bhyve/bhyve_command.c @@ -169,7 +169,6 @@ bhyveBuildAHCIControllerArgStr(const virDomainDef *def, g_auto(virBuffer) buf =3D VIR_BUFFER_INITIALIZER; const char *disk_source; size_t i; - int ret =3D -1; =20 for (i =3D 0; i < def->ndisks; i++) { g_auto(virBuffer) device =3D VIR_BUFFER_INITIALIZER; @@ -187,11 +186,11 @@ bhyveBuildAHCIControllerArgStr(const virDomainDef *de= f, (virDomainDiskGetType(disk) !=3D VIR_STORAGE_TYPE_VOLUME)) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", _("unsupported disk type")); - goto error; + return -1; } =20 if (virDomainDiskTranslateSourcePool(disk) < 0) - goto error; + return -1; =20 disk_source =3D virDomainDiskGetSource(disk); =20 @@ -200,7 +199,7 @@ bhyveBuildAHCIControllerArgStr(const virDomainDef *def, virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", _("cdrom device without source path " "not supported")); - goto error; + return -1; } =20 switch (disk->device) { @@ -219,7 +218,7 @@ bhyveBuildAHCIControllerArgStr(const virDomainDef *def, default: virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", _("unsupported disk device")); - goto error; + return -1; } virBufferAddBuffer(&buf, &device); } @@ -229,9 +228,7 @@ bhyveBuildAHCIControllerArgStr(const virDomainDef *def, controller->info.addr.pci.slot, virBufferCurrentContent(&buf)); =20 - ret =3D 0; - error: - return ret; + return 0; } =20 static int @@ -406,7 +403,7 @@ bhyveBuildGraphicsArgStr(const virDomainDef *def, if (!(glisten =3D virDomainGraphicsGetListen(graphics, 0))) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Missing listen element")); - goto error; + return -1; } =20 virBufferAsprintf(&opt, "%d:%d,fbuf", video->info.addr.pci.slot, video= ->info.addr.pci.function); @@ -421,13 +418,13 @@ bhyveBuildGraphicsArgStr(const virDomainDef *def, graphics->data.vnc.port > 65535)) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", _("vnc port must be in range [5900,65535]")); - goto error; + return -1; } =20 if (graphics->data.vnc.auth.passwd) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", _("vnc password auth not supported")); - goto error; + return -1; } else { /* Bhyve doesn't support VNC Auth yet, so print a warning abo= ut * unauthenticated VNC sessions */ @@ -461,11 +458,11 @@ bhyveBuildGraphicsArgStr(const virDomainDef *def, case VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_NONE: virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", _("Unsupported listen type")); - goto error; + return -1; case VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_LAST: default: virReportEnumRangeError(virDomainGraphicsListenType, glisten->type= ); - goto error; + return -1; } =20 if (video->driver) @@ -476,8 +473,6 @@ bhyveBuildGraphicsArgStr(const virDomainDef *def, virCommandAddArgBuffer(cmd, &opt); return 0; =20 - error: - return -1; } =20 virCommandPtr --=20 2.25.4 From nobody Mon May 6 01:10:47 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 207.211.31.120 as permitted sender) client-ip=207.211.31.120; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.120 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=1594007119; cv=none; d=zohomail.com; s=zohoarc; b=SubXZhqyL0RcvYKBS7QfbKzbtY8w8awSGMfvwdFunGwKzdVcecvWbZ6fGpW+/GKd9BUxrWBKp3oVgLNrH0l8piznSiw7O/a+rFpQZzfUMZBMdvqatXbgJiViXVAigk8fN/n6B0QIGJYLet0ZDYhMFCzWEun6B/qCIuLAVuscRO8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1594007119; 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=bSFetdmW78tPL3tWwdAUTqVEy3cQWqHMgdSF+OwdzfI=; b=YCiZk7pEMmfjl8Fj4MTlGjDAyjozIoxQBE+8+prqTuZd5vbX6GTR+kW2eN4AfWINC/dNPlQZRBgpU4Ytxy6jEtOXGSUw7/hWv+6hM/LsNBkt99la01DCrjzykPMB+igZEjuSGss4f0jk9a+kDhHqGp58r1yiDeU6ITJt6VyjX6I= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.120 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-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) by mx.zohomail.com with SMTPS id 1594007119259372.5912098710819; Sun, 5 Jul 2020 20:45:19 -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-507-49UwntP9PXiy_pTs0WO8qQ-1; Sun, 05 Jul 2020 23:42:35 -0400 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 CC970805F0C; Mon, 6 Jul 2020 03:42:29 +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 ADE6E5D9E4; Mon, 6 Jul 2020 03:42:29 +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 80DA11805318; Mon, 6 Jul 2020 03:42:29 +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 0663g7xW004702 for ; Sun, 5 Jul 2020 23:42:07 -0400 Received: by smtp.corp.redhat.com (Postfix) id 89FBA275E36; Mon, 6 Jul 2020 03:42:07 +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 3C017275E3B for ; Mon, 6 Jul 2020 03:42:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1594007118; 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=bSFetdmW78tPL3tWwdAUTqVEy3cQWqHMgdSF+OwdzfI=; b=FIlRQmiKzZZPVzpaNieid6ruN/fUQx3Az/rXToz2JRxHPEpNFJkB5RlF1ASDjy6mb6IT7t josOR3juvCFxQZPoBI/5GRJ2feVjbNWyPTw2yvus4hlpZ1MYHg7Vz5UWPYmRSdrnf6pUKd kgD2pxinrxF8A7B/uMnrjKqRPnjiFvM= X-MC-Unique: 49UwntP9PXiy_pTs0WO8qQ-1 From: Laine Stump To: libvir-list@redhat.com Subject: [PATCH 21/32] conf: eliminate unnecessary labels Date: Sun, 5 Jul 2020 23:41:16 -0400 Message-Id: <20200706034127.1117504-22-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.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) Content-Type: text/plain; charset="utf-8" Signed-off-by: Laine Stump Reviewed-by: J=C3=A1n Tomko --- src/conf/capabilities.c | 5 +-- src/conf/checkpoint_conf.c | 8 ++-- src/conf/cpu_conf.c | 18 +++----- src/conf/domain_conf.c | 88 +++++++++++++++++++------------------- src/conf/network_conf.c | 5 +-- src/conf/nwfilter_conf.c | 5 +-- src/conf/secret_conf.c | 5 +-- src/conf/snapshot_conf.c | 11 ++--- src/conf/storage_conf.c | 17 ++------ src/conf/virnetworkobj.c | 7 +-- src/conf/virsavecookie.c | 5 +-- 11 files changed, 67 insertions(+), 107 deletions(-) diff --git a/src/conf/capabilities.c b/src/conf/capabilities.c index 6a48af1fca..610e6e8242 100644 --- a/src/conf/capabilities.c +++ b/src/conf/capabilities.c @@ -1340,7 +1340,7 @@ virCapabilitiesFormatXML(virCapsPtr caps) virBufferAdjustIndent(&buf, 2); =20 if (virCapabilitiesFormatHostXML(&caps->host, &buf) < 0) - goto error; + return NULL; =20 virCapabilitiesFormatGuestXML(caps->guests, caps->nguests, &buf); =20 @@ -1350,9 +1350,6 @@ virCapabilitiesFormatXML(virCapsPtr caps) virBufferAddLit(&buf, "\n"); =20 return virBufferContentAndReset(&buf); - - error: - return NULL; } =20 /* get the maximum ID of cpus in the host */ diff --git a/src/conf/checkpoint_conf.c b/src/conf/checkpoint_conf.c index 41f67bd895..861004801e 100644 --- a/src/conf/checkpoint_conf.c +++ b/src/conf/checkpoint_conf.c @@ -476,7 +476,7 @@ virDomainCheckpointDefFormatInternal(virBufferPtr buf, for (i =3D 0; i < def->ndisks; i++) { if (virDomainCheckpointDiskDefFormat(buf, &def->disks[i], flags) < 0) - goto error; + return -1; } virBufferAdjustIndent(buf, -2); virBufferAddLit(buf, "\n"); @@ -485,17 +485,15 @@ virDomainCheckpointDefFormatInternal(virBufferPtr buf, if (!(flags & VIR_DOMAIN_CHECKPOINT_FORMAT_NO_DOMAIN) && virDomainDefFormatInternal(def->parent.dom, xmlopt, buf, domainflags) < 0) - goto error; + return -1; =20 virBufferAdjustIndent(buf, -2); virBufferAddLit(buf, "\n"); =20 return 0; - - error: - return -1; } =20 + char * virDomainCheckpointDefFormat(virDomainCheckpointDefPtr def, virDomainXMLOptionPtr xmlopt, diff --git a/src/conf/cpu_conf.c b/src/conf/cpu_conf.c index dd3db00bc8..7be108fa63 100644 --- a/src/conf/cpu_conf.c +++ b/src/conf/cpu_conf.c @@ -671,12 +671,9 @@ virCPUDefFormat(virCPUDefPtr def, g_auto(virBuffer) buf =3D VIR_BUFFER_INITIALIZER; =20 if (virCPUDefFormatBufFull(&buf, def, numa) < 0) - goto cleanup; + return NULL; =20 return virBufferContentAndReset(&buf); - - cleanup: - return NULL; } =20 =20 @@ -685,7 +682,6 @@ virCPUDefFormatBufFull(virBufferPtr buf, virCPUDefPtr def, virDomainNumaPtr numa) { - int ret =3D -1; g_auto(virBuffer) attributeBuf =3D VIR_BUFFER_INITIALIZER; g_auto(virBuffer) childrenBuf =3D VIR_BUFFER_INIT_CHILD(buf); =20 @@ -701,7 +697,7 @@ virCPUDefFormatBufFull(virBufferPtr buf, if (!(tmp =3D virCPUModeTypeToString(def->mode))) { virReportError(VIR_ERR_INTERNAL_ERROR, _("Unexpected CPU mode %d"), def->mode); - goto cleanup; + return -1; } virBufferAsprintf(&attributeBuf, " mode=3D'%s'", tmp); =20 @@ -710,7 +706,7 @@ virCPUDefFormatBufFull(virBufferPtr buf, virReportError(VIR_ERR_INTERNAL_ERROR, _("Unexpected CPU match policy %d"), def->match); - goto cleanup; + return -1; } virBufferAsprintf(&attributeBuf, " match=3D'%s'", tmp); } @@ -731,10 +727,10 @@ virCPUDefFormatBufFull(virBufferPtr buf, virBufferAsprintf(&childrenBuf, "%s\n", virArchToString(def->arch)); if (virCPUDefFormatBuf(&childrenBuf, def) < 0) - goto cleanup; + return -1; =20 if (virDomainNumaDefCPUFormatXML(&childrenBuf, numa) < 0) - goto cleanup; + return -1; =20 /* Put it all together */ if (virBufferUse(&attributeBuf) || virBufferUse(&childrenBuf)) { @@ -752,9 +748,7 @@ virCPUDefFormatBufFull(virBufferPtr buf, } } =20 - ret =3D 0; - cleanup: - return ret; + return 0; } =20 int diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index e5070ed871..706d050f4d 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -29543,7 +29543,7 @@ virDomainDefFormatInternalSetRootName(virDomainDefP= tr def, if (!(type =3D virDomainVirtTypeToString(def->virtType))) { virReportError(VIR_ERR_INTERNAL_ERROR, _("unexpected domain type %d"), def->virtType); - goto error; + return -1; } =20 if (def->id =3D=3D -1) @@ -29588,13 +29588,13 @@ virDomainDefFormatInternalSetRootName(virDomainDe= fPtr def, xmlIndentTreeOutput =3D 1; if (!(xmlbuf =3D xmlBufferCreate())) { virReportOOMError(); - goto error; + return -1; } =20 if (xmlNodeDump(xmlbuf, def->metadata->doc, def->metadata, virBufferGetIndent(buf) / 2, 1) < 0) { xmlIndentTreeOutput =3D oldIndentTreeOutput; - goto error; + return -1; } virBufferAsprintf(buf, "%s\n", (char *) xmlBufferContent(xmlbuf)); xmlIndentTreeOutput =3D oldIndentTreeOutput; @@ -29617,13 +29617,13 @@ virDomainDefFormatInternalSetRootName(virDomainDe= fPtr def, def->mem.cur_balloon); =20 if (virDomainDefFormatBlkiotune(buf, def) < 0) - goto error; + return -1; =20 virDomainMemtuneFormat(buf, &def->mem); virDomainMemorybackingFormat(buf, &def->mem); =20 if (virDomainCpuDefFormat(buf, def) < 0) - goto error; + return -1; =20 if (def->niothreadids > 0) { virBufferAsprintf(buf, "%zu\n", @@ -29641,17 +29641,17 @@ virDomainDefFormatInternalSetRootName(virDomainDe= fPtr def, } =20 if (virDomainCputuneDefFormat(buf, def, flags) < 0) - goto error; + return -1; =20 if (virDomainNumatuneFormatXML(buf, def->numa) < 0) - goto error; + return -1; =20 if (def->resource) virDomainResourceDefFormat(buf, def->resource); =20 for (i =3D 0; i < def->nsysinfo; i++) { if (virSysinfoFormat(buf, def->sysinfo[i]) < 0) - goto error; + return -1; } =20 if (def->os.bootloader) { @@ -29731,7 +29731,7 @@ virDomainDefFormatInternalSetRootName(virDomainDefP= tr def, virReportError(VIR_ERR_INTERNAL_ERROR, _("unexpected boot device type %d"), def->os.bootDevs[n]); - goto error; + return -1; } virBufferAsprintf(buf, "\n", boottype); } @@ -29763,7 +29763,7 @@ virDomainDefFormatInternalSetRootName(virDomainDefP= tr def, if (mode =3D=3D NULL) { virReportError(VIR_ERR_INTERNAL_ERROR, _("unexpected smbios mode %d"), def->os.smbios_= mode); - goto error; + return -1; } virBufferAsprintf(buf, "\n", mode); } @@ -29794,10 +29794,10 @@ virDomainDefFormatInternalSetRootName(virDomainDe= fPtr def, } =20 if (virDomainDefFormatFeatures(buf, def) < 0) - goto error; + return -1; =20 if (virCPUDefFormatBufFull(buf, def->cpu, def->numa) < 0) - goto error; + return -1; =20 virBufferAsprintf(buf, "clock.offset)); @@ -29828,7 +29828,7 @@ virDomainDefFormatInternalSetRootName(virDomainDefP= tr def, virBufferAdjustIndent(buf, 2); for (n =3D 0; n < def->clock.ntimers; n++) { if (virDomainTimerDefFormat(buf, def->clock.timers[n]) < 0) - goto error; + return -1; } virBufferAdjustIndent(buf, -2); virBufferAddLit(buf, "\n"); @@ -29837,20 +29837,20 @@ virDomainDefFormatInternalSetRootName(virDomainDe= fPtr def, if (virDomainEventActionDefFormat(buf, def->onPoweroff, "on_poweroff", virDomainLifecycleActionTypeToString= ) < 0) - goto error; + return -1; if (virDomainEventActionDefFormat(buf, def->onReboot, "on_reboot", virDomainLifecycleActionTypeToString= ) < 0) - goto error; + return -1; if (virDomainEventActionDefFormat(buf, def->onCrash, "on_crash", virDomainLifecycleActionTypeToString= ) < 0) - goto error; + return -1; if (def->onLockFailure !=3D VIR_DOMAIN_LOCK_FAILURE_DEFAULT && virDomainEventActionDefFormat(buf, def->onLockFailure, "on_lockfailure", virDomainLockFailureTypeToString) < = 0) - goto error; + return -1; =20 if (def->pm.s3 || def->pm.s4) { virBufferAddLit(buf, "\n"); @@ -29877,35 +29877,35 @@ virDomainDefFormatInternalSetRootName(virDomainDe= fPtr def, =20 for (n =3D 0; n < def->ndisks; n++) if (virDomainDiskDefFormat(buf, def->disks[n], flags, xmlopt) < 0) - goto error; + return -1; =20 for (n =3D 0; n < def->ncontrollers; n++) if (virDomainControllerDefFormat(buf, def->controllers[n], flags) = < 0) - goto error; + return -1; =20 for (n =3D 0; n < def->nleases; n++) if (virDomainLeaseDefFormat(buf, def->leases[n]) < 0) - goto error; + return -1; =20 for (n =3D 0; n < def->nfss; n++) if (virDomainFSDefFormat(buf, def->fss[n], flags) < 0) - goto error; + return -1; =20 for (n =3D 0; n < def->nnets; n++) if (virDomainNetDefFormat(buf, def->nets[n], xmlopt, flags) < 0) - goto error; + return -1; =20 for (n =3D 0; n < def->nsmartcards; n++) if (virDomainSmartcardDefFormat(buf, def->smartcards[n], flags) < = 0) - goto error; + return -1; =20 for (n =3D 0; n < def->nserials; n++) if (virDomainChrDefFormat(buf, def->serials[n], flags) < 0) - goto error; + return -1; =20 for (n =3D 0; n < def->nparallels; n++) if (virDomainChrDefFormat(buf, def->parallels[n], flags) < 0) - goto error; + return -1; =20 for (n =3D 0; n < def->nconsoles; n++) { virDomainChrDef console; @@ -29923,36 +29923,36 @@ virDomainDefFormatInternalSetRootName(virDomainDe= fPtr def, memcpy(&console, def->consoles[n], sizeof(console)); } if (virDomainChrDefFormat(buf, &console, flags) < 0) - goto error; + return -1; } =20 for (n =3D 0; n < def->nchannels; n++) if (virDomainChrDefFormat(buf, def->channels[n], flags) < 0) - goto error; + return -1; =20 for (n =3D 0; n < def->ninputs; n++) { if (virDomainInputDefFormat(buf, def->inputs[n], flags) < 0) - goto error; + return -1; } =20 for (n =3D 0; n < def->ntpms; n++) { if (virDomainTPMDefFormat(buf, def->tpms[n], flags) < 0) - goto error; + return -1; } =20 for (n =3D 0; n < def->ngraphics; n++) { if (virDomainGraphicsDefFormat(buf, def->graphics[n], flags) < 0) - goto error; + return -1; } =20 for (n =3D 0; n < def->nsounds; n++) { if (virDomainSoundDefFormat(buf, def->sounds[n], flags) < 0) - goto error; + return -1; } =20 for (n =3D 0; n < def->nvideos; n++) { if (virDomainVideoDefFormat(buf, def->videos[n], flags) < 0) - goto error; + return -1; } =20 for (n =3D 0; n < def->nhostdevs; n++) { @@ -29962,13 +29962,13 @@ virDomainDefFormatInternalSetRootName(virDomainDe= fPtr def, */ if (!def->hostdevs[n]->parentnet && virDomainHostdevDefFormat(buf, def->hostdevs[n], flags) < 0) { - goto error; + return -1; } } =20 for (n =3D 0; n < def->nredirdevs; n++) { if (virDomainRedirdevDefFormat(buf, def->redirdevs[n], flags) < 0) - goto error; + return -1; } =20 if (def->redirfilter) @@ -29976,7 +29976,7 @@ virDomainDefFormatInternalSetRootName(virDomainDefP= tr def, =20 for (n =3D 0; n < def->nhubs; n++) { if (virDomainHubDefFormat(buf, def->hubs[n], flags) < 0) - goto error; + return -1; } =20 if (def->watchdog) @@ -29987,7 +29987,7 @@ virDomainDefFormatInternalSetRootName(virDomainDefP= tr def, =20 for (n =3D 0; n < def->nrngs; n++) { if (virDomainRNGDefFormat(buf, def->rngs[n], flags)) - goto error; + return -1; } =20 if (def->nvram) @@ -29995,26 +29995,26 @@ virDomainDefFormatInternalSetRootName(virDomainDe= fPtr def, =20 for (n =3D 0; n < def->npanics; n++) { if (virDomainPanicDefFormat(buf, def->panics[n]) < 0) - goto error; + return -1; } =20 for (n =3D 0; n < def->nshmems; n++) { if (virDomainShmemDefFormat(buf, def->shmems[n], flags) < 0) - goto error; + return -1; } =20 for (n =3D 0; n < def->nmems; n++) { if (virDomainMemoryDefFormat(buf, def->mems[n], def, flags) < 0) - goto error; + return -1; } =20 if (def->iommu && virDomainIOMMUDefFormat(buf, def->iommu) < 0) - goto error; + return -1; =20 if (def->vsock && virDomainVsockDefFormat(buf, def->vsock) < 0) - goto error; + return -1; =20 virBufferAdjustIndent(buf, -2); virBufferAddLit(buf, "\n"); @@ -30029,18 +30029,16 @@ virDomainDefFormatInternalSetRootName(virDomainDe= fPtr def, =20 if (def->namespaceData && def->ns.format) { if ((def->ns.format)(buf, def->namespaceData) < 0) - goto error; + return -1; } =20 virBufferAdjustIndent(buf, -2); virBufferAsprintf(buf, "\n", rootname); =20 return 0; - - error: - return -1; } =20 + /* Converts VIR_DOMAIN_XML_COMMON_FLAGS into VIR_DOMAIN_DEF_FORMAT_* * flags, and silently ignores any other flags. Note that the caller * should validate the set of flags it is willing to accept; see also diff --git a/src/conf/network_conf.c b/src/conf/network_conf.c index 99f11fdf05..0fd68a7d66 100644 --- a/src/conf/network_conf.c +++ b/src/conf/network_conf.c @@ -2721,12 +2721,9 @@ virNetworkDefFormat(const virNetworkDef *def, g_auto(virBuffer) buf =3D VIR_BUFFER_INITIALIZER; =20 if (virNetworkDefFormatBuf(&buf, def, xmlopt, flags) < 0) - goto error; + return NULL; =20 return virBufferContentAndReset(&buf); - - error: - return NULL; } =20 =20 diff --git a/src/conf/nwfilter_conf.c b/src/conf/nwfilter_conf.c index 3827c65462..02722abc32 100644 --- a/src/conf/nwfilter_conf.c +++ b/src/conf/nwfilter_conf.c @@ -3062,16 +3062,13 @@ virNWFilterDefFormat(const virNWFilterDef *def) =20 for (i =3D 0; i < def->nentries; i++) { if (virNWFilterEntryFormat(&buf, def->filterEntries[i]) < 0) - goto err_exit; + return NULL; } =20 virBufferAdjustIndent(&buf, -2); virBufferAddLit(&buf, "\n"); =20 return virBufferContentAndReset(&buf); - - err_exit: - return NULL; } =20 static virNWFilterTriggerRebuildCallback rebuildCallback; diff --git a/src/conf/secret_conf.c b/src/conf/secret_conf.c index 3960cf04ad..2e35348ce1 100644 --- a/src/conf/secret_conf.c +++ b/src/conf/secret_conf.c @@ -294,12 +294,9 @@ virSecretDefFormat(const virSecretDef *def) def->description); if (def->usage_type !=3D VIR_SECRET_USAGE_TYPE_NONE && virSecretDefFormatUsage(&buf, def) < 0) - goto error; + return NULL; virBufferAdjustIndent(&buf, -2); virBufferAddLit(&buf, "\n"); =20 return virBufferContentAndReset(&buf); - - error: - return NULL; } diff --git a/src/conf/snapshot_conf.c b/src/conf/snapshot_conf.c index b7ed3b42df..07336e914f 100644 --- a/src/conf/snapshot_conf.c +++ b/src/conf/snapshot_conf.c @@ -877,7 +877,7 @@ virDomainSnapshotDefFormatInternal(virBufferPtr buf, virBufferAdjustIndent(buf, 2); for (i =3D 0; i < def->ndisks; i++) { if (virDomainSnapshotDiskDefFormat(buf, &def->disks[i], xmlopt= ) < 0) - goto error; + return -1; } virBufferAdjustIndent(buf, -2); virBufferAddLit(buf, "\n"); @@ -886,7 +886,7 @@ virDomainSnapshotDefFormatInternal(virBufferPtr buf, if (def->parent.dom) { if (virDomainDefFormatInternal(def->parent.dom, xmlopt, buf, domainflags) < 0) - goto error; + return -1; } else if (uuidstr) { virBufferAddLit(buf, "\n"); virBufferAdjustIndent(buf, 2); @@ -899,12 +899,12 @@ virDomainSnapshotDefFormatInternal(virBufferPtr buf, if (virDomainDefFormatInternalSetRootName(def->parent.inactiveDom,= xmlopt, buf, "inactiveDomain", domainflags) < 0) - goto error; + return -1; } =20 if (virSaveCookieFormatBuf(buf, def->cookie, virDomainXMLOptionGetSaveCookie(xmlopt)) < = 0) - goto error; + return -1; =20 if (flags & VIR_DOMAIN_SNAPSHOT_FORMAT_INTERNAL) virBufferAsprintf(buf, "%d\n", @@ -914,9 +914,6 @@ virDomainSnapshotDefFormatInternal(virBufferPtr buf, virBufferAddLit(buf, "\n"); =20 return 0; - - error: - return -1; } =20 =20 diff --git a/src/conf/storage_conf.c b/src/conf/storage_conf.c index 7bc743887c..65d9b33049 100644 --- a/src/conf/storage_conf.c +++ b/src/conf/storage_conf.c @@ -1226,12 +1226,9 @@ virStoragePoolDefFormat(virStoragePoolDefPtr def) g_auto(virBuffer) buf =3D VIR_BUFFER_INITIALIZER; =20 if (virStoragePoolDefFormatBuf(&buf, def) < 0) - goto error; + return NULL; =20 return virBufferContentAndReset(&buf); - - error: - return NULL; } =20 =20 @@ -1648,21 +1645,18 @@ virStorageVolDefFormat(virStoragePoolDefPtr pool, =20 if (virStorageVolTargetDefFormat(options, &buf, &def->target, "target") < 0) - goto cleanup; + return NULL; =20 if (virStorageSourceHasBacking(&def->target) && virStorageVolTargetDefFormat(options, &buf, def->target.backingStore, "backingStore") < 0) - goto cleanup; + return NULL; =20 virBufferAdjustIndent(&buf, -2); virBufferAddLit(&buf, "\n"); =20 return virBufferContentAndReset(&buf); - - cleanup: - return NULL; } =20 =20 @@ -1753,7 +1747,7 @@ virStoragePoolSourceListFormat(virStoragePoolSourceLi= stPtr def) if (!type) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("unexpected pool type")); - goto cleanup; + return NULL; } =20 virBufferAddLit(&buf, "\n"); @@ -1766,7 +1760,4 @@ virStoragePoolSourceListFormat(virStoragePoolSourceLi= stPtr def) virBufferAddLit(&buf, "\n"); =20 return virBufferContentAndReset(&buf); - - cleanup: - return NULL; } diff --git a/src/conf/virnetworkobj.c b/src/conf/virnetworkobj.c index 5d90dec2bc..8b12ce0482 100644 --- a/src/conf/virnetworkobj.c +++ b/src/conf/virnetworkobj.c @@ -820,7 +820,7 @@ virNetworkObjFormat(virNetworkObjPtr obj, size_t i; =20 if (!classIdStr) - goto error; + return NULL; =20 virBufferAddLit(&buf, "\n"); virBufferAdjustIndent(&buf, 2); @@ -835,15 +835,12 @@ virNetworkObjFormat(virNetworkObjPtr obj, } =20 if (virNetworkDefFormatBuf(&buf, obj->def, xmlopt, flags) < 0) - goto error; + return NULL; =20 virBufferAdjustIndent(&buf, -2); virBufferAddLit(&buf, ""); =20 return virBufferContentAndReset(&buf); - - error: - return NULL; } =20 =20 diff --git a/src/conf/virsavecookie.c b/src/conf/virsavecookie.c index 429daf69be..d8c51ce0ef 100644 --- a/src/conf/virsavecookie.c +++ b/src/conf/virsavecookie.c @@ -130,10 +130,7 @@ virSaveCookieFormat(virObjectPtr obj, g_auto(virBuffer) buf =3D VIR_BUFFER_INITIALIZER; =20 if (virSaveCookieFormatBuf(&buf, obj, saveCookie) < 0) - goto error; + return NULL; =20 return virBufferContentAndReset(&buf); - - error: - return NULL; } --=20 2.25.4 From nobody Mon May 6 01:10:47 2024 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=1594006946; cv=none; d=zohomail.com; s=zohoarc; b=AXkkznau0swc+mITpnPGwgEyN07iw79lF6DOrMz/85SPLADYgUAXXF9b1sD3JaQ2p4AV3geJPTdvwmXMw9+CnFj3nTVfckPsqLNitKtIZExxTPCCc3jsCUp6wpsexH/qfmlw1yufBbqsQulbZIL3Oe3fJC/TVyl+35AnswhL6PU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1594006946; 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=zakrDooXfkU1Mo85Jr9Q8aZZSyonYd4r1Xv9U2dA1JQ=; b=g+iDv/3dx2+1D9fqMTDIUtjZFuS6xPGWVzyqIBPybkpo/41xPhuqgpJRyi2XZIS+J6un83Ud0DGWJUNIgLDF58WyCud8JaC7JMFFFaj+/Ez6aYrZq3p2Q1WUGB4TzW56if2lvuaqm1DWi6taYONxzSWpnJ+Jy7rnIun4dKX9j2c= 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 1594006946604998.0998584125244; Sun, 5 Jul 2020 20:42:26 -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-181-jGUbIkrtPS-vEJvtx1u-Mw-1; Sun, 05 Jul 2020 23:42:23 -0400 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 25A9F18FE86A; Mon, 6 Jul 2020 03:42:17 +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 09D2A6E6E4; Mon, 6 Jul 2020 03:42:17 +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 D260293F70; Mon, 6 Jul 2020 03:42:16 +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 0663gAwJ004719 for ; Sun, 5 Jul 2020 23:42:10 -0400 Received: by smtp.corp.redhat.com (Postfix) id 8EF26275E39; Mon, 6 Jul 2020 03:42:10 +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 4346C275E36 for ; Mon, 6 Jul 2020 03:42:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1594006945; 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=zakrDooXfkU1Mo85Jr9Q8aZZSyonYd4r1Xv9U2dA1JQ=; b=NTch6HQ4FjdNAipDfr2i9Kar04t7Bxs/I8Zus3rEZjzBh4sY5VRE84t+ZhArW2bJLqqpb1 3wqXvCINHYv9B0RAkRJFTGywqSfdEnenbJ63NbkxoiuGU7tYzr+ipIIVRpMl6ZiGrLmMVI jmFO8rssZNxQVJvIqne/ox1S4N7Qgos= X-MC-Unique: jGUbIkrtPS-vEJvtx1u-Mw-1 From: Laine Stump To: libvir-list@redhat.com Subject: [PATCH 22/32] libxl: eliminate unnecessary labels Date: Sun, 5 Jul 2020 23:41:17 -0400 Message-Id: <20200706034127.1117504-23-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.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-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/libxl/libxl_conf.c | 11 ++++------- src/libxl/xen_common.c | 16 +++++----------- src/libxl/xen_xl.c | 25 ++++++++----------------- src/libxl/xen_xm.c | 7 ++----- 4 files changed, 19 insertions(+), 40 deletions(-) diff --git a/src/libxl/libxl_conf.c b/src/libxl/libxl_conf.c index fe8ad4a3cb..02cc5e6f1b 100644 --- a/src/libxl/libxl_conf.c +++ b/src/libxl/libxl_conf.c @@ -910,7 +910,6 @@ libxlMakeNetworkDiskSrcStr(virStorageSourcePtr src, const char *username, const char *secret) { - char *ret =3D NULL; g_auto(virBuffer) buf =3D VIR_BUFFER_INITIALIZER; size_t i; =20 @@ -931,14 +930,14 @@ libxlMakeNetworkDiskSrcStr(virStorageSourcePtr src, virReportError(VIR_ERR_NO_SUPPORT, _("Unsupported network block protocol '%s'"), virStorageNetProtocolTypeToString(src->protocol)); - goto cleanup; + return NULL; =20 case VIR_STORAGE_NET_PROTOCOL_RBD: if (strchr(src->path, ':')) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("':' not allowed in RBD source volume name '%= s'"), src->path); - goto cleanup; + return NULL; } =20 virBufferStrcat(&buf, "rbd:", src->volume, "/", src->path, NULL); @@ -973,12 +972,10 @@ libxlMakeNetworkDiskSrcStr(virStorageSourcePtr src, if (src->configFile) virBufferEscape(&buf, '\\', ":", ":conf=3D%s", src->configFile= ); =20 - ret =3D virBufferContentAndReset(&buf); - break; + return virBufferContentAndReset(&buf); } =20 - cleanup: - return ret; + return NULL; } =20 static int diff --git a/src/libxl/xen_common.c b/src/libxl/xen_common.c index 6b16752c8a..475c64f944 100644 --- a/src/libxl/xen_common.c +++ b/src/libxl/xen_common.c @@ -1640,13 +1640,13 @@ xenFormatSerial(virConfValuePtr list, virDomainChrD= efPtr serial) if (serial) { ret =3D xenFormatSxprChr(serial, &buf); if (ret < 0) - goto cleanup; + return -1; } else { virBufferAddLit(&buf, "none"); } =20 if (VIR_ALLOC(val) < 0) - goto cleanup; + return -1; =20 val->type =3D VIR_CONF_STRING; val->str =3D virBufferContentAndReset(&buf); @@ -1659,9 +1659,6 @@ xenFormatSerial(virConfValuePtr list, virDomainChrDef= Ptr serial) list->list =3D val; =20 return 0; - - cleanup: - return -1; } =20 char * @@ -1781,12 +1778,12 @@ xenFormatNet(virConnectPtr conn, case VIR_DOMAIN_NET_TYPE_USER: virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("Unsupported net type= '%s'"), virDomainNetTypeToString(net->type)); - goto cleanup; + return -1; =20 case VIR_DOMAIN_NET_TYPE_LAST: default: virReportEnumRangeError(virDomainNetType, net->type); - goto cleanup; + return -1; } =20 if (virDomainNetGetModelString(net)) { @@ -1810,7 +1807,7 @@ xenFormatNet(virConnectPtr conn, virBufferAsprintf(&buf, ",rate=3D%lluKB/s", net->bandwidth->out->a= verage); =20 if (VIR_ALLOC(val) < 0) - goto cleanup; + return -1; =20 val->type =3D VIR_CONF_STRING; val->str =3D virBufferContentAndReset(&buf); @@ -1823,9 +1820,6 @@ xenFormatNet(virConnectPtr conn, list->list =3D val; =20 return 0; - - cleanup: - return -1; } =20 =20 diff --git a/src/libxl/xen_xl.c b/src/libxl/xen_xl.c index 4baf5e336e..b81c5d23ce 100644 --- a/src/libxl/xen_xl.c +++ b/src/libxl/xen_xl.c @@ -1412,11 +1412,10 @@ static int xenFormatXLVnode(virConfValuePtr list, virBufferPtr buf) { - int ret =3D -1; virConfValuePtr numaPnode, tmp; =20 if (VIR_ALLOC(numaPnode) < 0) - goto cleanup; + return -1; =20 /* Place VNODE directive */ numaPnode->type =3D VIR_CONF_STRING; @@ -1429,10 +1428,8 @@ xenFormatXLVnode(virConfValuePtr list, tmp->next =3D numaPnode; else list->list =3D numaPnode; - ret =3D 0; =20 - cleanup: - return ret; + return 0; } =20 static int @@ -1561,7 +1558,6 @@ xenFormatXLXenbusLimits(virConfPtr conf, virDomainDef= Ptr def) static char * xenFormatXLDiskSrcNet(virStorageSourcePtr src) { - char *ret =3D NULL; g_auto(virBuffer) buf =3D VIR_BUFFER_INITIALIZER; size_t i; =20 @@ -1582,14 +1578,14 @@ xenFormatXLDiskSrcNet(virStorageSourcePtr src) virReportError(VIR_ERR_NO_SUPPORT, _("Unsupported network block protocol '%s'"), virStorageNetProtocolTypeToString(src->protocol)); - goto cleanup; + return NULL; =20 case VIR_STORAGE_NET_PROTOCOL_RBD: if (strchr(src->path, ':')) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("':' not allowed in RBD source volume name '%= s'"), src->path); - goto cleanup; + return NULL; } =20 virBufferStrcat(&buf, "rbd:", src->volume, "/", src->path, NULL); @@ -1614,12 +1610,10 @@ xenFormatXLDiskSrcNet(virStorageSourcePtr src) } } =20 - ret =3D virBufferContentAndReset(&buf); - break; + return virBufferContentAndReset(&buf); } =20 - cleanup: - return ret; + return NULL; } =20 =20 @@ -2111,14 +2105,14 @@ xenFormatXLChannel(virConfValuePtr list, virDomainC= hrDefPtr channel) channel->source->data.nix.path); break; default: - goto cleanup; + return -1; } =20 /* name */ virBufferAsprintf(&buf, "name=3D%s", channel->target.name); =20 if (VIR_ALLOC(val) < 0) - goto cleanup; + return -1; =20 val->type =3D VIR_CONF_STRING; val->str =3D virBufferContentAndReset(&buf); @@ -2130,9 +2124,6 @@ xenFormatXLChannel(virConfValuePtr list, virDomainChr= DefPtr channel) else list->list =3D val; return 0; - - cleanup: - return -1; } =20 static int diff --git a/src/libxl/xen_xm.c b/src/libxl/xen_xm.c index f28326ade8..81b64a2fb4 100644 --- a/src/libxl/xen_xm.c +++ b/src/libxl/xen_xm.c @@ -322,7 +322,7 @@ xenFormatXMDisk(virConfValuePtr list, virReportError(VIR_ERR_INTERNAL_ERROR, _("unsupported disk type %s"), virStorageTypeToString(virDomainDiskGetType= (disk))); - goto cleanup; + return -1; } } virBufferAdd(&buf, src, -1); @@ -346,7 +346,7 @@ xenFormatXMDisk(virConfValuePtr list, } =20 if (VIR_ALLOC(val) < 0) - goto cleanup; + return -1; =20 val->type =3D VIR_CONF_STRING; val->str =3D virBufferContentAndReset(&buf); @@ -359,9 +359,6 @@ xenFormatXMDisk(virConfValuePtr list, list->list =3D val; =20 return 0; - - cleanup: - return -1; } =20 =20 --=20 2.25.4 From nobody Mon May 6 01:10:47 2024 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=1594007167; cv=none; d=zohomail.com; s=zohoarc; b=XrKtyeTXZHJ7oZsm5CVZqnbrUru444jpk64ICY2fpcr2qHpvDSSAZfe+p7EMZNyTYjvoZCdDcikMi9UZ6hh2m4yGon5lu9EhSDmqdezrQLkuyHr3JkUizfDcv0DL5rssn+6QsYDM7odX8Y6HHqRAlBPXYAUJci1ndLLlfRF7pzo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1594007167; 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=qFG0ToKZsZg+7Te0SVX7S5NgxhjphVimAxy/uJEteT8=; b=W76QbiGgKk1H+9jmQf+jCLdIqiONAJJl5xHc72vGBdBIfyENQym2R7a3iHylEHnbQtfGuts+rFD0AI0enEXVv8rV2nWVHJdIuIBlvOtRjb32rCAkG1qAsebE+8LDIn1mzBkzMyAks9sOlcWJXX2xvJ0U1bUQCpd1JL7v/ez3Ul4= 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 1594007167032161.14253228081668; Sun, 5 Jul 2020 20:46:07 -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-402-sIb4MazoM6aXZ6HJ7dJaQg-1; Sun, 05 Jul 2020 23:42:37 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id EF49191184; Mon, 6 Jul 2020 03:42:30 +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 CE33060C80; Mon, 6 Jul 2020 03:42:30 +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 9DB6E180531A; Mon, 6 Jul 2020 03:42:30 +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 0663gDqo004742 for ; Sun, 5 Jul 2020 23:42:13 -0400 Received: by smtp.corp.redhat.com (Postfix) id 4B14D275E39; Mon, 6 Jul 2020 03:42:13 +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 F4162275E36 for ; Mon, 6 Jul 2020 03:42:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1594007165; 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=qFG0ToKZsZg+7Te0SVX7S5NgxhjphVimAxy/uJEteT8=; b=VfL/4TI67cN8LnWmsuRqLIybUS/SJzbpEQHdJmw+wFfj17lqesxYevSO0fJk+DG2ZYTQHS EdXr13nLeMVAYdefA6Vg51x3FwLxNGCYc6M8fLj3PGvErYdBMKqn7N3D07+gvW0agk7GaM Q+AjKxBLi4truJTV/RDjEu8DREoYzFY= X-MC-Unique: sIb4MazoM6aXZ6HJ7dJaQg-1 From: Laine Stump To: libvir-list@redhat.com Subject: [PATCH 23/32] util: eliminate unnecessary labels Date: Sun, 5 Jul 2020 23:41:18 -0400 Message-Id: <20200706034127.1117504-24-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.79 on 10.5.11.12 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/util/virqemu.c | 8 ++------ src/util/virsocketaddr.c | 22 +++++++--------------- src/util/virxml.c | 8 ++------ 3 files changed, 11 insertions(+), 27 deletions(-) diff --git a/src/util/virqemu.c b/src/util/virqemu.c index 52f3a2ca12..486b8e03db 100644 --- a/src/util/virqemu.c +++ b/src/util/virqemu.c @@ -361,16 +361,12 @@ char * virQEMUBuildDriveCommandlineFromJSON(virJSONValuePtr srcdef) { g_auto(virBuffer) buf =3D VIR_BUFFER_INITIALIZER; - char *ret =3D NULL; =20 if (virQEMUBuildCommandLineJSON(srcdef, &buf, NULL, false, virQEMUBuildCommandLineJSONArrayNumber= ed) < 0) - goto cleanup; - - ret =3D virBufferContentAndReset(&buf); + return NULL; =20 - cleanup: - return ret; + return virBufferContentAndReset(&buf); } =20 =20 diff --git a/src/util/virsocketaddr.c b/src/util/virsocketaddr.c index 0fda8e101b..e0eb76ded3 100644 --- a/src/util/virsocketaddr.c +++ b/src/util/virsocketaddr.c @@ -1265,16 +1265,15 @@ virSocketAddrPTRDomain(const virSocketAddr *addr, { g_auto(virBuffer) buf =3D VIR_BUFFER_INITIALIZER; size_t i; - int ret =3D -1; =20 if (VIR_SOCKET_ADDR_IS_FAMILY(addr, AF_INET)) { virSocketAddrIPv4 ip; =20 if (prefix =3D=3D 0 || prefix >=3D 32 || prefix % 8 !=3D 0) - goto unsupported; + return -2; =20 if (virSocketAddrGetIPv4Addr(addr, &ip) < 0) - goto cleanup; + return -1; =20 for (i =3D prefix / 8; i > 0; i--) virBufferAsprintf(&buf, "%u.", ip[i - 1]); @@ -1284,30 +1283,23 @@ virSocketAddrPTRDomain(const virSocketAddr *addr, virSocketAddrIPv6Nibbles ip; =20 if (prefix =3D=3D 0 || prefix >=3D 128 || prefix % 4 !=3D 0) - goto unsupported; + return -2; =20 if (virSocketAddrGetIPv6Nibbles(addr, &ip) < 0) - goto cleanup; + return -1; =20 for (i =3D prefix / 4; i > 0; i--) virBufferAsprintf(&buf, "%x.", ip[i - 1]); =20 virBufferAddLit(&buf, VIR_SOCKET_ADDR_IPV6_ARPA); } else { - goto unsupported; + return -2; } =20 if (!(*ptr =3D virBufferContentAndReset(&buf))) - goto cleanup; - - ret =3D 0; - - cleanup: - return ret; + return -1; =20 - unsupported: - ret =3D -2; - goto cleanup; + return 0; } =20 void diff --git a/src/util/virxml.c b/src/util/virxml.c index 56e6f67597..5558b3829f 100644 --- a/src/util/virxml.c +++ b/src/util/virxml.c @@ -1271,19 +1271,15 @@ int virXMLValidatorValidate(virXMLValidatorPtr validator, xmlDocPtr doc) { - int ret =3D -1; - if (xmlRelaxNGValidateDoc(validator->rngValid, doc) !=3D 0) { virReportError(VIR_ERR_XML_INVALID_SCHEMA, _("Unable to validate doc against %s\n%s"), validator->schemafile, virBufferCurrentContent(&validator->buf)); - goto cleanup; + return -1; } =20 - ret =3D 0; - cleanup: - return ret; + return 0; } =20 =20 --=20 2.25.4 From nobody Mon May 6 01:10:47 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 205.139.110.120 as permitted sender) client-ip=205.139.110.120; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.120 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=1594006990; cv=none; d=zohomail.com; s=zohoarc; b=MSAlzCrJIDhAPWSZQ5cgCGmpVaXPNycdgmAjyLyWSps/JHuvTltmmHl02cwmrtb95e2TW10tnfoa4qQCkRn816gwg9jhPEYSlQ1BjqlW/2sBDzbT7r4+Mf3MyJCpigyeIvRSIpA4NGvfdfcT0DJc4zO2DdXO+QMxdUOEWT7c/rw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1594006990; 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=4O0jYAR/dxPDmxowKVgpwH4OPud+2zbK58YXHD94MGI=; b=beryDhBAauXevJxvY6aptLdcs60oQLjoF6PIoa6JGeTtELlIm+e9TbYbRlqhJEZzCjTfd1Qy2A+lsAepYoLilxomB3sRx6gbcS54PY3fxjK/iDhrkEB0vk3QZs9lkVs1KtWvds8xibH/wwI1JFCeel9G+H/YcrLYlPalgXumsCk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.120 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-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) by mx.zohomail.com with SMTPS id 1594006990100306.7867703635053; Sun, 5 Jul 2020 20:43:10 -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-187-XX2JhUECNL23xilBSibZ_Q-1; Sun, 05 Jul 2020 23:42:26 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 739668015CE; Mon, 6 Jul 2020 03:42:20 +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 4E2AB7BEAF; Mon, 6 Jul 2020 03:42:20 +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 03E2F93F85; Mon, 6 Jul 2020 03:42:20 +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 0663gGp6004770 for ; Sun, 5 Jul 2020 23:42:16 -0400 Received: by smtp.corp.redhat.com (Postfix) id 65DF3285858; Mon, 6 Jul 2020 03:42:16 +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 08A81275E36 for ; Mon, 6 Jul 2020 03:42:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1594006989; 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=4O0jYAR/dxPDmxowKVgpwH4OPud+2zbK58YXHD94MGI=; b=YMhV76MQc9jOKvLopWxFYHOnZpKE/dNoq066NeLmCY9GZw4vW8b1IFT15C5vnTp8XvAezm tbJO/x/HTANDX2JFjb+QFaJFZacBAB/buPvkTVsSFBbMPnF4SjHOvr4/kW7vS6MTZIoZUE tWNsvnKKs2x/rSafhzo7Ky3/9/Usj04= X-MC-Unique: XX2JhUECNL23xilBSibZ_Q-1 From: Laine Stump To: libvir-list@redhat.com Subject: [PATCH 24/32] tests: eliminate unnecessary labels Date: Sun, 5 Jul 2020 23:41:19 -0400 Message-Id: <20200706034127.1117504-25-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.79 on 10.5.11.13 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 --- tests/virbuftest.c | 35 ++++++++++++++--------------------- 1 file changed, 14 insertions(+), 21 deletions(-) diff --git a/tests/virbuftest.c b/tests/virbuftest.c index 39ae7c2b9d..df341be50c 100644 --- a/tests/virbuftest.c +++ b/tests/virbuftest.c @@ -100,7 +100,6 @@ static int testBufTrim(const void *data G_GNUC_UNUSED) virBufferPtr buf =3D NULL; g_autofree char *result =3D NULL; const char *expected =3D "a,b"; - int ret =3D -1; =20 virBufferTrim(buf, ""); buf =3D &bufinit; @@ -120,13 +119,10 @@ static int testBufTrim(const void *data G_GNUC_UNUSED) result =3D virBufferContentAndReset(buf); if (!result || STRNEQ(result, expected)) { virTestDifference(stderr, expected, result); - goto cleanup; + return -1; } =20 - ret =3D 0; - - cleanup: - return ret; + return 0; } =20 static int @@ -158,7 +154,6 @@ static int testBufAddBuffer(const void *data G_GNUC_UNU= SED) g_auto(virBuffer) buf1 =3D VIR_BUFFER_INITIALIZER; g_auto(virBuffer) buf2 =3D VIR_BUFFER_INITIALIZER; g_auto(virBuffer) buf3 =3D VIR_BUFFER_INITIALIZER; - int ret =3D -1; g_autofree char *result =3D NULL; const char *expected =3D \ " A long time ago, in a galaxy far,\n" \ @@ -178,17 +173,17 @@ static int testBufAddBuffer(const void *data G_GNUC_U= NUSED) =20 if (virBufferUse(&buf1)) { VIR_TEST_DEBUG("buf1 already in use"); - goto cleanup; + return -1; } =20 if (virBufferUse(&buf2)) { VIR_TEST_DEBUG("buf2 already in use"); - goto cleanup; + return -1; } =20 if (virBufferUse(&buf3)) { VIR_TEST_DEBUG("buf3 already in use"); - goto cleanup; + return -1; } =20 virBufferAdjustIndent(&buf1, 2); @@ -213,52 +208,50 @@ static int testBufAddBuffer(const void *data G_GNUC_U= NUSED) =20 if (!virBufferUse(&buf1)) { VIR_TEST_DEBUG("Error adding to buf1"); - goto cleanup; + return -1; } =20 if (!virBufferUse(&buf2)) { VIR_TEST_DEBUG("Error adding to buf2"); - goto cleanup; + return -1; } =20 if (!virBufferUse(&buf3)) { VIR_TEST_DEBUG("Error adding to buf3"); - goto cleanup; + return -1; } =20 virBufferAddBuffer(&buf2, &buf3); =20 if (!virBufferUse(&buf2)) { VIR_TEST_DEBUG("buf2 cleared mistakenly"); - goto cleanup; + return -1; } =20 if (virBufferUse(&buf3)) { VIR_TEST_DEBUG("buf3 is not clear even though it should be"); - goto cleanup; + return -1; } =20 virBufferAddBuffer(&buf1, &buf2); =20 if (!virBufferUse(&buf1)) { VIR_TEST_DEBUG("buf1 cleared mistakenly"); - goto cleanup; + return -1; } =20 if (virBufferUse(&buf2)) { VIR_TEST_DEBUG("buf2 is not clear even though it should be"); - goto cleanup; + return -1; } =20 result =3D virBufferContentAndReset(&buf1); if (STRNEQ_NULLABLE(result, expected)) { virTestDifference(stderr, expected, result); - goto cleanup; + return -1; } =20 - ret =3D 0; - cleanup: - return ret; + return 0; } =20 static int --=20 2.25.4 From nobody Mon May 6 01:10:47 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 205.139.110.120 as permitted sender) client-ip=205.139.110.120; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.120 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=1594006961; cv=none; d=zohomail.com; s=zohoarc; b=mnU4tkt/ujm37hnHEjPhEiytgYIHLuEGWIeFmIiozFGisC/lAYtkA550XyKsx7mOjTX5aiDB7BtoUlX+Li4anBlYuQYKcUResdj4LS0Dh4sayUSoX9O1qddRqNj1vRTCEvxGxC0ydSp3juTEEyLHwk2xv2VDj3/YogDKsDsu6u8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1594006961; 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=laWQakcMevmqsiqf5MTBV1Zjgtzy8lqUrQwa1NcZuGA=; b=IDKc7JpQDM+0vk4zQcAbSj4J6cXBRW/XyRmPscRyZS7Y3O+FZQzaktVcYOx5STD1iDvOjWvMa7IBz1ozmU+7WB6BAwgdH3q1bQDtwo7F3jNdPe4K2BY721SulkBh3osT35p8mDhv+n2NN34yDcqeO+3RqejJw3pRR/S+709V7Ek= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.120 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-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) by mx.zohomail.com with SMTPS id 1594006961860796.0055268548829; Sun, 5 Jul 2020 20:42:41 -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-172-XGxOG_VfOOWtPxNy2iMF_A-1; Sun, 05 Jul 2020 23:42:38 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 402F6805F02; Mon, 6 Jul 2020 03:42:33 +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 1C3292DE7C; Mon, 6 Jul 2020 03:42:33 +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 E1A3093F96; Mon, 6 Jul 2020 03:42:32 +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 0663gGR5004777 for ; Sun, 5 Jul 2020 23:42:16 -0400 Received: by smtp.corp.redhat.com (Postfix) id ED43D71678; Mon, 6 Jul 2020 03:42:16 +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 88410275E4B for ; Mon, 6 Jul 2020 03:42:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1594006960; 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=laWQakcMevmqsiqf5MTBV1Zjgtzy8lqUrQwa1NcZuGA=; b=JDHg0AZwNvcfNpbah01+bv3CDiRj3szgm/QjVSkhi5WhV/g6OCsT2oPynK5cxws01SJkhq rlP2+7Q6MfHzzlhW3052AyGfqbprqEfgkfL2w8YDyFJq4KPaYyMHv+JeVJ9JYh7F1RMpMb AMVj6zCzmP+UPuHcZLQHn6Jm6C8zM/E= X-MC-Unique: XGxOG_VfOOWtPxNy2iMF_A-1 From: Laine Stump To: libvir-list@redhat.com Subject: [PATCH 25/32] tools: eliminate unnecessary labels Date: Sun, 5 Jul 2020 23:41:20 -0400 Message-Id: <20200706034127.1117504-26-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.23 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 --- tools/virsh-pool.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/tools/virsh-pool.c b/tools/virsh-pool.c index 885e000ed2..622b1396d0 100644 --- a/tools/virsh-pool.c +++ b/tools/virsh-pool.c @@ -330,9 +330,10 @@ virshBuildPoolXML(vshControl *ctl, VSH_EXCLUSIVE_OPTIONS("secret-usage", "secret-uuid"); =20 if (vshCommandOptStringReq(ctl, cmd, "name", &name) < 0) - goto cleanup; + return false; + if (vshCommandOptStringReq(ctl, cmd, "type", &type) < 0) - goto cleanup; + return false; =20 if (vshCommandOptStringReq(ctl, cmd, "source-host", &srcHost) < 0 || vshCommandOptStringReq(ctl, cmd, "source-path", &srcPath) < 0 || @@ -351,8 +352,9 @@ virshBuildPoolXML(vshControl *ctl, vshCommandOptStringReq(ctl, cmd, "adapter-parent-wwnn", &adapterPa= rentWwnn) < 0 || vshCommandOptStringReq(ctl, cmd, "adapter-parent-wwpn", &adapterPa= rentWwpn) < 0 || vshCommandOptStringReq(ctl, cmd, "adapter-parent-fabric-wwn", &ada= pterParentFabricWwn) < 0 || - vshCommandOptStringReq(ctl, cmd, "source-protocol-ver", &protoVer)= < 0) - goto cleanup; + vshCommandOptStringReq(ctl, cmd, "source-protocol-ver", &protoVer)= < 0) { + return false; + } =20 virBufferAsprintf(&buf, "\n", type); virBufferAdjustIndent(&buf, 2); @@ -419,9 +421,6 @@ virshBuildPoolXML(vshControl *ctl, *xml =3D virBufferContentAndReset(&buf); *retname =3D name; return true; - - cleanup: - return false; } =20 /* --=20 2.25.4 From nobody Mon May 6 01:10:47 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 205.139.110.120 as permitted sender) client-ip=205.139.110.120; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.120 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=1594006952; cv=none; d=zohomail.com; s=zohoarc; b=nSUzLpu1QjfqYW4LG3E6C4GPiQfZocEhJ+Zharh3NhLcL9QlvA6MqNv8qzJxJFmKNGkGpBQ23eG0npDChpEOvrfroO9vf1QCPk5zhDaH8OBVroJnaVhgxM0D751MiUJI+A9JLPZr/JOKIHfKusm2BjTuH7Ip0KURmuYX/0MEmn0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1594006952; 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=NVjXIGV6BzJT/kz1MDZTALZ/yKSNZFQEFqmyWWb6qJs=; b=OS+ffdyhSfijBPeP22ig+R0IwWDpGG7d1/HQz3yhcoSt0AjIkB8jauwNUHDFZjaEUn+dFjWRoWybAGLW4tbgp5iXx+oZreP17gy7wlElas24iQ1327kQgL8148yGEAm/HYLMqn4f+6GtpsKLi+wCDwkkJ8GRhXbMsK8lWPuv1y8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.120 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-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) by mx.zohomail.com with SMTPS id 1594006952641535.9945274983802; Sun, 5 Jul 2020 20:42:32 -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-194-LJSmllBgOUW_3LpEAYtmww-1; Sun, 05 Jul 2020 23:42:29 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 9041918FE873; Mon, 6 Jul 2020 03:42:23 +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 6DB162DE79; Mon, 6 Jul 2020 03:42:23 +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 4189F180530D; Mon, 6 Jul 2020 03:42:23 +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 0663gHCj004782 for ; Sun, 5 Jul 2020 23:42:17 -0400 Received: by smtp.corp.redhat.com (Postfix) id 5BD187AC9F; Mon, 6 Jul 2020 03:42:17 +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 103A271678 for ; Mon, 6 Jul 2020 03:42:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1594006951; 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=NVjXIGV6BzJT/kz1MDZTALZ/yKSNZFQEFqmyWWb6qJs=; b=UuFGqXl8EY0NR+C4WPsRD6gXbLhAPwskcADvobwOeyd8bKNDPMB1WL3tNe+bh0T6HcqyUS sNCKexmAX85WLlxAg6muEM2+L+FdoVC4r/zx564uxxaIdOiVi1LhU4VD5c4lvpqtV1h4d8 nOaP0cxfyQAaIIUVbG3PebVKxev24bU= X-MC-Unique: LJSmllBgOUW_3LpEAYtmww-1 From: Laine Stump To: libvir-list@redhat.com Subject: [PATCH 26/32] network: eliminate unnecessary labels Date: Sun, 5 Jul 2020 23:41:21 -0400 Message-Id: <20200706034127.1117504-27-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.23 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/network/bridge_driver.c | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/src/network/bridge_driver.c b/src/network/bridge_driver.c index 9f37d8f558..713763130b 100644 --- a/src/network/bridge_driver.c +++ b/src/network/bridge_driver.c @@ -1842,7 +1842,6 @@ networkRadvdConfContents(virNetworkObjPtr obj, { virNetworkDefPtr def =3D virNetworkObjGetDef(obj); g_auto(virBuffer) configbuf =3D VIR_BUFFER_INITIALIZER; - int ret =3D -1; size_t i; virNetworkIPDefPtr ipdef; bool v6present =3D false, dhcp6 =3D false; @@ -1859,10 +1858,8 @@ networkRadvdConfContents(virNetworkObjPtr obj, } =20 /* If there are no IPv6 addresses, then we are done */ - if (!v6present) { - ret =3D 0; - goto cleanup; - } + if (!v6present) + return 0; =20 /* create radvd config file appropriate for this network; * IgnoreIfMissing allows radvd to start even when the bridge is down @@ -1887,10 +1884,11 @@ networkRadvdConfContents(virNetworkObjPtr obj, virReportError(VIR_ERR_INTERNAL_ERROR, _("bridge '%s' has an invalid prefix"), def->bridge); - goto cleanup; + return -1; } if (!(netaddr =3D virSocketAddrFormat(&ipdef->address))) - goto cleanup; + return -1; + virBufferAsprintf(&configbuf, " prefix %s/%d\n" " {\n%s };\n", @@ -1903,9 +1901,7 @@ networkRadvdConfContents(virNetworkObjPtr obj, =20 *configstr =3D virBufferContentAndReset(&configbuf); =20 - ret =3D 0; - cleanup: - return ret; + return 0; } =20 =20 --=20 2.25.4 From nobody Mon May 6 01:10:47 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 207.211.31.120 as permitted sender) client-ip=207.211.31.120; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.120 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=1594006960; cv=none; d=zohomail.com; s=zohoarc; b=c0zRzVzBgjOZ2ZQf8UKkVJFAqQflanCfnqP22yUXrVZvi0lVy2hnpHVcligZ/ALw0Up4+MD2uv0NhmQXphjwKW1NXxS3fiMEl8IdC3k1+JC35XQnsl0HRBafc6TI2FFPc7sXWtLfGCPehW1xGzBVwK5K5S1AulXofasXdqFIo1Y= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1594006960; 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=xmzSoaCsvPRaX/A6Sffu3wGexeStq8/QHwVeHdniF9w=; b=VZ7ieYn4Mdtn4elCdPcuIm2VP5O87i/v7V0HYAcs9nsmu2txSDP4LI7iJZOEmSc934HsrlWThhuG2B3C/iYPoG8woSWpwqZd6rcKH7zqqki9VKf8ZItkp0inzb7c5YU+9p7mw3QArw2GKM2EbGWH/JoeluLoPmFdqHgnYVM9ki8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.120 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-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) by mx.zohomail.com with SMTPS id 1594006960977505.09390513392896; Sun, 5 Jul 2020 20:42:40 -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-475-QLdjHn1bOki9l-8OsqgUQw-1; Sun, 05 Jul 2020 23:42:37 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 6F8A28064B0; Mon, 6 Jul 2020 03:42:32 +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 525A271678; Mon, 6 Jul 2020 03:42:32 +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 255E8180531D; Mon, 6 Jul 2020 03:42:32 +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 0663gHbj004794 for ; Sun, 5 Jul 2020 23:42:17 -0400 Received: by smtp.corp.redhat.com (Postfix) id D4B157AC9F; Mon, 6 Jul 2020 03:42:17 +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 8ACC371678 for ; Mon, 6 Jul 2020 03:42:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1594006959; 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=xmzSoaCsvPRaX/A6Sffu3wGexeStq8/QHwVeHdniF9w=; b=gcAjE7cRrlptk/1ZDAS+XUcfKJF8E+IDUqydiDzrVmET8qgaTWcRDBDrifii7yFG05fuAd YDZIYg6vZVKmt225HXTVywBKq4o+G9CKc0OQEfCE0bK01sVDUaElzfl18lvzJki9eqj23j 7e467tyJQJiuhGzXXAIrYtch9iOnAZ8= X-MC-Unique: QLdjHn1bOki9l-8OsqgUQw-1 From: Laine Stump To: libvir-list@redhat.com Subject: [PATCH 27/32] lxc: eliminate unnecessary labels Date: Sun, 5 Jul 2020 23:41:22 -0400 Message-Id: <20200706034127.1117504-28-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.79 on 10.5.11.11 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/lxc/lxc_controller.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/lxc/lxc_controller.c b/src/lxc/lxc_controller.c index 01cdeb29db..ae6b737b60 100644 --- a/src/lxc/lxc_controller.c +++ b/src/lxc/lxc_controller.c @@ -1380,13 +1380,12 @@ virLXCControllerSetupUsernsMap(virDomainIdMapEntryP= tr map, { g_auto(virBuffer) map_value =3D VIR_BUFFER_INITIALIZER; size_t i; - int ret =3D -1; =20 /* The kernel supports up to 340 lines in /proc//{g,u}id_map */ if (num > 340) { virReportError(VIR_ERR_INVALID_ARG, "%s", _("Too many id mappings defined.")); - goto cleanup; + return -1; } =20 for (i =3D 0; i < num; i++) @@ -1397,12 +1396,10 @@ virLXCControllerSetupUsernsMap(virDomainIdMapEntryP= tr map, =20 if (virFileWriteStr(path, virBufferCurrentContent(&map_value), 0) < 0)= { virReportSystemError(errno, _("unable write to %s"), path); - goto cleanup; + return -1; } =20 - ret =3D 0; - cleanup: - return ret; + return 0; } =20 /** --=20 2.25.4 From nobody Mon May 6 01:10:47 2024 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=1594007164; cv=none; d=zohomail.com; s=zohoarc; b=Ci/LcMW5imhl3Qc4cmIxoqH+NgkU6UyNvLyOCUuy6nOvXHsCQYtUebGuIyyrQN0vHPRvgYO0O2YgOFF8pwAmskTEMeBUCGWbiKaOICjaa9rh08vN9d6HVJlqCJn7rhsmThIlkIQsV4aUf1FKb+wnJstU9GVxWv3OcVvOEutpVVs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1594007164; 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=7ri2TGDXx2NOaXTIl3JYUIeKYtB3x9gwOjOkNw2X3o4=; b=d1n8271PtecPB2owckVs8KBFx/Btkf5YDBlfYUsmN/M5GMee/pIEJBCFUfapvxFDW2EDMwOXws7SmYMvFOOpnlFESJOGoNo1MUH5f8cs8Z5nI7Q7sIZSJL/LYiPN45TOpDKvdmeEx0SaPyv+BWg7uLABMRBxa5R7SPGgyhXWHWk= 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 159400716427127.724424306689684; Sun, 5 Jul 2020 20:46:04 -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-495-9e0smErhN6GDs6fd-kY3hw-1; Sun, 05 Jul 2020 23:42:39 -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 B03AEA0BE3; Mon, 6 Jul 2020 03:42:34 +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 926265C1D4; Mon, 6 Jul 2020 03:42:34 +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 67CAC93F9A; Mon, 6 Jul 2020 03:42:34 +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 0663gIS7004800 for ; Sun, 5 Jul 2020 23:42:18 -0400 Received: by smtp.corp.redhat.com (Postfix) id 5A08A7AC9F; Mon, 6 Jul 2020 03:42:18 +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 0FBBF71678 for ; Mon, 6 Jul 2020 03:42:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1594007163; 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=7ri2TGDXx2NOaXTIl3JYUIeKYtB3x9gwOjOkNw2X3o4=; b=PjZYicL0kjKym3IozzJ5Cya6+11TkBK3Go5Qoms84UUhuEkLthmd4Tu52A1+PNtfDrtGID 2IEDKnZXiCK8gsP2toPnwGN3dZ/xD8zle/OpYgyGY+Oae4zUycCXmP3yFHJsDOW71oCTHP aayh7AFmSneyRjQO6cylnZt/cmcd1I4= X-MC-Unique: 9e0smErhN6GDs6fd-kY3hw-1 From: Laine Stump To: libvir-list@redhat.com Subject: [PATCH 28/32] esx: eliminate unnecessary labels Date: Sun, 5 Jul 2020 23:41:23 -0400 Message-Id: <20200706034127.1117504-29-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.79 on 10.5.11.16 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_vi.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/esx/esx_vi.c b/src/esx/esx_vi.c index d48a24e9d3..71aa3876b3 100644 --- a/src/esx/esx_vi.c +++ b/src/esx/esx_vi.c @@ -369,7 +369,7 @@ int esxVI_CURL_Download(esxVI_CURL *curl, const char *url, char **content, unsigned long long offset, unsigned long long *length) { - char *range =3D NULL; + g_autofree char *range =3D NULL; g_auto(virBuffer) buffer =3D VIR_BUFFER_INITIALIZER; int responseCode =3D 0; =20 @@ -405,12 +405,12 @@ esxVI_CURL_Download(esxVI_CURL *curl, const char *url= , char **content, virMutexUnlock(&curl->lock); =20 if (responseCode < 0) { - goto cleanup; + return -1; } else if (responseCode !=3D 200 && responseCode !=3D 206) { virReportError(VIR_ERR_INTERNAL_ERROR, _("HTTP response code %d for download from '%s'"), responseCode, url); - goto cleanup; + return -1; } =20 if (length) @@ -418,9 +418,6 @@ esxVI_CURL_Download(esxVI_CURL *curl, const char *url, = char **content, =20 *content =3D virBufferContentAndReset(&buffer); =20 - cleanup: - VIR_FREE(range); - if (!(*content)) return -1; =20 --=20 2.25.4 From nobody Mon May 6 01:10:47 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 205.139.110.120 as permitted sender) client-ip=205.139.110.120; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.120 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=1594007058; cv=none; d=zohomail.com; s=zohoarc; b=Fwg+kZXGFdmLOYVZP/hEZSUtsQL+onjCHygl1cIbhi/qbKtU2GDM3oyj46SFnhGts5jKuBV4yzkDjEzOWRumHSE8T8D/HkpMziun2Tv3itcBRV8Pvm4RS1v6obEsXzoTUiDt2F9HLNaCZMPr3GYIDTEMdxcbGZoJrWl28DvskmM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1594007058; 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=Pkat3x795bymnuOXuEVMQlzPQrsYx29NGaNzTmjwJvY=; b=bieOQHVbP1bWSMZHfIVG4aPeW2kztFLZMz9fVyj1HM7cERXf24biX55tZTdJXd8LI26YOqUDf+DUAsM1uTj/pwRgIfPbAxPcMNKbc4JBr/g7jIfee/8rP7WTU10a2x00LOsvds7wwID/7T3cQxdfwwTS9Hz/8vagaIC5pHvd1+o= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.120 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-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) by mx.zohomail.com with SMTPS id 1594007058629172.14667167674247; Sun, 5 Jul 2020 20:44:18 -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-57-FHzY23QfPFCUtGdAUo7uYg-1; Sun, 05 Jul 2020 23:42:40 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 66E5118FE864; Mon, 6 Jul 2020 03:42:35 +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 44A981A91F; Mon, 6 Jul 2020 03:42:35 +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 1482D1804746; Mon, 6 Jul 2020 03:42:35 +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 0663gI6k004806 for ; Sun, 5 Jul 2020 23:42:18 -0400 Received: by smtp.corp.redhat.com (Postfix) id D5B6C7AC9F; Mon, 6 Jul 2020 03:42:18 +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 8A31171678 for ; Mon, 6 Jul 2020 03:42:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1594007057; 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=Pkat3x795bymnuOXuEVMQlzPQrsYx29NGaNzTmjwJvY=; b=AJgwOOBA1G5fiMzGnGDHubLWkPK0gh7hreq0uHYTeBYtKYYNTM5WQsa8ghJxKpe5tkJwt7 D7EAwStRasSyaXQzKEIupmH3Uj+dFyN4hldZY/DorHz/BILTXlh2LrBbU9TOd650atq1DY rUTFHQ58RHirPgJ5tt+lWUT8HI6fOvw= X-MC-Unique: FHzY23QfPFCUtGdAUo7uYg-1 From: Laine Stump To: libvir-list@redhat.com Subject: [PATCH 29/32] nwfilter: eliminate unnecessary labels Date: Sun, 5 Jul 2020 23:41:24 -0400 Message-Id: <20200706034127.1117504-30-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.23 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/nwfilter/nwfilter_ebiptables_driver.c | 89 +++++++++++------------ 1 file changed, 43 insertions(+), 46 deletions(-) diff --git a/src/nwfilter/nwfilter_ebiptables_driver.c b/src/nwfilter/nwfil= ter_ebiptables_driver.c index dad631f03b..6cdb3ca45e 100644 --- a/src/nwfilter/nwfilter_ebiptables_driver.c +++ b/src/nwfilter/nwfilter_ebiptables_driver.c @@ -1797,7 +1797,6 @@ ebtablesCreateRuleInstance(virFirewallPtr fw, const char *target; bool hasMask =3D false; virFirewallRulePtr fwrule; - int ret =3D -1; g_auto(virBuffer) buf =3D VIR_BUFFER_INITIALIZER; =20 if (STREQ(chainSuffix, @@ -1813,7 +1812,7 @@ ebtablesCreateRuleInstance(virFirewallPtr fw, if (printDataType(vars, \ field, sizeof(field), \ &rule->p.STRUCT.ITEM) < 0) \ - goto cleanup; \ + return -1; \ virFirewallRuleAddArg(fw, fwrule, CLI); \ if (ENTRY_WANT_NEG_SIGN(&rule->p.STRUCT.ITEM)) \ virFirewallRuleAddArg(fw, fwrule, "!"); \ @@ -1825,7 +1824,7 @@ ebtablesCreateRuleInstance(virFirewallPtr fw, if (printDataType(vars, \ field, sizeof(field), \ &rule->p.STRUCT.ITEM) < 0) \ - goto cleanup; \ + return -1; \ virFirewallRuleAddArg(fw, fwrule, CLI); \ if (ENTRY_WANT_NEG_SIGN(&rule->p.STRUCT.ITEM)) \ virFirewallRuleAddArg(fw, fwrule, "!"); \ @@ -1833,7 +1832,7 @@ ebtablesCreateRuleInstance(virFirewallPtr fw, if (printDataType(vars, \ fieldalt, sizeof(fieldalt), \ &rule->p.STRUCT.ITEM_HI) < 0) \ - goto cleanup; \ + return -1; \ virFirewallRuleAddArgFormat(fw, fwrule, \ "%s%s%s", field, SEP, fieldalt= ); \ } else { \ @@ -1855,13 +1854,13 @@ ebtablesCreateRuleInstance(virFirewallPtr fw, vars, &rule->p.ethHdrFilter.ethHdr, reverse) < 0) - goto cleanup; + return -1; =20 if (HAS_ENTRY_ITEM(&rule->p.ethHdrFilter.dataProtocolID)) { if (printDataTypeAsHex(vars, number, sizeof(number), &rule->p.ethHdrFilter.dataProtocolID) <= 0) - goto cleanup; + return -1; virFirewallRuleAddArg(fw, fwrule, "-p"); if (ENTRY_WANT_NEG_SIGN(&rule->p.ethHdrFilter.dataProtocolID)) virFirewallRuleAddArg(fw, fwrule, "!"); @@ -1877,7 +1876,7 @@ ebtablesCreateRuleInstance(virFirewallPtr fw, vars, &rule->p.vlanHdrFilter.ethHdr, reverse) < 0) - goto cleanup; + return -1; =20 virFirewallRuleAddArgList(fw, fwrule, "-p", "0x8100", NULL); @@ -1906,7 +1905,7 @@ ebtablesCreateRuleInstance(virFirewallPtr fw, vars, &rule->p.stpHdrFilter.ethHdr, reverse) < 0) - goto cleanup; + return -1; =20 virFirewallRuleAddArgList(fw, fwrule, "-d", NWFILTER_MAC_BGA, NULL); @@ -1942,7 +1941,7 @@ ebtablesCreateRuleInstance(virFirewallPtr fw, vars, &rule->p.arpHdrFilter.ethHdr, reverse) < 0) - goto cleanup; + return -1; =20 virFirewallRuleAddArg(fw, fwrule, "-p"); virFirewallRuleAddArgFormat(fw, fwrule, "0x%x", @@ -1954,7 +1953,7 @@ ebtablesCreateRuleInstance(virFirewallPtr fw, if (printDataType(vars, number, sizeof(number), &rule->p.arpHdrFilter.dataHWType) < 0) - goto cleanup; + return -1; virFirewallRuleAddArg(fw, fwrule, "--arp-htype"); if (ENTRY_WANT_NEG_SIGN(&rule->p.arpHdrFilter.dataHWType)) virFirewallRuleAddArg(fw, fwrule, "!"); @@ -1965,7 +1964,7 @@ ebtablesCreateRuleInstance(virFirewallPtr fw, if (printDataType(vars, number, sizeof(number), &rule->p.arpHdrFilter.dataOpcode) < 0) - goto cleanup; + return -1; virFirewallRuleAddArg(fw, fwrule, "--arp-opcode"); if (ENTRY_WANT_NEG_SIGN(&rule->p.arpHdrFilter.dataOpcode)) virFirewallRuleAddArg(fw, fwrule, "!"); @@ -1976,7 +1975,7 @@ ebtablesCreateRuleInstance(virFirewallPtr fw, if (printDataTypeAsHex(vars, number, sizeof(number), &rule->p.arpHdrFilter.dataProtocolType)= < 0) - goto cleanup; + return -1; virFirewallRuleAddArg(fw, fwrule, "--arp-ptype"); if (ENTRY_WANT_NEG_SIGN(&rule->p.arpHdrFilter.dataProtocolType= )) virFirewallRuleAddArg(fw, fwrule, "!"); @@ -1987,13 +1986,13 @@ ebtablesCreateRuleInstance(virFirewallPtr fw, if (printDataType(vars, ipaddr, sizeof(ipaddr), &rule->p.arpHdrFilter.dataARPSrcIPAddr) < 0) - goto cleanup; + return -1; =20 if (HAS_ENTRY_ITEM(&rule->p.arpHdrFilter.dataARPSrcIPMask)) { if (printDataType(vars, ipmask, sizeof(ipmask), &rule->p.arpHdrFilter.dataARPSrcIPMask) = < 0) - goto cleanup; + return -1; hasMask =3D true; } =20 @@ -2009,13 +2008,13 @@ ebtablesCreateRuleInstance(virFirewallPtr fw, if (printDataType(vars, ipaddr, sizeof(ipaddr), &rule->p.arpHdrFilter.dataARPDstIPAddr) < 0) - goto cleanup; + return -1; =20 if (HAS_ENTRY_ITEM(&rule->p.arpHdrFilter.dataARPDstIPMask)) { if (printDataType(vars, ipmask, sizeof(ipmask), &rule->p.arpHdrFilter.dataARPDstIPMask) = < 0) - goto cleanup; + return -1; hasMask =3D true; } =20 @@ -2031,7 +2030,7 @@ ebtablesCreateRuleInstance(virFirewallPtr fw, if (printDataType(vars, macaddr, sizeof(macaddr), &rule->p.arpHdrFilter.dataARPSrcMACAddr) < 0) - goto cleanup; + return -1; =20 virFirewallRuleAddArg(fw, fwrule, reverse ? "--arp-mac-dst" : "--arp-mac-s= rc"); @@ -2044,7 +2043,7 @@ ebtablesCreateRuleInstance(virFirewallPtr fw, if (printDataType(vars, macaddr, sizeof(macaddr), &rule->p.arpHdrFilter.dataARPDstMACAddr) < 0) - goto cleanup; + return -1; =20 virFirewallRuleAddArg(fw, fwrule, reverse ? "--arp-mac-src" : "--arp-mac-d= st"); @@ -2069,7 +2068,7 @@ ebtablesCreateRuleInstance(virFirewallPtr fw, vars, &rule->p.ipHdrFilter.ethHdr, reverse) < 0) - goto cleanup; + return -1; =20 virFirewallRuleAddArgList(fw, fwrule, "-p", "ipv4", NULL); @@ -2078,7 +2077,7 @@ ebtablesCreateRuleInstance(virFirewallPtr fw, if (printDataType(vars, ipaddr, sizeof(ipaddr), &rule->p.ipHdrFilter.ipHdr.dataSrcIPAddr) < = 0) - goto cleanup; + return -1; =20 virFirewallRuleAddArg(fw, fwrule, reverse ? "--ip-destination" : "--ip-sou= rce"); @@ -2089,7 +2088,7 @@ ebtablesCreateRuleInstance(virFirewallPtr fw, if (printDataType(vars, number, sizeof(number), &rule->p.ipHdrFilter.ipHdr.dataSrcIPMask= ) < 0) - goto cleanup; + return -1; virFirewallRuleAddArgFormat(fw, fwrule, "%s/%s", ipaddr, number); } else { @@ -2102,7 +2101,7 @@ ebtablesCreateRuleInstance(virFirewallPtr fw, if (printDataType(vars, ipaddr, sizeof(ipaddr), &rule->p.ipHdrFilter.ipHdr.dataDstIPAddr) < = 0) - goto cleanup; + return -1; =20 virFirewallRuleAddArg(fw, fwrule, reverse ? "--ip-source" : "--ip-destinat= ion"); @@ -2113,7 +2112,7 @@ ebtablesCreateRuleInstance(virFirewallPtr fw, if (printDataType(vars, number, sizeof(number), &rule->p.ipHdrFilter.ipHdr.dataDstIPMask= ) < 0) - goto cleanup; + return -1; virFirewallRuleAddArgFormat(fw, fwrule, "%s/%s", ipaddr, number); } else { @@ -2125,7 +2124,7 @@ ebtablesCreateRuleInstance(virFirewallPtr fw, if (printDataType(vars, number, sizeof(number), &rule->p.ipHdrFilter.ipHdr.dataProtocolID) <= 0) - goto cleanup; + return -1; =20 virFirewallRuleAddArg(fw, fwrule, "--ip-protocol"); if (ENTRY_WANT_NEG_SIGN(&rule->p.ipHdrFilter.ipHdr.dataProtoco= lID)) @@ -2137,7 +2136,7 @@ ebtablesCreateRuleInstance(virFirewallPtr fw, if (printDataType(vars, number, sizeof(number), &rule->p.ipHdrFilter.portData.dataSrcPortSta= rt) < 0) - goto cleanup; + return -1; =20 virFirewallRuleAddArg(fw, fwrule, reverse ? "--ip-destination-port" : "--i= p-source-port"); @@ -2148,7 +2147,7 @@ ebtablesCreateRuleInstance(virFirewallPtr fw, if (printDataType(vars, numberalt, sizeof(numberalt), &rule->p.ipHdrFilter.portData.dataSrcPor= tEnd) < 0) - goto cleanup; + return -1; =20 virFirewallRuleAddArgFormat(fw, fwrule, "%s:%s", number, numberalt); @@ -2161,7 +2160,7 @@ ebtablesCreateRuleInstance(virFirewallPtr fw, if (printDataType(vars, number, sizeof(number), &rule->p.ipHdrFilter.portData.dataDstPortSta= rt) < 0) - goto cleanup; + return -1; =20 virFirewallRuleAddArg(fw, fwrule, reverse ? "--ip-source-port" : "--ip-des= tination-port"); @@ -2172,7 +2171,7 @@ ebtablesCreateRuleInstance(virFirewallPtr fw, if (printDataType(vars, numberalt, sizeof(numberalt), &rule->p.ipHdrFilter.portData.dataDstPor= tEnd) < 0) - goto cleanup; + return -1; =20 virFirewallRuleAddArgFormat(fw, fwrule, "%s:%s", number, numberalt); @@ -2185,7 +2184,7 @@ ebtablesCreateRuleInstance(virFirewallPtr fw, if (printDataTypeAsHex(vars, number, sizeof(number), &rule->p.ipHdrFilter.ipHdr.dataDSCP) < = 0) - goto cleanup; + return -1; =20 virFirewallRuleAddArg(fw, fwrule, "--ip-tos"); if (ENTRY_WANT_NEG_SIGN(&rule->p.ipHdrFilter.ipHdr.dataDSCP)) @@ -2202,7 +2201,7 @@ ebtablesCreateRuleInstance(virFirewallPtr fw, vars, &rule->p.ipv6HdrFilter.ethHdr, reverse) < 0) - goto cleanup; + return -1; =20 virFirewallRuleAddArgList(fw, fwrule, "-p", "ipv6", NULL); @@ -2211,7 +2210,7 @@ ebtablesCreateRuleInstance(virFirewallPtr fw, if (printDataType(vars, ipv6addr, sizeof(ipv6addr), &rule->p.ipv6HdrFilter.ipHdr.dataSrcIPAddr) = < 0) - goto cleanup; + return -1; =20 virFirewallRuleAddArg(fw, fwrule, reverse ? "--ip6-destination" : "--ip6-s= ource"); @@ -2222,7 +2221,7 @@ ebtablesCreateRuleInstance(virFirewallPtr fw, if (printDataType(vars, number, sizeof(number), &rule->p.ipv6HdrFilter.ipHdr.dataSrcIPMa= sk) < 0) - goto cleanup; + return -1; virFirewallRuleAddArgFormat(fw, fwrule, "%s/%s", ipv6addr, number); } else { @@ -2235,7 +2234,7 @@ ebtablesCreateRuleInstance(virFirewallPtr fw, if (printDataType(vars, ipv6addr, sizeof(ipv6addr), &rule->p.ipv6HdrFilter.ipHdr.dataDstIPAddr) = < 0) - goto cleanup; + return -1; =20 virFirewallRuleAddArg(fw, fwrule, reverse ? "--ip6-source" : "--ip6-destin= ation"); @@ -2246,7 +2245,7 @@ ebtablesCreateRuleInstance(virFirewallPtr fw, if (printDataType(vars, number, sizeof(number), &rule->p.ipv6HdrFilter.ipHdr.dataDstIPMa= sk) < 0) - goto cleanup; + return -1; virFirewallRuleAddArgFormat(fw, fwrule, "%s/%s", ipv6addr, number); } else { @@ -2258,7 +2257,7 @@ ebtablesCreateRuleInstance(virFirewallPtr fw, if (printDataType(vars, number, sizeof(number), &rule->p.ipv6HdrFilter.ipHdr.dataProtocolID)= < 0) - goto cleanup; + return -1; =20 virFirewallRuleAddArg(fw, fwrule, "--ip6-protocol"); if (ENTRY_WANT_NEG_SIGN(&rule->p.ipv6HdrFilter.ipHdr.dataProto= colID)) @@ -2271,7 +2270,7 @@ ebtablesCreateRuleInstance(virFirewallPtr fw, if (printDataType(vars, number, sizeof(number), &rule->p.ipv6HdrFilter.portData.dataSrcPortS= tart) < 0) - goto cleanup; + return -1; =20 virFirewallRuleAddArg(fw, fwrule, reverse ? "--ip6-destination-port" : "--= ip6-source-port"); @@ -2282,7 +2281,7 @@ ebtablesCreateRuleInstance(virFirewallPtr fw, if (printDataType(vars, numberalt, sizeof(numberalt), &rule->p.ipv6HdrFilter.portData.dataSrcP= ortEnd) < 0) - goto cleanup; + return -1; =20 virFirewallRuleAddArgFormat(fw, fwrule, "%s:%s", number, numberalt); @@ -2296,7 +2295,7 @@ ebtablesCreateRuleInstance(virFirewallPtr fw, if (printDataType(vars, number, sizeof(number), &rule->p.ipv6HdrFilter.portData.dataDstPortS= tart) < 0) - goto cleanup; + return -1; =20 virFirewallRuleAddArg(fw, fwrule, reverse ? "--ip6-source-port" : "--ip6-d= estination-port"); @@ -2307,7 +2306,7 @@ ebtablesCreateRuleInstance(virFirewallPtr fw, if (printDataType(vars, numberalt, sizeof(numberalt), &rule->p.ipv6HdrFilter.portData.dataDstP= ortEnd) < 0) - goto cleanup; + return -1; =20 virFirewallRuleAddArgFormat(fw, fwrule, "%s:%s", number, numberalt); @@ -2330,7 +2329,7 @@ ebtablesCreateRuleInstance(virFirewallPtr fw, if (printDataType(vars, number, sizeof(number), &rule->p.ipv6HdrFilter.dataICMPTypeStart= ) < 0) - goto cleanup; + return -1; lo =3D true; } else { ignore_value(virStrcpyStatic(number, "0")); @@ -2342,7 +2341,7 @@ ebtablesCreateRuleInstance(virFirewallPtr fw, if (printDataType(vars, numberalt, sizeof(numberalt), &rule->p.ipv6HdrFilter.dataICMPTypeEnd) = < 0) - goto cleanup; + return -1; } else { if (lo) ignore_value(virStrcpyStatic(numberalt, number)); @@ -2358,7 +2357,7 @@ ebtablesCreateRuleInstance(virFirewallPtr fw, if (printDataType(vars, number, sizeof(number), &rule->p.ipv6HdrFilter.dataICMPCodeStart= ) < 0) - goto cleanup; + return -1; lo =3D true; } else { ignore_value(virStrcpyStatic(number, "0")); @@ -2370,7 +2369,7 @@ ebtablesCreateRuleInstance(virFirewallPtr fw, if (printDataType(vars, numberalt, sizeof(numberalt), &rule->p.ipv6HdrFilter.dataICMPCodeEnd) = < 0) - goto cleanup; + return -1; } else { if (lo) ignore_value(virStrcpyStatic(numberalt, number)); @@ -2421,9 +2420,7 @@ ebtablesCreateRuleInstance(virFirewallPtr fw, #undef INST_ITEM_2PARMS #undef INST_ITEM =20 - ret =3D 0; - cleanup: - return ret; + return 0; } =20 =20 --=20 2.25.4 From nobody Mon May 6 01:10:47 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 207.211.31.120 as permitted sender) client-ip=207.211.31.120; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.120 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=1594006986; cv=none; d=zohomail.com; s=zohoarc; b=m3kh6wGG8S4u7XR5yWBAaKHLZMInDmp4Zb03k7LkLLf15f0jwXOduI6iPYT2HwtccVQEEltdfNThXkkJbjohqCzH+CplDGz7EusLT8UT7HfVC32XIj/+Bp7Z5IPqqu1Je2cBF2/98IZvgwITJ6J3NaZCRH+CSNqpQRDWehzX870= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1594006986; 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=F6KDoHzsLmIUy3zfLunzxoLzdXIygNluLP5P0y6rCaw=; b=SIiSc21watBvZdB0CQnXtWsOWhTJK2P1lz84sWPXp7gE2DRC2Ozci2CvDbLzaLJU8LEAT8cTUMGsDV81BiAVTz6co3shGU+B+cPr3UvdToNm5s3Hl2IKU1QReU2fOdwE3TAL0JhvzmjFrUZUUkIKFeUQ9DgZR5Xnc0nRCFu1qiw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.120 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-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) by mx.zohomail.com with SMTPS id 1594006986941741.0828507081264; Sun, 5 Jul 2020 20:43:06 -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-488-gndrOqI1N6auUFVjWapH9Q-1; Sun, 05 Jul 2020 23:42:31 -0400 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 9D326107ACF2; Mon, 6 Jul 2020 03:42:26 +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 810C36E6E4; Mon, 6 Jul 2020 03:42:26 +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 533F193F8C; Mon, 6 Jul 2020 03:42:26 +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 0663gMV7004848 for ; Sun, 5 Jul 2020 23:42:22 -0400 Received: by smtp.corp.redhat.com (Postfix) id 886C371678; Mon, 6 Jul 2020 03:42:22 +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 3C53A285854 for ; Mon, 6 Jul 2020 03:42:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1594006985; 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=F6KDoHzsLmIUy3zfLunzxoLzdXIygNluLP5P0y6rCaw=; b=NyV+up1i8Wq/SXp77YSOhjiUGNcseceA8urkSb04zTqp0SVMD0Rd9qQisPow/HIfYMkon/ KyHaRd1YaVEA8oQ8xEynxMUXGPVOWpESQ6+Zs0QZJvIUWU9dgsHd9UDaHzLsg6dky4ibpB GQNuNS3JBd3/aFoIVbPxqxjSkrSr3Ek= X-MC-Unique: gndrOqI1N6auUFVjWapH9Q-1 From: Laine Stump To: libvir-list@redhat.com Subject: [PATCH 30/32] storage: eliminate unnecessary labels Date: Sun, 5 Jul 2020 23:41:25 -0400 Message-Id: <20200706034127.1117504-31-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.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-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/storage/storage_util.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/storage/storage_util.c b/src/storage/storage_util.c index 36b5b21a5b..9f46ea764b 100644 --- a/src/storage/storage_util.c +++ b/src/storage/storage_util.c @@ -749,7 +749,7 @@ storageBackendCreateQemuImgOpts(virStorageEncryptionInf= oDefPtr encinfo, _("lazy_refcounts not supported with compat" " level %s"), info->compat); - goto error; + return -1; } virBufferAddLit(&buf, "lazy_refcounts,"); } @@ -759,9 +759,6 @@ storageBackendCreateQemuImgOpts(virStorageEncryptionInf= oDefPtr encinfo, =20 *opts =3D virBufferContentAndReset(&buf); return 0; - - error: - return -1; } =20 =20 --=20 2.25.4 From nobody Mon May 6 01:10:47 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 207.211.31.120 as permitted sender) client-ip=207.211.31.120; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.120 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=1594007176; cv=none; d=zohomail.com; s=zohoarc; b=XgxcArsEpQNqHVH1Ah3zZrPUzr9wpjG+u22QCtcLYajVpiV3wK4s64uOBrQ3jseRaLtnqodok+A8KFwq8vjAaD3/1AmIfI56ceNswx466Gggu6GaiV50v58Dpr7PhT6f9jCdl5JprT3RAhafmh4FOZoxD16TmkLMS7JIT3ey9sI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1594007176; 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=iFthZFjFD876G+ZYuN55NBpH4EdzFO0RTGHs4QIyRlQ=; b=D1+I567P1FglsNeul+GL5DRAJmV1e2bIswuJNxYrhRfAKZLfot4/342NeNM3x41zVaf34HdlTDe5UO40s6lHQE6BYILpPhoRb8s2l/gaaKfJOZHVSJoMb4cSuTT7SzZXNjdZmq2j+hFell0vq+xLUoDnb5mIRJ/XGj3hiDfSH60= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.120 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-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) by mx.zohomail.com with SMTPS id 1594007176770140.17198558299162; Sun, 5 Jul 2020 20:46:16 -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-302-L0cqjva9NR-lbUITP-BfMg-1; Sun, 05 Jul 2020 23:42:42 -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 E43B718FE87A; Mon, 6 Jul 2020 03:42:36 +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 BDEA661788; Mon, 6 Jul 2020 03:42:36 +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 8D2951804766; Mon, 6 Jul 2020 03:42:36 +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 0663gNrP004854 for ; Sun, 5 Jul 2020 23:42:23 -0400 Received: by smtp.corp.redhat.com (Postfix) id 1224F7AC9F; Mon, 6 Jul 2020 03:42:23 +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 B80B971678 for ; Mon, 6 Jul 2020 03:42:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1594007175; 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=iFthZFjFD876G+ZYuN55NBpH4EdzFO0RTGHs4QIyRlQ=; b=SUI8tXTrAjKN/k33jn8Z5Xp5XnG9TqcgxB0wZ2pM6U994qVqfbZD6J4GVCmkiM0Qt/wsjE 1Tc9rd7R5f4NHBLrN2H37BEG5fbPnAmBpSxMqJG9fa97pQC78piFCYteJ7WeF1obZxRU3V WRrFH3/0S+/2/vKITsfNrTJQ5Xiy6p0= X-MC-Unique: L0cqjva9NR-lbUITP-BfMg-1 From: Laine Stump To: libvir-list@redhat.com Subject: [PATCH 31/32] use g_autoptr() for all usages of virFirewallNew/Free Date: Sun, 5 Jul 2020 23:41:26 -0400 Message-Id: <20200706034127.1117504-32-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.79 on 10.5.11.16 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/network/bridge_driver_linux.c | 11 ++--- src/nwfilter/nwfilter_ebiptables_driver.c | 31 ++++---------- src/util/virebtables.c | 8 +--- src/util/viriptables.c | 6 +-- tests/virfirewalltest.c | 50 +++++------------------ 5 files changed, 25 insertions(+), 81 deletions(-) diff --git a/src/network/bridge_driver_linux.c b/src/network/bridge_driver_= linux.c index 30f6aa8fe1..f72f94f38d 100644 --- a/src/network/bridge_driver_linux.c +++ b/src/network/bridge_driver_linux.c @@ -838,7 +838,7 @@ int networkAddFirewallRules(virNetworkDefPtr def) { size_t i; virNetworkIPDefPtr ipdef; - virFirewallPtr fw =3D NULL; + g_autoptr(virFirewall) fw =3D virFirewallNew(); int ret =3D -1; =20 if (virOnce(&createdOnce, networkSetupPrivateChains) < 0) @@ -925,8 +925,6 @@ int networkAddFirewallRules(virNetworkDefPtr def) } } =20 - fw =3D virFirewallNew(); - virFirewallStartTransaction(fw, 0); =20 networkAddGeneralFirewallRules(fw, def); @@ -956,7 +954,6 @@ int networkAddFirewallRules(virNetworkDefPtr def) =20 ret =3D 0; cleanup: - virFirewallFree(fw); return ret; } =20 @@ -965,9 +962,7 @@ void networkRemoveFirewallRules(virNetworkDefPtr def) { size_t i; virNetworkIPDefPtr ipdef; - virFirewallPtr fw =3D NULL; - - fw =3D virFirewallNew(); + g_autoptr(virFirewall) fw =3D virFirewallNew(); =20 virFirewallStartTransaction(fw, VIR_FIREWALL_TRANSACTION_IGNORE_ERRORS= ); networkRemoveChecksumFirewallRules(fw, def); @@ -985,5 +980,5 @@ void networkRemoveFirewallRules(virNetworkDefPtr def) virFirewallApply(fw); =20 cleanup: - virFirewallFree(fw); + return; } diff --git a/src/nwfilter/nwfilter_ebiptables_driver.c b/src/nwfilter/nwfil= ter_ebiptables_driver.c index 6cdb3ca45e..2976521e6d 100644 --- a/src/nwfilter/nwfilter_ebiptables_driver.c +++ b/src/nwfilter/nwfilter_ebiptables_driver.c @@ -2858,7 +2858,7 @@ static int ebtablesApplyBasicRules(const char *ifname, const virMacAddr *macaddr) { - virFirewallPtr fw =3D virFirewallNew(); + g_autoptr(virFirewall) fw =3D virFirewallNew(); char chain[MAX_CHAINNAME_LENGTH]; char chainPrefix =3D CHAINPREFIX_HOST_IN_TEMP; char macaddr_str[VIR_MAC_STRING_BUFLEN]; @@ -2895,13 +2895,11 @@ ebtablesApplyBasicRules(const char *ifname, if (virFirewallApply(fw) < 0) goto tear_down_tmpebchains; =20 - virFirewallFree(fw); return 0; =20 tear_down_tmpebchains: ebtablesCleanAll(ifname); error: - virFirewallFree(fw); return -1; } =20 @@ -2934,7 +2932,7 @@ ebtablesApplyDHCPOnlyRules(const char *ifname, char macaddr_str[VIR_MAC_STRING_BUFLEN]; unsigned int idx =3D 0; unsigned int num_dhcpsrvrs; - virFirewallPtr fw =3D virFirewallNew(); + g_autoptr(virFirewall) fw =3D virFirewallNew(); =20 virMacAddrFormat(macaddr, macaddr_str); =20 @@ -3014,14 +3012,11 @@ ebtablesApplyDHCPOnlyRules(const char *ifname, if (virFirewallApply(fw) < 0) goto tear_down_tmpebchains; =20 - virFirewallFree(fw); - return 0; =20 tear_down_tmpebchains: ebtablesCleanAll(ifname); error: - virFirewallFree(fw); return -1; } =20 @@ -3040,7 +3035,7 @@ ebtablesApplyDropAllRules(const char *ifname) { char chain_in [MAX_CHAINNAME_LENGTH], chain_out[MAX_CHAINNAME_LENGTH]; - virFirewallPtr fw =3D virFirewallNew(); + g_autoptr(virFirewall) fw =3D virFirewallNew(); =20 if (ebiptablesAllTeardown(ifname) < 0) goto error; @@ -3069,13 +3064,11 @@ ebtablesApplyDropAllRules(const char *ifname) if (virFirewallApply(fw) < 0) goto tear_down_tmpebchains; =20 - virFirewallFree(fw); return 0; =20 tear_down_tmpebchains: ebtablesCleanAll(ifname); error: - virFirewallFree(fw); return -1; } =20 @@ -3090,7 +3083,7 @@ ebtablesRemoveBasicRules(const char *ifname) static int ebtablesCleanAll(const char *ifname) { - virFirewallPtr fw =3D virFirewallNew(); + g_autoptr(virFirewall) fw =3D virFirewallNew(); int ret =3D -1; =20 virFirewallStartTransaction(fw, VIR_FIREWALL_TRANSACTION_IGNORE_ERRORS= ); @@ -3108,7 +3101,6 @@ ebtablesCleanAll(const char *ifname) ebtablesRemoveTmpRootChainFW(fw, false, ifname); =20 ret =3D virFirewallApply(fw); - virFirewallFree(fw); return ret; } =20 @@ -3357,7 +3349,7 @@ ebiptablesApplyNewRules(const char *ifname, size_t nrules) { size_t i, j; - virFirewallPtr fw =3D virFirewallNew(); + g_autoptr(virFirewall) fw =3D virFirewallNew(); virHashTablePtr chains_in_set =3D virHashCreate(10, NULL); virHashTablePtr chains_out_set =3D virHashCreate(10, NULL); bool haveEbtables =3D false; @@ -3558,7 +3550,6 @@ ebiptablesApplyNewRules(const char *ifname, for (i =3D 0; i < nsubchains; i++) VIR_FREE(subchains[i]); VIR_FREE(subchains); - virFirewallFree(fw); virHashFree(chains_in_set); virHashFree(chains_out_set); =20 @@ -3586,7 +3577,7 @@ ebiptablesTearNewRulesFW(virFirewallPtr fw, const cha= r *ifname) static int ebiptablesTearNewRules(const char *ifname) { - virFirewallPtr fw =3D virFirewallNew(); + g_autoptr(virFirewall) fw =3D virFirewallNew(); int ret =3D -1; =20 virFirewallStartTransaction(fw, VIR_FIREWALL_TRANSACTION_IGNORE_ERRORS= ); @@ -3594,14 +3585,13 @@ ebiptablesTearNewRules(const char *ifname) ebiptablesTearNewRulesFW(fw, ifname); =20 ret =3D virFirewallApply(fw); - virFirewallFree(fw); return ret; } =20 static int ebiptablesTearOldRules(const char *ifname) { - virFirewallPtr fw =3D virFirewallNew(); + g_autoptr(virFirewall) fw =3D virFirewallNew(); int ret =3D -1; =20 virFirewallStartTransaction(fw, VIR_FIREWALL_TRANSACTION_IGNORE_ERRORS= ); @@ -3622,7 +3612,6 @@ ebiptablesTearOldRules(const char *ifname) ebtablesRenameTmpSubAndRootChainsFW(fw, ifname); =20 ret =3D virFirewallApply(fw); - virFirewallFree(fw); return ret; } =20 @@ -3639,7 +3628,7 @@ ebiptablesTearOldRules(const char *ifname) static int ebiptablesAllTeardown(const char *ifname) { - virFirewallPtr fw =3D virFirewallNew(); + g_autoptr(virFirewall) fw =3D virFirewallNew(); int ret =3D -1; =20 virFirewallStartTransaction(fw, VIR_FIREWALL_TRANSACTION_IGNORE_ERRORS= ); @@ -3663,7 +3652,6 @@ ebiptablesAllTeardown(const char *ifname) ebtablesRemoveRootChainFW(fw, false, ifname); =20 ret =3D virFirewallApply(fw); - virFirewallFree(fw); return ret; } =20 @@ -3749,7 +3737,7 @@ static int ebiptablesDriverProbeStateMatch(void) { unsigned long version; - virFirewallPtr fw =3D virFirewallNew(); + g_autoptr(virFirewall) fw =3D virFirewallNew(); int ret =3D -1; =20 virFirewallStartTransaction(fw, 0); @@ -3769,7 +3757,6 @@ ebiptablesDriverProbeStateMatch(void) =20 ret =3D 0; cleanup: - virFirewallFree(fw); return ret; } =20 diff --git a/src/util/virebtables.c b/src/util/virebtables.c index 14a922834a..69483f35ec 100644 --- a/src/util/virebtables.c +++ b/src/util/virebtables.c @@ -82,10 +82,9 @@ ebtablesContextFree(ebtablesContext *ctx) int ebtablesAddForwardPolicyReject(ebtablesContext *ctx) { - virFirewallPtr fw =3D NULL; + g_autoptr(virFirewall) fw =3D virFirewallNew(); int ret =3D -1; =20 - fw =3D virFirewallNew(); virFirewallStartTransaction(fw, VIR_FIREWALL_TRANSACTION_IGNORE_ERRORS= ); virFirewallAddRule(fw, VIR_FIREWALL_LAYER_ETHERNET, "--new-chain", ctx->chain, @@ -104,7 +103,6 @@ ebtablesAddForwardPolicyReject(ebtablesContext *ctx) =20 ret =3D 0; cleanup: - virFirewallFree(fw); return ret; } =20 @@ -118,10 +116,9 @@ ebtablesForwardAllowIn(ebtablesContext *ctx, const char *macaddr, int action) { - virFirewallPtr fw =3D NULL; + g_autoptr(virFirewall) fw =3D virFirewallNew(); int ret =3D -1; =20 - fw =3D virFirewallNew(); virFirewallStartTransaction(fw, 0); virFirewallAddRule(fw, VIR_FIREWALL_LAYER_ETHERNET, action =3D=3D ADD ? "--insert" : "--delete", @@ -136,7 +133,6 @@ ebtablesForwardAllowIn(ebtablesContext *ctx, =20 ret =3D 0; cleanup: - virFirewallFree(fw); return ret; } =20 diff --git a/src/util/viriptables.c b/src/util/viriptables.c index 8ccce835b2..b1ef3a2db6 100644 --- a/src/util/viriptables.c +++ b/src/util/viriptables.c @@ -128,7 +128,7 @@ iptablesPrivateChainCreate(virFirewallPtr fw, int iptablesSetupPrivateChains(virFirewallLayer layer) { - virFirewallPtr fw =3D NULL; + g_autoptr(virFirewall) fw =3D virFirewallNew(); int ret =3D -1; iptablesGlobalChain filter_chains[] =3D { {"INPUT", "LIBVIRT_INP"}, @@ -151,8 +151,6 @@ iptablesSetupPrivateChains(virFirewallLayer layer) }; size_t i; =20 - fw =3D virFirewallNew(); - virFirewallStartTransaction(fw, 0); =20 for (i =3D 0; i < G_N_ELEMENTS(data); i++) @@ -167,8 +165,6 @@ iptablesSetupPrivateChains(virFirewallLayer layer) ret =3D changed ? 1 : 0; =20 cleanup: - - virFirewallFree(fw); return ret; } =20 diff --git a/tests/virfirewalltest.c b/tests/virfirewalltest.c index 4105c1867e..ce252bd0e0 100644 --- a/tests/virfirewalltest.c +++ b/tests/virfirewalltest.c @@ -200,7 +200,7 @@ static int testFirewallSingleGroup(const void *opaque) { g_auto(virBuffer) cmdbuf =3D VIR_BUFFER_INITIALIZER; - virFirewallPtr fw =3D NULL; + g_autoptr(virFirewall) fw =3D virFirewallNew(); int ret =3D -1; const char *actual =3D NULL; const char *expected =3D @@ -217,8 +217,6 @@ testFirewallSingleGroup(const void *opaque) else fwBuf =3D &cmdbuf; =20 - fw =3D virFirewallNew(); - virFirewallStartTransaction(fw, 0); =20 virFirewallAddRule(fw, VIR_FIREWALL_LAYER_IPV4, @@ -246,7 +244,6 @@ testFirewallSingleGroup(const void *opaque) cleanup: fwBuf =3D NULL; virCommandSetDryRun(NULL, NULL, NULL); - virFirewallFree(fw); return ret; } =20 @@ -255,7 +252,7 @@ static int testFirewallRemoveRule(const void *opaque) { g_auto(virBuffer) cmdbuf =3D VIR_BUFFER_INITIALIZER; - virFirewallPtr fw =3D NULL; + g_autoptr(virFirewall) fw =3D virFirewallNew(); int ret =3D -1; const char *actual =3D NULL; const char *expected =3D @@ -273,8 +270,6 @@ testFirewallRemoveRule(const void *opaque) else fwBuf =3D &cmdbuf; =20 - fw =3D virFirewallNew(); - virFirewallStartTransaction(fw, 0); =20 virFirewallAddRule(fw, VIR_FIREWALL_LAYER_IPV4, @@ -308,7 +303,6 @@ testFirewallRemoveRule(const void *opaque) cleanup: fwBuf =3D NULL; virCommandSetDryRun(NULL, NULL, NULL); - virFirewallFree(fw); return ret; } =20 @@ -317,7 +311,7 @@ static int testFirewallManyGroups(const void *opaque G_GNUC_UNUSED) { g_auto(virBuffer) cmdbuf =3D VIR_BUFFER_INITIALIZER; - virFirewallPtr fw =3D NULL; + g_autoptr(virFirewall) fw =3D virFirewallNew(); int ret =3D -1; const char *actual =3D NULL; const char *expected =3D @@ -336,8 +330,6 @@ testFirewallManyGroups(const void *opaque G_GNUC_UNUSED) else fwBuf =3D &cmdbuf; =20 - fw =3D virFirewallNew(); - virFirewallStartTransaction(fw, 0); =20 virFirewallAddRule(fw, VIR_FIREWALL_LAYER_IPV4, @@ -377,7 +369,6 @@ testFirewallManyGroups(const void *opaque G_GNUC_UNUSED) cleanup: fwBuf =3D NULL; virCommandSetDryRun(NULL, NULL, NULL); - virFirewallFree(fw); return ret; } =20 @@ -407,7 +398,7 @@ static int testFirewallIgnoreFailGroup(const void *opaque G_GNUC_UNUSED) { g_auto(virBuffer) cmdbuf =3D VIR_BUFFER_INITIALIZER; - virFirewallPtr fw =3D NULL; + g_autoptr(virFirewall) fw =3D virFirewallNew(); int ret =3D -1; const char *actual =3D NULL; const char *expected =3D @@ -428,8 +419,6 @@ testFirewallIgnoreFailGroup(const void *opaque G_GNUC_U= NUSED) fwError =3D true; } =20 - fw =3D virFirewallNew(); - virFirewallStartTransaction(fw, VIR_FIREWALL_TRANSACTION_IGNORE_ERRORS= ); =20 virFirewallAddRule(fw, VIR_FIREWALL_LAYER_IPV4, @@ -469,7 +458,6 @@ testFirewallIgnoreFailGroup(const void *opaque G_GNUC_U= NUSED) cleanup: fwBuf =3D NULL; virCommandSetDryRun(NULL, NULL, NULL); - virFirewallFree(fw); return ret; } =20 @@ -478,7 +466,7 @@ static int testFirewallIgnoreFailRule(const void *opaque G_GNUC_UNUSED) { g_auto(virBuffer) cmdbuf =3D VIR_BUFFER_INITIALIZER; - virFirewallPtr fw =3D NULL; + g_autoptr(virFirewall) fw =3D virFirewallNew(); int ret =3D -1; const char *actual =3D NULL; const char *expected =3D @@ -499,8 +487,6 @@ testFirewallIgnoreFailRule(const void *opaque G_GNUC_UN= USED) fwError =3D true; } =20 - fw =3D virFirewallNew(); - virFirewallStartTransaction(fw, 0); =20 virFirewallAddRule(fw, VIR_FIREWALL_LAYER_IPV4, @@ -539,7 +525,6 @@ testFirewallIgnoreFailRule(const void *opaque G_GNUC_UN= USED) cleanup: fwBuf =3D NULL; virCommandSetDryRun(NULL, NULL, NULL); - virFirewallFree(fw); return ret; } =20 @@ -548,7 +533,7 @@ static int testFirewallNoRollback(const void *opaque G_GNUC_UNUSED) { g_auto(virBuffer) cmdbuf =3D VIR_BUFFER_INITIALIZER; - virFirewallPtr fw =3D NULL; + g_autoptr(virFirewall) fw =3D virFirewallNew(); int ret =3D -1; const char *actual =3D NULL; const char *expected =3D @@ -567,8 +552,6 @@ testFirewallNoRollback(const void *opaque G_GNUC_UNUSED) fwError =3D true; } =20 - fw =3D virFirewallNew(); - virFirewallStartTransaction(fw, 0); =20 virFirewallAddRule(fw, VIR_FIREWALL_LAYER_IPV4, @@ -603,7 +586,6 @@ testFirewallNoRollback(const void *opaque G_GNUC_UNUSED) cleanup: fwBuf =3D NULL; virCommandSetDryRun(NULL, NULL, NULL); - virFirewallFree(fw); return ret; } =20 @@ -611,7 +593,7 @@ static int testFirewallSingleRollback(const void *opaque G_GNUC_UNUSED) { g_auto(virBuffer) cmdbuf =3D VIR_BUFFER_INITIALIZER; - virFirewallPtr fw =3D NULL; + g_autoptr(virFirewall) fw =3D virFirewallNew(); int ret =3D -1; const char *actual =3D NULL; const char *expected =3D @@ -633,8 +615,6 @@ testFirewallSingleRollback(const void *opaque G_GNUC_UN= USED) fwBuf =3D &cmdbuf; } =20 - fw =3D virFirewallNew(); - virFirewallStartTransaction(fw, 0); =20 virFirewallAddRule(fw, VIR_FIREWALL_LAYER_IPV4, @@ -686,7 +666,6 @@ testFirewallSingleRollback(const void *opaque G_GNUC_UN= USED) cleanup: fwBuf =3D NULL; virCommandSetDryRun(NULL, NULL, NULL); - virFirewallFree(fw); return ret; } =20 @@ -694,7 +673,7 @@ static int testFirewallManyRollback(const void *opaque G_GNUC_UNUSED) { g_auto(virBuffer) cmdbuf =3D VIR_BUFFER_INITIALIZER; - virFirewallPtr fw =3D NULL; + g_autoptr(virFirewall) fw =3D virFirewallNew(); int ret =3D -1; const char *actual =3D NULL; const char *expected =3D @@ -715,8 +694,6 @@ testFirewallManyRollback(const void *opaque G_GNUC_UNUS= ED) fwError =3D true; } =20 - fw =3D virFirewallNew(); - virFirewallStartTransaction(fw, 0); =20 virFirewallAddRule(fw, VIR_FIREWALL_LAYER_IPV4, @@ -772,7 +749,6 @@ testFirewallManyRollback(const void *opaque G_GNUC_UNUS= ED) cleanup: fwBuf =3D NULL; virCommandSetDryRun(NULL, NULL, NULL); - virFirewallFree(fw); return ret; } =20 @@ -780,7 +756,7 @@ static int testFirewallChainedRollback(const void *opaque G_GNUC_UNUSED) { g_auto(virBuffer) cmdbuf =3D VIR_BUFFER_INITIALIZER; - virFirewallPtr fw =3D NULL; + g_autoptr(virFirewall) fw =3D virFirewallNew(); int ret =3D -1; const char *actual =3D NULL; const char *expected =3D @@ -805,8 +781,6 @@ testFirewallChainedRollback(const void *opaque G_GNUC_U= NUSED) fwError =3D true; } =20 - fw =3D virFirewallNew(); - virFirewallStartTransaction(fw, 0); =20 virFirewallAddRule(fw, VIR_FIREWALL_LAYER_IPV4, @@ -888,7 +862,6 @@ testFirewallChainedRollback(const void *opaque G_GNUC_U= NUSED) cleanup: fwBuf =3D NULL; virCommandSetDryRun(NULL, NULL, NULL); - virFirewallFree(fw); return ret; } =20 @@ -973,7 +946,7 @@ static int testFirewallQuery(const void *opaque G_GNUC_UNUSED) { g_auto(virBuffer) cmdbuf =3D VIR_BUFFER_INITIALIZER; - virFirewallPtr fw =3D NULL; + g_autoptr(virFirewall) fw =3D virFirewallNew(); int ret =3D -1; const char *actual =3D NULL; const char *expected =3D @@ -1001,8 +974,6 @@ testFirewallQuery(const void *opaque G_GNUC_UNUSED) fwError =3D true; } =20 - fw =3D virFirewallNew(); - virFirewallStartTransaction(fw, 0); =20 virFirewallAddRule(fw, VIR_FIREWALL_LAYER_IPV4, @@ -1066,7 +1037,6 @@ testFirewallQuery(const void *opaque G_GNUC_UNUSED) cleanup: fwBuf =3D NULL; virCommandSetDryRun(NULL, NULL, NULL); - virFirewallFree(fw); return ret; } =20 --=20 2.25.4 From nobody Mon May 6 01:10:47 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 205.139.110.61 as permitted sender) client-ip=205.139.110.61; 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 205.139.110.61 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=1594006967; cv=none; d=zohomail.com; s=zohoarc; b=JYD4qA8H+WhVUzMwmNrMv3TUR5gdxVL0X7o7NbQntwa/OcRGAJ2pvKBJG1KnM+XoAG+YBBtu6Lqsr1ORl8Joz0f3acQW3W6HzqhaumfT4fcasN9rgpojZvM1ar66YofvV0QX5qwjWcN7IcfKZu48s9qD3AM7OvBBSSyyZIgtB9s= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1594006967; 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=S+qa3TFsuPWNq0eEicwzQzgTVjbyaidy3TS02ZUIdP4=; b=fUY2rdrVhMThBKrYsMZMdie0OfQLT/fLuw6gZ2XYdpETbtMkwKcQ36tq4XeUJ4TNfAdson35/jYWksP61xydUCbB2t5ucoAQ4TXh36q+o9PgWgoy2BiiinP4VThHP7bf3mLekJZoEGAHkM7v7C/5w+VX3A8b/7YAcXfm9tVFrrM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.61 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 [205.139.110.61]) by mx.zohomail.com with SMTPS id 1594006967921936.4532194736041; Sun, 5 Jul 2020 20:42:47 -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-214-y4OUTr5rMoOjlsiGQBJm7g-1; Sun, 05 Jul 2020 23:42:44 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 22A5318FE867; Mon, 6 Jul 2020 03:42:39 +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 042F771678; Mon, 6 Jul 2020 03:42: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 C9C0B18005C5; Mon, 6 Jul 2020 03:42:38 +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 0663gN7T004862 for ; Sun, 5 Jul 2020 23:42:23 -0400 Received: by smtp.corp.redhat.com (Postfix) id 8D1B571678; Mon, 6 Jul 2020 03:42:23 +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 4336F275E25 for ; Mon, 6 Jul 2020 03:42:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1594006966; 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=S+qa3TFsuPWNq0eEicwzQzgTVjbyaidy3TS02ZUIdP4=; b=HOdzaQu8bY1CpBPkPC5as5P0vhkteajzEJCErVBOcswzQeD0FCH0RMJ87oPx6uhhcpH9RO YgRshfC0K2oidv+oGQRwvyE3clo1+SP5DY0m1v/V76denkpH4TlBoVzK+3VEfEeEFzc+Zj oUMldplQaOJLTfA5KzT9778MNP75RfM= X-MC-Unique: y4OUTr5rMoOjlsiGQBJm7g-1 From: Laine Stump To: libvir-list@redhat.com Subject: [PATCH 32/32] eliminate unnecessary labels and ret variables Date: Sun, 5 Jul 2020 23:41:27 -0400 Message-Id: <20200706034127.1117504-33-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.79 on 10.5.11.11 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" after making all virFirewall objects use g_autoptr(). Signed-off-by: Laine Stump Reviewed-by: J=C3=A1n Tomko --- src/network/bridge_driver_linux.c | 27 +++++++------------ src/nwfilter/nwfilter_ebiptables_driver.c | 32 +++++++---------------- src/util/virebtables.c | 16 ++---------- src/util/viriptables.c | 8 ++---- 4 files changed, 22 insertions(+), 61 deletions(-) diff --git a/src/network/bridge_driver_linux.c b/src/network/bridge_driver_= linux.c index f72f94f38d..5fc77785dc 100644 --- a/src/network/bridge_driver_linux.c +++ b/src/network/bridge_driver_linux.c @@ -839,7 +839,6 @@ int networkAddFirewallRules(virNetworkDefPtr def) size_t i; virNetworkIPDefPtr ipdef; g_autoptr(virFirewall) fw =3D virFirewallNew(); - int ret =3D -1; =20 if (virOnce(&createdOnce, networkSetupPrivateChains) < 0) return -1; @@ -869,11 +868,11 @@ int networkAddFirewallRules(virNetworkDefPtr def) _("zone %s requested for network %s " "but firewalld is not active"), def->bridgeZone, def->name); - goto cleanup; + return -1; } =20 if (virFirewallDInterfaceSetZone(def->bridge, def->bridgeZone) < 0) - goto cleanup; + return -1; =20 } else { =20 @@ -893,13 +892,13 @@ int networkAddFirewallRules(virNetworkDefPtr def) */ if (virFirewallDZoneExists("libvirt")) { if (virFirewallDInterfaceSetZone(def->bridge, "libvirt") <= 0) - goto cleanup; + return -1; } else { unsigned long version; int vresult =3D virFirewallDGetVersion(&version); =20 if (vresult < 0) - goto cleanup; + return -1; =20 /* Support for nftables backend was added in firewalld * 0.6.0. Support for rule priorities (required by the @@ -919,7 +918,7 @@ int networkAddFirewallRules(virNetworkDefPtr def) "version supporting rule priorities " "(0.7.0+) and/or rebuilding " "libvirt with --with-firewalld-zone")= ); - goto cleanup; + return -1; } } } @@ -933,7 +932,7 @@ int networkAddFirewallRules(virNetworkDefPtr def) (ipdef =3D virNetworkDefGetIPByIndex(def, AF_UNSPEC, i)); i++) { if (networkAddIPSpecificFirewallRules(fw, def, ipdef) < 0) - goto cleanup; + return -1; } =20 virFirewallStartRollback(fw, 0); @@ -942,19 +941,14 @@ int networkAddFirewallRules(virNetworkDefPtr def) (ipdef =3D virNetworkDefGetIPByIndex(def, AF_UNSPEC, i)); i++) { if (networkRemoveIPSpecificFirewallRules(fw, def, ipdef) < 0) - goto cleanup; + return -1; } networkRemoveGeneralFirewallRules(fw, def); =20 virFirewallStartTransaction(fw, VIR_FIREWALL_TRANSACTION_IGNORE_ERRORS= ); networkAddChecksumFirewallRules(fw, def); =20 - if (virFirewallApply(fw) < 0) - goto cleanup; - - ret =3D 0; - cleanup: - return ret; + return virFirewallApply(fw); } =20 /* Remove all rules for all ip addresses (and general rules) on a network = */ @@ -973,12 +967,9 @@ void networkRemoveFirewallRules(virNetworkDefPtr def) (ipdef =3D virNetworkDefGetIPByIndex(def, AF_UNSPEC, i)); i++) { if (networkRemoveIPSpecificFirewallRules(fw, def, ipdef) < 0) - goto cleanup; + return; } networkRemoveGeneralFirewallRules(fw, def); =20 virFirewallApply(fw); - - cleanup: - return; } diff --git a/src/nwfilter/nwfilter_ebiptables_driver.c b/src/nwfilter/nwfil= ter_ebiptables_driver.c index 2976521e6d..78a52408b2 100644 --- a/src/nwfilter/nwfilter_ebiptables_driver.c +++ b/src/nwfilter/nwfilter_ebiptables_driver.c @@ -2866,7 +2866,7 @@ ebtablesApplyBasicRules(const char *ifname, virMacAddrFormat(macaddr, macaddr_str); =20 if (ebiptablesAllTeardown(ifname) < 0) - goto error; + return -1; =20 virFirewallStartTransaction(fw, 0); =20 @@ -2899,7 +2899,6 @@ ebtablesApplyBasicRules(const char *ifname, =20 tear_down_tmpebchains: ebtablesCleanAll(ifname); - error: return -1; } =20 @@ -2937,7 +2936,7 @@ ebtablesApplyDHCPOnlyRules(const char *ifname, virMacAddrFormat(macaddr, macaddr_str); =20 if (ebiptablesAllTeardown(ifname) < 0) - goto error; + return -1; =20 virFirewallStartTransaction(fw, 0); =20 @@ -3016,7 +3015,6 @@ ebtablesApplyDHCPOnlyRules(const char *ifname, =20 tear_down_tmpebchains: ebtablesCleanAll(ifname); - error: return -1; } =20 @@ -3038,7 +3036,7 @@ ebtablesApplyDropAllRules(const char *ifname) g_autoptr(virFirewall) fw =3D virFirewallNew(); =20 if (ebiptablesAllTeardown(ifname) < 0) - goto error; + return -1; =20 virFirewallStartTransaction(fw, 0); =20 @@ -3068,7 +3066,6 @@ ebtablesApplyDropAllRules(const char *ifname) =20 tear_down_tmpebchains: ebtablesCleanAll(ifname); - error: return -1; } =20 @@ -3084,7 +3081,6 @@ static int ebtablesCleanAll(const char *ifname) { g_autoptr(virFirewall) fw =3D virFirewallNew(); - int ret =3D -1; =20 virFirewallStartTransaction(fw, VIR_FIREWALL_TRANSACTION_IGNORE_ERRORS= ); =20 @@ -3100,8 +3096,7 @@ ebtablesCleanAll(const char *ifname) ebtablesRemoveTmpRootChainFW(fw, true, ifname); ebtablesRemoveTmpRootChainFW(fw, false, ifname); =20 - ret =3D virFirewallApply(fw); - return ret; + return virFirewallApply(fw); } =20 =20 @@ -3578,21 +3573,18 @@ static int ebiptablesTearNewRules(const char *ifname) { g_autoptr(virFirewall) fw =3D virFirewallNew(); - int ret =3D -1; =20 virFirewallStartTransaction(fw, VIR_FIREWALL_TRANSACTION_IGNORE_ERRORS= ); =20 ebiptablesTearNewRulesFW(fw, ifname); =20 - ret =3D virFirewallApply(fw); - return ret; + return virFirewallApply(fw); } =20 static int ebiptablesTearOldRules(const char *ifname) { g_autoptr(virFirewall) fw =3D virFirewallNew(); - int ret =3D -1; =20 virFirewallStartTransaction(fw, VIR_FIREWALL_TRANSACTION_IGNORE_ERRORS= ); =20 @@ -3611,8 +3603,7 @@ ebiptablesTearOldRules(const char *ifname) ebtablesRemoveRootChainFW(fw, false, ifname); ebtablesRenameTmpSubAndRootChainsFW(fw, ifname); =20 - ret =3D virFirewallApply(fw); - return ret; + return virFirewallApply(fw); } =20 =20 @@ -3629,7 +3620,6 @@ static int ebiptablesAllTeardown(const char *ifname) { g_autoptr(virFirewall) fw =3D virFirewallNew(); - int ret =3D -1; =20 virFirewallStartTransaction(fw, VIR_FIREWALL_TRANSACTION_IGNORE_ERRORS= ); =20 @@ -3651,8 +3641,7 @@ ebiptablesAllTeardown(const char *ifname) ebtablesRemoveRootChainFW(fw, true, ifname); ebtablesRemoveRootChainFW(fw, false, ifname); =20 - ret =3D virFirewallApply(fw); - return ret; + return virFirewallApply(fw); } =20 =20 @@ -3738,7 +3727,6 @@ ebiptablesDriverProbeStateMatch(void) { unsigned long version; g_autoptr(virFirewall) fw =3D virFirewallNew(); - int ret =3D -1; =20 virFirewallStartTransaction(fw, 0); virFirewallAddRuleFull(fw, VIR_FIREWALL_LAYER_IPV4, @@ -3746,7 +3734,7 @@ ebiptablesDriverProbeStateMatch(void) "--version", NULL); =20 if (virFirewallApply(fw) < 0) - goto cleanup; + return -1; =20 /* * since version 1.4.16 '-m state --state ...' will be converted to @@ -3755,9 +3743,7 @@ ebiptablesDriverProbeStateMatch(void) if (version >=3D 1 * 1000000 + 4 * 1000 + 16) newMatchState =3D true; =20 - ret =3D 0; - cleanup: - return ret; + return 0; } =20 static int diff --git a/src/util/virebtables.c b/src/util/virebtables.c index 69483f35ec..610c399414 100644 --- a/src/util/virebtables.c +++ b/src/util/virebtables.c @@ -83,7 +83,6 @@ int ebtablesAddForwardPolicyReject(ebtablesContext *ctx) { g_autoptr(virFirewall) fw =3D virFirewallNew(); - int ret =3D -1; =20 virFirewallStartTransaction(fw, VIR_FIREWALL_TRANSACTION_IGNORE_ERRORS= ); virFirewallAddRule(fw, VIR_FIREWALL_LAYER_ETHERNET, @@ -98,12 +97,7 @@ ebtablesAddForwardPolicyReject(ebtablesContext *ctx) "-P", ctx->chain, "DROP", NULL); =20 - if (virFirewallApply(fw) < 0) - goto cleanup; - - ret =3D 0; - cleanup: - return ret; + return virFirewallApply(fw); } =20 =20 @@ -117,7 +111,6 @@ ebtablesForwardAllowIn(ebtablesContext *ctx, int action) { g_autoptr(virFirewall) fw =3D virFirewallNew(); - int ret =3D -1; =20 virFirewallStartTransaction(fw, 0); virFirewallAddRule(fw, VIR_FIREWALL_LAYER_ETHERNET, @@ -128,12 +121,7 @@ ebtablesForwardAllowIn(ebtablesContext *ctx, "--jump", "ACCEPT", NULL); =20 - if (virFirewallApply(fw) < 0) - goto cleanup; - - ret =3D 0; - cleanup: - return ret; + return virFirewallApply(fw); } =20 /** diff --git a/src/util/viriptables.c b/src/util/viriptables.c index b1ef3a2db6..b5dd2edbd3 100644 --- a/src/util/viriptables.c +++ b/src/util/viriptables.c @@ -129,7 +129,6 @@ int iptablesSetupPrivateChains(virFirewallLayer layer) { g_autoptr(virFirewall) fw =3D virFirewallNew(); - int ret =3D -1; iptablesGlobalChain filter_chains[] =3D { {"INPUT", "LIBVIRT_INP"}, {"OUTPUT", "LIBVIRT_OUT"}, @@ -160,12 +159,9 @@ iptablesSetupPrivateChains(virFirewallLayer layer) "--list-rules", NULL); =20 if (virFirewallApply(fw) < 0) - goto cleanup; - - ret =3D changed ? 1 : 0; + return -1; =20 - cleanup: - return ret; + return changed ? 1 : 0; } =20 =20 --=20 2.25.4