From nobody Mon Feb 9 10:24:32 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1617285319; cv=none; d=zohomail.com; s=zohoarc; b=kPJQOzW3yKpFOG/925lZZyTcSBEyiTlrHQg7TJnc8YzMgUayBlJ2wRK5fnGdWQgxeybwzlGVXCCo9YQcGJdSgkD+OdSo8iIObeT6k/cwL/N4MUDO6kNKiw258hCJkYdLrhJUzN3kurwx6CCZ7AaUxKT6Ufd8a35KghEs11ctn18= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1617285319; 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=sLm/1d45kk9UUByeTiv2iL1r11ArKZcQtFVkkigXo4M=; b=gY5H/u2ePAJreZFZ7JT9EKaz/IgnXLJW1c9KnERbbZKzPyFqCskueGt8b9aAXJiaANNPZ/sAzXj9eoYvWLuMO82rkhBoxIyUDi/6VRDFio7cdW2Gp7Y5fa7x4sXnDLZbXWuxOiS7aehW6EST6wno1oG/T9lRVSaqyAtoPW3jv8U= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 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-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mx.zohomail.com with SMTPS id 1617285319152992.2062592771233; Thu, 1 Apr 2021 06:55: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-421-Oo72LYUMO3ip17zq2mJ_5A-1; Thu, 01 Apr 2021 09:55:14 -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 BD93C88291A; Thu, 1 Apr 2021 13:54: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 355861037E92; Thu, 1 Apr 2021 13:54: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 9B90B1809C84; Thu, 1 Apr 2021 13:54:22 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 131DqlEW023023 for ; Thu, 1 Apr 2021 09:52:47 -0400 Received: by smtp.corp.redhat.com (Postfix) id 1A5C25C1A1; Thu, 1 Apr 2021 13:52:47 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.33]) by smtp.corp.redhat.com (Postfix) with ESMTP id 71BB45C237 for ; Thu, 1 Apr 2021 13:52:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1617285318; 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=sLm/1d45kk9UUByeTiv2iL1r11ArKZcQtFVkkigXo4M=; b=OIsEPGExOvQmDCfTO79EufW/UkrVVyvJGJJwNUJ0WQZ3a5BqK7aUUIYtfMuYAddsRp5FZq xndpYhqT01n8TjFbB/FTxGpELkZde7Tc6IQRp7wRqIstJSxi3sOQAhihnx/D7OkmkOzrK6 8pzW2uwb5kcxqTtwz1XmnlPEMhLgzpo= X-MC-Unique: Oo72LYUMO3ip17zq2mJ_5A-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 01/39] qemuDomainStorageSourceValidateDepth: Define chain depth as macro Date: Thu, 1 Apr 2021 15:52:00 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 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" The magic constant will be used in one more place. Signed-off-by: Peter Krempa --- src/qemu/qemu_domain.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 76e8903dbc..f818fce271 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -7471,6 +7471,7 @@ qemuDomainStorageAlias(const char *device, int depth) * * Returns 0 on success and -1 if the chain is too deep. Error is reported. */ +#define QEMU_DOMAIN_STORAGE_SOURCE_CHAIN_MAX_DEPTH 200 int qemuDomainStorageSourceValidateDepth(virStorageSourcePtr src, int add, @@ -7484,7 +7485,7 @@ qemuDomainStorageSourceValidateDepth(virStorageSource= Ptr src, nlayers +=3D add; - if (nlayers > 200) { + if (nlayers > QEMU_DOMAIN_STORAGE_SOURCE_CHAIN_MAX_DEPTH) { if (diskdst) virReportError(VIR_ERR_OPERATION_UNSUPPORTED, _("backing chains more than 200 layers deep are= not " --=20 2.29.2 From nobody Mon Feb 9 10:24:32 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1617285444; cv=none; d=zohomail.com; s=zohoarc; b=c+JkDDiXWobvH/W+TvnIxQA+UgTPc1GqZN54RAS0g+wdBuUumQnxY5G4Z0qD5veT96NarBzIXwsZH9v53ZKFVqxQsdE1Ah7O6saWiahYIHV6+GBstirNL9fMt5ZOGMMleV/pVNyZxpvLlc3s9hqNpCuTeVmfDtRx0jpMknQMvDo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1617285444; 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=pJd92Exf2vDaJYx0KIUZZIRh/quxxZ8OtGayTVTf1Po=; b=A8nlPDd+ANn405bdrQ4zsJHSIAdPQWPQXfXrugLXuTxKCasCRcZ3UhZ+oWsAVbKFB+ed6RYbgLzTN8fk/R79+s50X+PHOBme2VnrFPhlmEIaLdX24zl3sSwPX4e3lEZO682ItcwJmVCYYuLDQ1dpQ16zn2/rOId51URL7lhZnEo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 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-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mx.zohomail.com with SMTPS id 1617285444851879.0077508338705; Thu, 1 Apr 2021 06:57:24 -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-167-tUHXApvNNmyNJt64arHsOg-1; Thu, 01 Apr 2021 09:55:21 -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 8786B81CBF4; Thu, 1 Apr 2021 13:54:27 +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 3E81B1037E82; Thu, 1 Apr 2021 13:54: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 EB9354A703; Thu, 1 Apr 2021 13:54:26 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 131DqmHT023028 for ; Thu, 1 Apr 2021 09:52:48 -0400 Received: by smtp.corp.redhat.com (Postfix) id 2F6805C237; Thu, 1 Apr 2021 13:52:48 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.33]) by smtp.corp.redhat.com (Postfix) with ESMTP id 852F45C1A1 for ; Thu, 1 Apr 2021 13:52:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1617285443; 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=pJd92Exf2vDaJYx0KIUZZIRh/quxxZ8OtGayTVTf1Po=; b=e4GhaT20CVVgcjYeGB7leJ8RY0qUUhSp5FwQjxQfTGqdBB1+YrBOWUE8+6OMbrj7QtVFYM q95yEKF0tgmHqwNEnuWXGQlsKkZ9sH7VjvdlLR9IKqPHXgyMyuF8IeRsvXSPZyjwGcp4gN oBiwC/NNXluh96SxL0x6mGYBHz7TsiI= X-MC-Unique: tUHXApvNNmyNJt64arHsOg-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 02/39] virStorageSourceGetMetadata: Use depth limit instead of unique path checking Date: Thu, 1 Apr 2021 15:52:01 +0200 Message-Id: <098085cf6812348ec0c09c504598dbc105b220c1.1617285119.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 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" Prevent unbounded chains by limiting the recursion depth of virStorageSourceGetMetadataRecurse to the maximum number of image layers we limit anyways. This removes the last use of virStorageSourceGetUniqueIdentifier which will allow us to delete some crusty old infrastructure which isn't really needed. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_domain.c | 4 ++- src/security/virt-aa-helper.c | 5 +++- src/storage_file/storage_source.c | 44 +++++++++++++------------------ src/storage_file/storage_source.h | 1 + tests/virstoragetest.c | 3 ++- 5 files changed, 28 insertions(+), 29 deletions(-) diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index f818fce271..cf6d41dcad 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -7627,7 +7627,9 @@ qemuDomainDetermineDiskChain(virQEMUDriverPtr driver, qemuDomainGetImageIds(cfg, vm, src, disksrc, &uid, &gid); - if (virStorageSourceGetMetadata(src, uid, gid, report_broken) < 0) + if (virStorageSourceGetMetadata(src, uid, gid, + QEMU_DOMAIN_STORAGE_SOURCE_CHAIN_MAX_D= EPTH, + report_broken) < 0) return -1; for (n =3D src->backingStore; virStorageSourceIsBacking(n); n =3D n->b= ackingStore) { diff --git a/src/security/virt-aa-helper.c b/src/security/virt-aa-helper.c index c615305320..7e29e43c2e 100644 --- a/src/security/virt-aa-helper.c +++ b/src/security/virt-aa-helper.c @@ -937,9 +937,12 @@ get_files(vahControl * ctl) continue; /* XXX - if we knew the qemu user:group here we could send it in * so that the open could be re-tried as that user:group. + * + * The maximum depth is limited to 200 layers similarly to the qemu + * implementation. */ if (!disk->src->backingStore) - virStorageSourceGetMetadata(disk->src, -1, -1, false); + virStorageSourceGetMetadata(disk->src, -1, -1, 200, false); /* XXX should handle open errors more careful than just ignoring = them. */ diff --git a/src/storage_file/storage_source.c b/src/storage_file/storage_s= ource.c index ffe150a9b0..19b06b02b8 100644 --- a/src/storage_file/storage_source.c +++ b/src/storage_file/storage_source.c @@ -1297,11 +1297,9 @@ virStorageSourceGetMetadataRecurseReadHeader(virStor= ageSourcePtr src, uid_t uid, gid_t gid, char **buf, - size_t *headerLen, - GHashTable *cycle) + size_t *headerLen) { int ret =3D -1; - const char *uniqueName; ssize_t len; if (virStorageSourceInitAs(src, uid, gid) < 0) @@ -1312,19 +1310,6 @@ virStorageSourceGetMetadataRecurseReadHeader(virStor= ageSourcePtr src, goto cleanup; } - if (!(uniqueName =3D virStorageSourceGetUniqueIdentifier(src))) - goto cleanup; - - if (virHashHasEntry(cycle, uniqueName)) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("backing store for %s (%s) is self-referential"), - NULLSTR(src->path), uniqueName); - goto cleanup; - } - - if (virHashAddEntry(cycle, uniqueName, NULL) < 0) - goto cleanup; - if ((len =3D virStorageSourceRead(src, 0, VIR_STORAGE_MAX_HEADER, buf)= ) < 0) goto cleanup; @@ -1343,7 +1328,7 @@ virStorageSourceGetMetadataRecurse(virStorageSourcePt= r src, virStorageSourcePtr parent, uid_t uid, gid_t gid, bool report_broken, - GHashTable *cycle, + size_t max_depth, unsigned int depth) { virStorageFileFormat orig_format =3D src->format; @@ -1352,9 +1337,16 @@ virStorageSourceGetMetadataRecurse(virStorageSourceP= tr src, g_autofree char *buf =3D NULL; g_autoptr(virStorageSource) backingStore =3D NULL; - VIR_DEBUG("path=3D%s format=3D%d uid=3D%u gid=3D%u", + VIR_DEBUG("path=3D%s format=3D%d uid=3D%u gid=3D%u depth=3D%u", NULLSTR(src->path), src->format, - (unsigned int)uid, (unsigned int)gid); + (unsigned int)uid, (unsigned int)gid, depth); + + if (depth > max_depth) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("backing store for %s is self-referential or too = deeply nested"), + NULLSTR(src->path)); + return -1; + } if (src->format =3D=3D VIR_STORAGE_FILE_AUTO_SAFE) src->format =3D VIR_STORAGE_FILE_AUTO; @@ -1369,7 +1361,7 @@ virStorageSourceGetMetadataRecurse(virStorageSourcePt= r src, } if (virStorageSourceGetMetadataRecurseReadHeader(src, parent, uid, gid, - &buf, &headerLen, cyc= le) < 0) + &buf, &headerLen) < 0) return -1; if (virStorageFileProbeGetMetadata(src, buf, headerLen) < 0) @@ -1396,7 +1388,7 @@ virStorageSourceGetMetadataRecurse(virStorageSourcePt= r src, if ((rv =3D virStorageSourceGetMetadataRecurse(backingStore, paren= t, uid, gid, report_broken, - cycle, depth + 1)) < = 0) { + max_depth, depth + 1)= ) < 0) { if (!report_broken) return 0; @@ -1427,7 +1419,7 @@ virStorageSourceGetMetadataRecurse(virStorageSourcePt= r src, * Extract metadata about the storage volume with the specified * image format. If image format is VIR_STORAGE_FILE_AUTO, it * will probe to automatically identify the format. Recurses through - * the entire chain. + * the chain up to @max_depth layers. * * Open files using UID and GID (or pass -1 for the current user/group). * Treat any backing files without explicit type as raw, unless ALLOW_PROB= E. @@ -1445,14 +1437,14 @@ virStorageSourceGetMetadataRecurse(virStorageSource= Ptr src, int virStorageSourceGetMetadata(virStorageSourcePtr src, uid_t uid, gid_t gid, + size_t max_depth, bool report_broken) { - g_autoptr(GHashTable) cycle =3D virHashNew(NULL); virStorageType actualType =3D virStorageSourceGetActualType(src); - VIR_DEBUG("path=3D%s format=3D%d uid=3D%u gid=3D%u report_broken=3D%d", + VIR_DEBUG("path=3D%s format=3D%d uid=3D%u gid=3D%u max_depth=3D%zu rep= ort_broken=3D%d", src->path, src->format, (unsigned int)uid, (unsigned int)gid, - report_broken); + max_depth, report_broken); if (src->format <=3D VIR_STORAGE_FILE_NONE) { if (actualType =3D=3D VIR_STORAGE_TYPE_DIR) @@ -1462,5 +1454,5 @@ virStorageSourceGetMetadata(virStorageSourcePtr src, } return virStorageSourceGetMetadataRecurse(src, src, uid, gid, - report_broken, cycle, 1); + report_broken, max_depth, 1); } diff --git a/src/storage_file/storage_source.h b/src/storage_file/storage_s= ource.h index 6eb795b301..5e05bde7b1 100644 --- a/src/storage_file/storage_source.h +++ b/src/storage_file/storage_source.h @@ -134,6 +134,7 @@ virStorageSourceSupportsBackingChainTraversal(const vir= StorageSource *src); int virStorageSourceGetMetadata(virStorageSourcePtr src, uid_t uid, gid_t gid, + size_t max_depth, bool report_broken) ATTRIBUTE_NONNULL(1); diff --git a/tests/virstoragetest.c b/tests/virstoragetest.c index 84dd813b80..157d577c7d 100644 --- a/tests/virstoragetest.c +++ b/tests/virstoragetest.c @@ -101,7 +101,8 @@ testStorageFileGetMetadata(const char *path, def->path =3D g_strdup(path); - if (virStorageSourceGetMetadata(def, uid, gid, true) < 0) + /* 20 is picked as an arbitrary depth, since the chains used here don'= t exceed it */ + if (virStorageSourceGetMetadata(def, uid, gid, 20, true) < 0) return NULL; return g_steal_pointer(&def); --=20 2.29.2 From nobody Mon Feb 9 10:24:32 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1617285322; cv=none; d=zohomail.com; s=zohoarc; b=iGS4HfLB6mWMaNhXCDPPUZDN3LN7UHYWZYwAL+2bkmMNRgwxoODQuXLMzO8p2Rmut4n+hxvXILg64zfcX1CT3qmtB+Xstr0KAxPGluUhaUntzSDrpVR6X1VuWW/xraIZOyl8CQV/G1z2rY+XquhhNl2nrmPeTJ/OihUx7mYMZw8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1617285322; 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=tfxbis/NJ+LYJZ7VoIpjCFq7bScOpXIQVJZd1wTuuRQ=; b=HfzOpsLSsT+xOlgbePx/fC5AAt6M2FIN/wR1Et2hiQF+sFioyez1wfoYJM3lxEMnC4Iw0h9kykjqxg6dYLIPwh0RI5GKBJANDbFeYCmEjknS3usFNNM3jEn9e4E5886xNlUFD+9ouv20jaqT4Odakx387jcV+GW9SE56ipipCZg= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 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-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mx.zohomail.com with SMTPS id 16172853229771023.5211941537154; Thu, 1 Apr 2021 06:55:22 -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-133-BxR8rfTDPyKOpU_tGZbQPQ-1; Thu, 01 Apr 2021 09:55: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 0F26A873071; Thu, 1 Apr 2021 13:54:31 +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 D7DC35D9DE; Thu, 1 Apr 2021 13:54: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 9416A4A701; Thu, 1 Apr 2021 13:54:30 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 131Dqqfx023045 for ; Thu, 1 Apr 2021 09:52:52 -0400 Received: by smtp.corp.redhat.com (Postfix) id 4DABF5C237; Thu, 1 Apr 2021 13:52:52 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.33]) by smtp.corp.redhat.com (Postfix) with ESMTP id A75365C1A1 for ; Thu, 1 Apr 2021 13:52:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1617285322; 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=tfxbis/NJ+LYJZ7VoIpjCFq7bScOpXIQVJZd1wTuuRQ=; b=XhUsYV55J7SHTPbf9jPZBszgplNEOcOuyhZo2Tr990sB595H2YvgHc3JbH/watm+//mJ6Y kw49Ig6NVmcsU6AouJRvX4owfhiQT9oI95d3E9mpvAc5AiChONLLllWGiH+RQASDV1P99A 0FbpkGoPpb2HRtkcDzwmYo58hfR9r9s= X-MC-Unique: BxR8rfTDPyKOpU_tGZbQPQ-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 03/39] Remove virStorageSourceGetUniqueIdentifier file backend API Date: Thu, 1 Apr 2021 15:52:02 +0200 Message-Id: <72420e07e8cbe45aa42a087958e14ec45fa772f3.1617285119.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 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" The API isn't used any more. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/libvirt_private.syms | 1 - src/storage_file/storage_file_backend.h | 4 -- src/storage_file/storage_file_backend_fs.c | 24 ------- .../storage_file_backend_gluster.c | 71 ------------------- src/storage_file/storage_source.c | 37 +--------- 5 files changed, 1 insertion(+), 136 deletions(-) diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index cb9fe7c80a..62ccda467f 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -1713,7 +1713,6 @@ virStorageSourceGetMetadata; virStorageSourceGetMetadataFromBuf; virStorageSourceGetMetadataFromFD; virStorageSourceGetRelativeBackingPath; -virStorageSourceGetUniqueIdentifier; virStorageSourceInit; virStorageSourceInitAs; virStorageSourceNewFromBacking; diff --git a/src/storage_file/storage_file_backend.h b/src/storage_file/sto= rage_file_backend.h index ecf5883a55..8ad579a8db 100644 --- a/src/storage_file/storage_file_backend.h +++ b/src/storage_file/storage_file_backend.h @@ -60,9 +60,6 @@ typedef ssize_t size_t len, char **buf); -typedef const char * -(*virStorageFileBackendGetUniqueIdentifier)(virStorageSourcePtr src); - typedef int (*virStorageFileBackendAccess)(virStorageSourcePtr src, int mode); @@ -88,7 +85,6 @@ struct _virStorageFileBackend { virStorageFileBackendInit backendInit; virStorageFileBackendDeinit backendDeinit; virStorageFileBackendRead storageFileRead; - virStorageFileBackendGetUniqueIdentifier storageFileGetUniqueIdentifie= r; /* The following group of callbacks is expected to set errno * and return -1 on error. No libvirt error shall be reported */ diff --git a/src/storage_file/storage_file_backend_fs.c b/src/storage_file/= storage_file_backend_fs.c index 7b114fdeb0..f34ffd5fc8 100644 --- a/src/storage_file/storage_file_backend_fs.c +++ b/src/storage_file/storage_file_backend_fs.c @@ -147,24 +147,6 @@ virStorageFileBackendFileRead(virStorageSourcePtr src, } -static const char * -virStorageFileBackendFileGetUniqueIdentifier(virStorageSourcePtr src) -{ - virStorageDriverDataPtr drv =3D src->drv; - virStorageFileBackendFsPrivPtr priv =3D drv->priv; - - if (!priv->canonpath) { - if (!(priv->canonpath =3D virFileCanonicalizePath(src->path))) { - virReportSystemError(errno, _("can't canonicalize path '%s'"), - src->path); - return NULL; - } - } - - return priv->canonpath; -} - - static int virStorageFileBackendFileAccess(virStorageSourcePtr src, int mode) @@ -197,8 +179,6 @@ virStorageFileBackend virStorageFileBackendFile =3D { .storageFileRead =3D virStorageFileBackendFileRead, .storageFileAccess =3D virStorageFileBackendFileAccess, .storageFileChown =3D virStorageFileBackendFileChown, - - .storageFileGetUniqueIdentifier =3D virStorageFileBackendFileGetUnique= Identifier, }; @@ -212,8 +192,6 @@ virStorageFileBackend virStorageFileBackendBlock =3D { .storageFileRead =3D virStorageFileBackendFileRead, .storageFileAccess =3D virStorageFileBackendFileAccess, .storageFileChown =3D virStorageFileBackendFileChown, - - .storageFileGetUniqueIdentifier =3D virStorageFileBackendFileGetUnique= Identifier, }; @@ -225,8 +203,6 @@ virStorageFileBackend virStorageFileBackendDir =3D { .storageFileAccess =3D virStorageFileBackendFileAccess, .storageFileChown =3D virStorageFileBackendFileChown, - - .storageFileGetUniqueIdentifier =3D virStorageFileBackendFileGetUnique= Identifier, }; diff --git a/src/storage_file/storage_file_backend_gluster.c b/src/storage_= file/storage_file_backend_gluster.c index 06ba99bfe3..252eb523af 100644 --- a/src/storage_file/storage_file_backend_gluster.c +++ b/src/storage_file/storage_file_backend_gluster.c @@ -255,75 +255,6 @@ virStorageFileBackendGlusterAccess(virStorageSourcePtr= src, return glfs_access(priv->vol, src->path, mode); } -static int -virStorageFileBackendGlusterReadlinkCallback(const char *path, - char **linkpath, - void *data) -{ - virStorageFileBackendGlusterPrivPtr priv =3D data; - size_t bufsiz =3D 0; - ssize_t ret; - struct stat st; - g_autofree char *buf =3D NULL; - - *linkpath =3D NULL; - - if (glfs_stat(priv->vol, path, &st) < 0) { - virReportSystemError(errno, - _("failed to stat gluster path '%s'"), - path); - return -1; - } - - if (!S_ISLNK(st.st_mode)) - return 1; - - realloc: - VIR_EXPAND_N(buf, bufsiz, 256); - - if ((ret =3D glfs_readlink(priv->vol, path, buf, bufsiz)) < 0) { - virReportSystemError(errno, - _("failed to read link of gluster file '%s'"), - path); - return -1; - } - - if (ret =3D=3D bufsiz) - goto realloc; - - buf[ret] =3D '\0'; - - *linkpath =3D g_steal_pointer(&buf); - - return 0; -} - - -static const char * -virStorageFileBackendGlusterGetUniqueIdentifier(virStorageSourcePtr src) -{ - virStorageDriverDataPtr drv =3D src->drv; - virStorageFileBackendGlusterPrivPtr priv =3D drv->priv; - g_autofree char *filePath =3D NULL; - - if (priv->canonpath) - return priv->canonpath; - - if (!(filePath =3D virStorageFileCanonicalizePath(src->path, - virStorageFileBackendG= lusterReadlinkCallback, - priv))) - return NULL; - - priv->canonpath =3D g_strdup_printf("gluster://%s:%u/%s/%s", - src->hosts->name, - src->hosts->port, - src->volume, - filePath); - - return priv->canonpath; -} - - static int virStorageFileBackendGlusterChown(const virStorageSource *src, uid_t uid, @@ -349,8 +280,6 @@ virStorageFileBackend virStorageFileBackendGluster =3D { .storageFileRead =3D virStorageFileBackendGlusterRead, .storageFileAccess =3D virStorageFileBackendGlusterAccess, .storageFileChown =3D virStorageFileBackendGlusterChown, - - .storageFileGetUniqueIdentifier =3D virStorageFileBackendGlusterGetUni= queIdentifier, }; diff --git a/src/storage_file/storage_source.c b/src/storage_file/storage_s= ource.c index 19b06b02b8..746a3446d8 100644 --- a/src/storage_file/storage_source.c +++ b/src/storage_file/storage_source.c @@ -843,8 +843,7 @@ virStorageSourceSupportsBackingChainTraversal(const vir= StorageSource *src) if ((rv =3D virStorageSourceGetBackendForSupportCheck(src, &backend)) = < 1) return rv; - return backend->storageFileGetUniqueIdentifier && - backend->storageFileRead && + return backend->storageFileRead && backend->storageFileAccess ? 1 : 0; } @@ -1142,40 +1141,6 @@ virStorageSourceRead(virStorageSourcePtr src, } -/* - * virStorageSourceGetUniqueIdentifier: Get a unique string describing the= volume - * - * @src: file structure pointing to the file - * - * Returns a string uniquely describing a single volume (canonical path). - * The string shall not be freed and is valid until the storage file is - * deinitialized. Returns NULL on error and sets a libvirt error code */ -const char * -virStorageSourceGetUniqueIdentifier(virStorageSourcePtr src) -{ - virStorageDriverDataPtr drv =3D NULL; - - if (!virStorageSourceIsInitialized(src)) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("storage file backend not initialized")); - return NULL; - } - - drv =3D src->drv; - - if (!drv->backend->storageFileGetUniqueIdentifier) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("unique storage file identifier not implemented f= or " - "storage type %s (protocol: %s)'"), - virStorageTypeToString(src->type), - virStorageNetProtocolTypeToString(src->protocol)); - return NULL; - } - - return drv->backend->storageFileGetUniqueIdentifier(src); -} - - /** * virStorageSourceAccess: Check accessibility of a storage file * --=20 2.29.2 From nobody Mon Feb 9 10:24:32 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1617285230; cv=none; d=zohomail.com; s=zohoarc; b=OwPFozI57OsGZqL5R2K4XRgrgDNhK87ZwQf4/ndte2LhXvIdHC2CYCtICul4D1CrpGQejR0HQyll7TjnOKkCS8ERIrq3p3NcuixPZhydVvFwC3hr0sSyv0z4HaDVdIWj75FHBBwp0wSbHJaHzTRioJiQ8W9SAquO3MDlVJxAkzw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1617285230; 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=wDkzEeo1vOrfjXQ9CTG7z9Ma4qZAdNjYiOO/Gqsb2VI=; b=oDnv76raBhy/6oXjvQGMlN2Q5LVKlI2aGpLzOcsNM6aU657Hf6UEWsoqD82s/bkLrUvHnfjVT7pUU+ZFtKko+5SQD3OuluXVhZqx0ghBlOhSx+RZBpG3OxphLUtV7P4guCwtIMR/h49EI7LyyO46prTD8BhShTQ3sf9yLzT76FE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 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-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mx.zohomail.com with SMTPS id 161728523004492.23966402755775; Thu, 1 Apr 2021 06:53:50 -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-579-iAiqIkMfMsOVBCPLHQRxrw-1; Thu, 01 Apr 2021 09:53:46 -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 9684D1019623; Thu, 1 Apr 2021 13:53:40 +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 32E5719D9B; Thu, 1 Apr 2021 13:53:40 +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 9AF6318155DD; Thu, 1 Apr 2021 13:53:38 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 131DqtAw023056 for ; Thu, 1 Apr 2021 09:52:55 -0400 Received: by smtp.corp.redhat.com (Postfix) id 9210B5C239; Thu, 1 Apr 2021 13:52:55 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.33]) by smtp.corp.redhat.com (Postfix) with ESMTP id 00F1B5C237 for ; Thu, 1 Apr 2021 13:52:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1617285229; 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=wDkzEeo1vOrfjXQ9CTG7z9Ma4qZAdNjYiOO/Gqsb2VI=; b=GdMuUCNv0lr4XnObqxOj53942vkEfVmkJIfqkWWoyerune4NZOYRAvjjtXMJ80BpA4oDN9 i8hvdRsk9bj5OVqoI/eRBiWTu4AsYKpji+rV9vCz6IUN6K6AAe2rvrRgVtm+s3ThzlX0Sn oHYJ3b5YJ1I9vyRBFPTOmRmyPeRmhME= X-MC-Unique: iAiqIkMfMsOVBCPLHQRxrw-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 04/39] storage_file: Remove virStorageFileBackendFsPriv Date: Thu, 1 Apr 2021 15:52:03 +0200 Message-Id: <1ac497aef1939c032d967a6d71d5acbae7c448c1.1617285119.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 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" The private data structure is no longer used. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/storage_file/storage_file_backend_fs.c | 20 -------------------- 1 file changed, 20 deletions(-) diff --git a/src/storage_file/storage_file_backend_fs.c b/src/storage_file/= storage_file_backend_fs.c index f34ffd5fc8..8422543057 100644 --- a/src/storage_file/storage_file_backend_fs.c +++ b/src/storage_file/storage_file_backend_fs.c @@ -40,27 +40,12 @@ VIR_LOG_INIT("storage.storage_backend_fs"); -typedef struct _virStorageFileBackendFsPriv virStorageFileBackendFsPriv; -typedef virStorageFileBackendFsPriv *virStorageFileBackendFsPrivPtr; - -struct _virStorageFileBackendFsPriv { - char *canonpath; /* unique file identifier (canonical path) */ -}; - - static void virStorageFileBackendFileDeinit(virStorageSourcePtr src) { - virStorageDriverDataPtr drv =3D src->drv; - virStorageFileBackendFsPrivPtr priv =3D drv->priv; - VIR_DEBUG("deinitializing FS storage file %p (%s:%s)", src, virStorageTypeToString(virStorageSourceGetActualType(src)), src->path); - - - VIR_FREE(priv->canonpath); - VIR_FREE(priv); } @@ -68,17 +53,12 @@ static int virStorageFileBackendFileInit(virStorageSourcePtr src) { virStorageDriverDataPtr drv =3D src->drv; - virStorageFileBackendFsPrivPtr priv =3D NULL; VIR_DEBUG("initializing FS storage file %p (%s:%s)[%u:%u]", src, virStorageTypeToString(virStorageSourceGetActualType(src)), src->path, (unsigned int)drv->uid, (unsigned int)drv->gid); - priv =3D g_new0(virStorageFileBackendFsPriv, 1); - - drv->priv =3D priv; - return 0; } --=20 2.29.2 From nobody Mon Feb 9 10:24:32 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1617285299; cv=none; d=zohomail.com; s=zohoarc; b=JDBHn4yFzqNBifzkKvVG6ZdjIRIQh9AfajnzHO7z3eMkrVbZjypH4j4plkWrFGwrgtwAndx+CaFU0Fn/GzoZ9KJqU1wioPazn/nyrpYQh3raXvGEKNLprGEQe67x8HJHYyUJuf3U6qBkzSULl1D8TX0bWR1Ui/2NKERBCANqdB0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1617285299; 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=w37rKpyL7/ch/b/AyQSG6vLbVKXM7UJjBJOAYLDWt6E=; b=Y/ZOGPEJz1+cdvMdhU30NJbT+3o4G2kteBUYY/W70rbOdiduxoIur2b14rgUFAsjcuv6Ld+WzbW56lYBIuOHEoIS24lodopBcO57QYnbhWOOLsTdFXBdWKtofo6jxhFqztLfxmbMTniBAiCNNA1eVnQnE+4eclQznk1936TcFFA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 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-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1617285299726491.9233560116976; Thu, 1 Apr 2021 06:54:59 -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-6-JxF8EMr3Om67lB0xnFffWQ-1; Thu, 01 Apr 2021 09:54:55 -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 56E418A2A1A; Thu, 1 Apr 2021 13:54: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 269B119D80; Thu, 1 Apr 2021 13:54: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 D56E64A704; Thu, 1 Apr 2021 13:54:33 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 131Dqubv023066 for ; Thu, 1 Apr 2021 09:52:56 -0400 Received: by smtp.corp.redhat.com (Postfix) id B02055C238; Thu, 1 Apr 2021 13:52:56 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.33]) by smtp.corp.redhat.com (Postfix) with ESMTP id F34035C1A1 for ; Thu, 1 Apr 2021 13:52:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1617285298; 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=w37rKpyL7/ch/b/AyQSG6vLbVKXM7UJjBJOAYLDWt6E=; b=g7h31V2lM8kuzRiFihSIQJs/KbPmgOVQgSgaflFUDHpheE8DgiP9EF8y40BiqJ4myIuhzq 9GgW1WRFDWLXZrvg7WTPYYLF5jxiq6TFFFPVx9RRkL6y4OLIjo0FS98+Ozo8HJNGydliTc AFNRaD8RHFIJH+LSv5kXaMVSk44mcq8= X-MC-Unique: JxF8EMr3Om67lB0xnFffWQ-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 05/39] virStorageFileBackendGlusterPriv: Remove 'canonpaht' Date: Thu, 1 Apr 2021 15:52:04 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 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: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/storage_file/storage_file_backend_gluster.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/storage_file/storage_file_backend_gluster.c b/src/storage_= file/storage_file_backend_gluster.c index 252eb523af..0cd4cf9f62 100644 --- a/src/storage_file/storage_file_backend_gluster.c +++ b/src/storage_file/storage_file_backend_gluster.c @@ -41,7 +41,6 @@ typedef virStorageFileBackendGlusterPriv *virStorageFileB= ackendGlusterPrivPtr; struct _virStorageFileBackendGlusterPriv { glfs_t *vol; - char *canonpath; }; static void @@ -55,7 +54,6 @@ virStorageFileBackendGlusterDeinit(virStorageSourcePtr sr= c) if (priv->vol) glfs_fini(priv->vol); - VIR_FREE(priv->canonpath); VIR_FREE(priv); drv->priv =3D NULL; --=20 2.29.2 From nobody Mon Feb 9 10:24:32 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) client-ip=63.128.21.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1617285237; cv=none; d=zohomail.com; s=zohoarc; b=U8G2mFtIFcSGQQx0zUT603+lKWINL9soQYsVenLJkxRGUOh5ADhHZCuMheR8aTLd6JO2Pq5PjTaieJYXfUGfLWTcEEoz4IaMbplz9VCSwVqL0mfHNvQpnfmOTnzC5/QmW4mAMG5RDbTG4RHAPlHrsgZm02EoDpaDMMmjGvrBRGM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1617285237; 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=h/nd95xRCpb3bKBqIUWlTqUQtKptUUVv2tK5B70lqz8=; b=hxuRUrk21AfA/7YGS9+H+O+bAl1aXivku9Yv12dvgf2kxQChRk6EEF0v0ymprHipAu5whCzcvcl+IaXyeWJC9Z0U4Gh5CpUIywy1rIvfWKIhlqJCO7wK0s2SQvSG3dSjLKqH+eInH5fWsGRDCldx2H0jbFKM0J9VRtCkDSZ4raQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.124 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-124.mimecast.com (us-smtp-delivery-124.mimecast.com [63.128.21.124]) by mx.zohomail.com with SMTPS id 1617285237667306.9698410796541; Thu, 1 Apr 2021 06:53: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-466-mn3ux35zPDWmnr1qNf_sWA-1; Thu, 01 Apr 2021 09:53:53 -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 BEB6681426D; Thu, 1 Apr 2021 13:53: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 9915260C5F; Thu, 1 Apr 2021 13:53: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 54E3A18155DD; Thu, 1 Apr 2021 13:53:48 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 131Dqvjk023076 for ; Thu, 1 Apr 2021 09:52:57 -0400 Received: by smtp.corp.redhat.com (Postfix) id D21B15C238; Thu, 1 Apr 2021 13:52:57 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.33]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3364D5C1A1 for ; Thu, 1 Apr 2021 13:52:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1617285235; 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=h/nd95xRCpb3bKBqIUWlTqUQtKptUUVv2tK5B70lqz8=; b=Mj3NmVoEaG3BO1suka++gzuPXuxDyWlW9IFePtKVPDlDYjeVQpUdeoH+pmCjgrPeorxmMr L6E2L2wfwLlHkXdEHhwyI8vtG1E8vHKbQir/W8k94Xp+GrjQhzotZKnclYjRaJn7ip6IDJ oCF1Yyd1T1OvA36GEMeXOOhcyC/+Uuw= X-MC-Unique: mn3ux35zPDWmnr1qNf_sWA-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 06/39] tests: Remove testing of virStorageFileCanonicalizePath Date: Thu, 1 Apr 2021 15:52:05 +0200 Message-Id: <04e13792718ba4143a9ba49edf5f106d46242079.1617285119.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 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" Remove the last code using the function. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- tests/virstoragetest.c | 100 ----------------------------------------- 1 file changed, 100 deletions(-) diff --git a/tests/virstoragetest.c b/tests/virstoragetest.c index 157d577c7d..23cc72d85c 100644 --- a/tests/virstoragetest.c +++ b/tests/virstoragetest.c @@ -398,62 +398,6 @@ testStorageLookup(const void *args) } -struct testPathCanonicalizeData -{ - const char *path; - const char *expect; -}; - -static const char *testPathCanonicalizeSymlinks[][2] =3D -{ - {"/path/blah", "/other/path/huzah"}, - {"/path/to/relative/symlink", "../../actual/file"}, - {"/cycle", "/cycle"}, - {"/cycle2/link", "./link"}, -}; - -static int -testPathCanonicalizeReadlink(const char *path, - char **linkpath, - void *data G_GNUC_UNUSED) -{ - size_t i; - - *linkpath =3D NULL; - - for (i =3D 0; i < G_N_ELEMENTS(testPathCanonicalizeSymlinks); i++) { - if (STREQ(path, testPathCanonicalizeSymlinks[i][0])) { - *linkpath =3D g_strdup(testPathCanonicalizeSymlinks[i][1]); - - return 0; - } - } - - return 1; -} - - -static int -testPathCanonicalize(const void *args) -{ - const struct testPathCanonicalizeData *data =3D args; - g_autofree char *canon =3D NULL; - - canon =3D virStorageFileCanonicalizePath(data->path, - testPathCanonicalizeReadlink, - NULL); - - if (STRNEQ_NULLABLE(data->expect, canon)) { - fprintf(stderr, - "path canonicalization of '%s' failed: expected '%s' got '= %s'\n", - data->path, NULLSTR(data->expect), NULLSTR(canon)); - - return -1; - } - - return 0; -} - static virStorageSource backingchain[12]; static void @@ -602,7 +546,6 @@ mymain(void) int ret; struct testChainData data; struct testLookupData data2; - struct testPathCanonicalizeData data3; struct testPathRelativeBacking data4; struct testBackingParseData data5; virStorageSourcePtr chain2; /* short for chain->backingStore */ @@ -1086,49 +1029,6 @@ mymain(void) TEST_LOOKUP_TARGET(80, "vda", chain3, "vda[2]", 0, NULL, NULL, NULL); TEST_LOOKUP_TARGET(81, "vda", NULL, "vda[3]", 0, NULL, NULL, NULL); -#define TEST_PATH_CANONICALIZE(id, PATH, EXPECT) \ - do { \ - data3.path =3D PATH; \ - data3.expect =3D EXPECT; \ - if (virTestRun("Path canonicalize " #id, \ - testPathCanonicalize, &data3) < 0) \ - ret =3D -1; \ - } while (0) - - TEST_PATH_CANONICALIZE(1, "/", "/"); - TEST_PATH_CANONICALIZE(2, "/path", "/path"); - TEST_PATH_CANONICALIZE(3, "/path/to/blah", "/path/to/blah"); - TEST_PATH_CANONICALIZE(4, "/path/", "/path"); - TEST_PATH_CANONICALIZE(5, "///////", "/"); - TEST_PATH_CANONICALIZE(6, "//", "//"); - TEST_PATH_CANONICALIZE(7, "", ""); - TEST_PATH_CANONICALIZE(8, ".", "."); - TEST_PATH_CANONICALIZE(9, "../", ".."); - TEST_PATH_CANONICALIZE(10, "../../", "../.."); - TEST_PATH_CANONICALIZE(11, "../../blah", "../../blah"); - TEST_PATH_CANONICALIZE(12, "/./././blah", "/blah"); - TEST_PATH_CANONICALIZE(13, ".././../././../blah", "../../../blah"); - TEST_PATH_CANONICALIZE(14, "/././", "/"); - TEST_PATH_CANONICALIZE(15, "./././", "."); - TEST_PATH_CANONICALIZE(16, "blah/../foo", "foo"); - TEST_PATH_CANONICALIZE(17, "foo/bar/../blah", "foo/blah"); - TEST_PATH_CANONICALIZE(18, "foo/bar/.././blah", "foo/blah"); - TEST_PATH_CANONICALIZE(19, "/path/to/foo/bar/../../../../../../../../b= az", "/baz"); - TEST_PATH_CANONICALIZE(20, "path/to/foo/bar/../../../../../../../../ba= z", "../../../../baz"); - TEST_PATH_CANONICALIZE(21, "path/to/foo/bar", "path/to/foo/bar"); - TEST_PATH_CANONICALIZE(22, "//foo//bar", "//foo/bar"); - TEST_PATH_CANONICALIZE(23, "/bar//foo", "/bar/foo"); - TEST_PATH_CANONICALIZE(24, "//../blah", "//blah"); - - /* test paths with symlinks */ - TEST_PATH_CANONICALIZE(25, "/path/blah", "/other/path/huzah"); - TEST_PATH_CANONICALIZE(26, "/path/to/relative/symlink", "/path/actual/= file"); - TEST_PATH_CANONICALIZE(27, "/path/to/relative/symlink/blah", "/path/ac= tual/file/blah"); - TEST_PATH_CANONICALIZE(28, "/path/blah/yippee", "/other/path/huzah/yip= pee"); - TEST_PATH_CANONICALIZE(29, "/cycle", NULL); - TEST_PATH_CANONICALIZE(30, "/cycle2/link", NULL); - TEST_PATH_CANONICALIZE(31, "///", "/"); - #define TEST_RELATIVE_BACKING(id, TOP, BASE, EXPECT) \ do { \ data4.top =3D &TOP; \ --=20 2.29.2 From nobody Mon Feb 9 10:24:32 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1617285298; cv=none; d=zohomail.com; s=zohoarc; b=EFCHmjVho9AAYRu0rjCiAF0h67kEoyy6BDxOZl9MiiUuiHC4siLw9viNtUWP6PYBsfcfZuZq9Z4i1YuN3o0bdO0vgqqGga9f837yi6k6/bJNaifxaJXPjfQT8HoIs6nPSl5mKYhCO8twGbYG805d6mg/afGmFp1Y1AY0nNKS01Y= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1617285298; 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=BjRgYi0KjjWLwnpEOgORojgAlWopjXw4Fx8X5UVRcRQ=; b=hwnCU2Ta0TcAD4CsifLrlPigoPM34HLqKDDShtKUfBEWz1wXpgk5yjas8QBdXMKXUCzyNKuEl25k6pPCxgurqKU2M2WRej2HbGjb5o3KTeBdj2kqSarLpdoKBeAvd6qpNuldtkZE2yTT6TD4JW/t2MY35qd5nJEBvzM0laW1L0A= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 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-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1617285298142284.9716143713159; Thu, 1 Apr 2021 06:54:58 -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-88-r7YRgl03MGi5TmKbLhE2EQ-1; Thu, 01 Apr 2021 09:54: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 18BE21026F73; Thu, 1 Apr 2021 13:54:38 +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 E0A715D6B1; Thu, 1 Apr 2021 13:54:37 +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 9A6E5180B452; Thu, 1 Apr 2021 13:54:37 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 131Dr268023091 for ; Thu, 1 Apr 2021 09:53:02 -0400 Received: by smtp.corp.redhat.com (Postfix) id 548D95C238; Thu, 1 Apr 2021 13:53:02 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.33]) by smtp.corp.redhat.com (Postfix) with ESMTP id A90605C1A1 for ; Thu, 1 Apr 2021 13:52:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1617285297; 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=BjRgYi0KjjWLwnpEOgORojgAlWopjXw4Fx8X5UVRcRQ=; b=Zu/dbvAX1Nfel3Zdc5QZX+x/BseKzfogewX4YFdhINxjahL/nDzwaOaP8LhoNpwfvqk+vv vNzwWZXIkG+pzVy+Pz4Z7fN2X58UGncUHLQPnImlAqowzCQcePxtdXYSeBzGrXmQ8zi9mB 5o5tqBp5J5Djtiuc2CflUv7/jOMTGdk= X-MC-Unique: r7YRgl03MGi5TmKbLhE2EQ-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 07/39] Remove virStorageFileCanonicalizePath Date: Thu, 1 Apr 2021 15:52:06 +0200 Message-Id: <9f2e44de4589bff9839369eb141036c4f088ecdb.1617285119.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 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: Peter Krempa --- src/libvirt_private.syms | 1 - src/util/virstoragefile.c | 210 -------------------------------------- src/util/virstoragefile.h | 8 -- 3 files changed, 219 deletions(-) diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 62ccda467f..9208db2056 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -3231,7 +3231,6 @@ virSocketAddrSetPort; # util/virstoragefile.h -virStorageFileCanonicalizePath; virStorageFileGetNPIVKey; virStorageFileGetSCSIKey; virStorageFileParseBackingStoreStr; diff --git a/src/util/virstoragefile.c b/src/util/virstoragefile.c index 9df891b57c..e6bc723d1e 100644 --- a/src/util/virstoragefile.c +++ b/src/util/virstoragefile.c @@ -214,213 +214,3 @@ virStorageFileParseBackingStoreStr(const char *str, *chainIndex =3D idx; return 0; } - - -static char * -virStorageFileCanonicalizeFormatPath(char **components, - size_t ncomponents, - bool beginSlash, - bool beginDoubleSlash) -{ - g_auto(virBuffer) buf =3D VIR_BUFFER_INITIALIZER; - size_t i; - char *ret =3D NULL; - - if (beginSlash) - virBufferAddLit(&buf, "/"); - - if (beginDoubleSlash) - virBufferAddLit(&buf, "/"); - - for (i =3D 0; i < ncomponents; i++) { - if (i !=3D 0) - virBufferAddLit(&buf, "/"); - - virBufferAdd(&buf, components[i], -1); - } - - /* if the output string is empty just return an empty string */ - if (!(ret =3D virBufferContentAndReset(&buf))) - ret =3D g_strdup(""); - - return ret; -} - - -static int -virStorageFileCanonicalizeInjectSymlink(const char *path, - size_t at, - char ***components, - size_t *ncomponents) -{ - char **tmp =3D NULL; - char **next; - size_t ntmp =3D 0; - int ret =3D -1; - - if (!(tmp =3D virStringSplitCount(path, "/", 0, &ntmp))) - goto cleanup; - - /* prepend */ - for (next =3D tmp; *next; next++) { - if (VIR_INSERT_ELEMENT(*components, at, *ncomponents, *next) < 0) - goto cleanup; - - at++; - } - - ret =3D 0; - - cleanup: - virStringListFreeCount(tmp, ntmp); - return ret; -} - - -char * -virStorageFileCanonicalizePath(const char *path, - virStorageFileSimplifyPathReadlinkCallback = cb, - void *cbdata) -{ - GHashTable *cycle =3D NULL; - bool beginSlash =3D false; - bool beginDoubleSlash =3D false; - char **components =3D NULL; - size_t ncomponents =3D 0; - size_t i =3D 0; - size_t j =3D 0; - int rc; - char *ret =3D NULL; - g_autofree char *linkpath =3D NULL; - g_autofree char *currentpath =3D NULL; - - if (path[0] =3D=3D '/') { - beginSlash =3D true; - - if (path[1] =3D=3D '/' && path[2] !=3D '/') - beginDoubleSlash =3D true; - } - - if (!(cycle =3D virHashNew(NULL))) - goto cleanup; - - if (!(components =3D virStringSplitCount(path, "/", 0, &ncomponents))) - goto cleanup; - - j =3D 0; - while (j < ncomponents) { - /* skip slashes */ - if (STREQ(components[j], "")) { - VIR_FREE(components[j]); - VIR_DELETE_ELEMENT(components, j, ncomponents); - continue; - } - j++; - } - - while (i < ncomponents) { - /* skip '.'s unless it's the last one remaining */ - if (STREQ(components[i], ".") && - (beginSlash || ncomponents > 1)) { - VIR_FREE(components[i]); - VIR_DELETE_ELEMENT(components, i, ncomponents); - continue; - } - - /* resolve changes to parent directory */ - if (STREQ(components[i], "..")) { - if (!beginSlash && - (i =3D=3D 0 || STREQ(components[i - 1], ".."))) { - i++; - continue; - } - - VIR_FREE(components[i]); - VIR_DELETE_ELEMENT(components, i, ncomponents); - - if (i !=3D 0) { - VIR_FREE(components[i - 1]); - VIR_DELETE_ELEMENT(components, i - 1, ncomponents); - i--; - } - - continue; - } - - /* check if the actual path isn't resulting into a symlink */ - if (!(currentpath =3D virStorageFileCanonicalizeFormatPath(compone= nts, - i + 1, - beginSlas= h, - beginDoub= leSlash))) - goto cleanup; - - if ((rc =3D cb(currentpath, &linkpath, cbdata)) < 0) - goto cleanup; - - if (rc =3D=3D 0) { - if (virHashLookup(cycle, currentpath)) { - virReportSystemError(ELOOP, - _("Failed to canonicalize path '%s'")= , path); - goto cleanup; - } - - if (virHashAddEntry(cycle, currentpath, (void *) 1) < 0) - goto cleanup; - - if (linkpath[0] =3D=3D '/') { - /* kill everything from the beginning including the actual= component */ - i++; - while (i--) { - VIR_FREE(components[0]); - VIR_DELETE_ELEMENT(components, 0, ncomponents); - } - beginSlash =3D true; - - if (linkpath[1] =3D=3D '/' && linkpath[2] !=3D '/') - beginDoubleSlash =3D true; - else - beginDoubleSlash =3D false; - - i =3D 0; - } else { - VIR_FREE(components[i]); - VIR_DELETE_ELEMENT(components, i, ncomponents); - } - - if (virStorageFileCanonicalizeInjectSymlink(linkpath, - i, - &components, - &ncomponents) < 0) - goto cleanup; - - j =3D 0; - while (j < ncomponents) { - /* skip slashes */ - if (STREQ(components[j], "")) { - VIR_FREE(components[j]); - VIR_DELETE_ELEMENT(components, j, ncomponents); - continue; - } - j++; - } - - VIR_FREE(linkpath); - VIR_FREE(currentpath); - - continue; - } - - VIR_FREE(currentpath); - - i++; - } - - ret =3D virStorageFileCanonicalizeFormatPath(components, ncomponents, - beginSlash, beginDoubleSlas= h); - - cleanup: - virHashFree(cycle); - virStringListFreeCount(components, ncomponents); - - return ret; -} diff --git a/src/util/virstoragefile.h b/src/util/virstoragefile.h index 6b198858cc..62185e6f4f 100644 --- a/src/util/virstoragefile.h +++ b/src/util/virstoragefile.h @@ -33,11 +33,3 @@ int virStorageFileGetSCSIKey(const char *path, bool ignoreError); int virStorageFileGetNPIVKey(const char *path, char **key); - -typedef int -(*virStorageFileSimplifyPathReadlinkCallback)(const char *path, - char **link, - void *data); -char *virStorageFileCanonicalizePath(const char *path, - virStorageFileSimplifyPathReadlinkCal= lback cb, - void *cbdata); --=20 2.29.2 From nobody Mon Feb 9 10:24:32 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1617285242; cv=none; d=zohomail.com; s=zohoarc; b=kqQAOwRiOACFJAeyFMvPcwADsP0t7uQUy+u5kwGFo+CPX2OTzpt5ohnilgKaGqTuH6U5Ajdh5mmmkMGDhdvxhmDWeAL4skWEgw0XExEj9JEiInYMJDXw/Ibrr1Rr6RLLOquZ8htts/et5ntbeXtJQuqaqAZt14CDFOehz+9d660= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1617285242; 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=FSnOd5hWNaFv8DpdpGpBt5GjDI0r0sFrYEiOp6r0oOU=; b=iQfiwtXJbC+kqwCStPNEky8+yFUjknixXfklOi9bJseWrL5S5jFFeQXC2fXm5rV6g49nXYoqgiAVRrcKHmwVViO1hjBViyHtvgoXEXqy2ru7aC3TZi8lSyZp3hVA2ooG79G1zUZXErTD462WUVPD+MBHrm+/fWfbZP3ablfN2yk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 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-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mx.zohomail.com with SMTPS id 1617285242746453.81872554322877; Thu, 1 Apr 2021 06:54:02 -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-369-GFn3VUYBPcCDB6fW_5mMtw-1; Thu, 01 Apr 2021 09:53:59 -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 B567F106BB30; Thu, 1 Apr 2021 13:53:52 +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 8D47351C5C; Thu, 1 Apr 2021 13:53:52 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 46385180B450; Thu, 1 Apr 2021 13:53:52 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 131Dr3oF023098 for ; Thu, 1 Apr 2021 09:53:03 -0400 Received: by smtp.corp.redhat.com (Postfix) id 606C05C238; Thu, 1 Apr 2021 13:53:03 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.33]) by smtp.corp.redhat.com (Postfix) with ESMTP id B1F0C5C1A1 for ; Thu, 1 Apr 2021 13:53:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1617285241; 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=FSnOd5hWNaFv8DpdpGpBt5GjDI0r0sFrYEiOp6r0oOU=; b=fEOE/ZjZQOttNO7NrTeULq42e2js3XdJaYBKU13eUytspKzPvT6B5JosMeNL9EukGMMX2Y H9jJkyWCclwLK7QeSV+TmnPcdetqCHnK5s4lbRgF9qHpbmO6aun/MvApaE2pvR3MOFC37n 6MXbXH1/AW1DZEJr8HFO9aBCBUfKQk0= X-MC-Unique: GFn3VUYBPcCDB6fW_5mMtw-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 08/39] virDomainDiskAddISCSIPoolSourceHost: use g_strsplit instead of virStringSplitCount Date: Thu, 1 Apr 2021 15:52:07 +0200 Message-Id: <90065cf85e2dc21d238bb3134dff85f35abeea42.1617285119.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 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" Count the elements directly using g_strv_length. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/conf/domain_conf.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index d050a519c6..2ab476dfdb 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -32080,7 +32080,6 @@ virDomainDiskAddISCSIPoolSourceHost(virStorageSourc= ePtr src, virStoragePoolDefPtr pooldef) { g_auto(GStrv) tokens =3D NULL; - size_t ntokens; /* Only support one host */ if (pooldef->source.nhost !=3D 1) { @@ -32101,10 +32100,10 @@ virDomainDiskAddISCSIPoolSourceHost(virStorageSou= rcePtr src, src->hosts[0].port =3D 3260; /* iscsi volume has name like "unit:0:0:1" */ - if (!(tokens =3D virStringSplitCount(src->srcpool->volume, ":", 0, &nt= okens))) + if (!(tokens =3D g_strsplit(src->srcpool->volume, ":", 0))) return -1; - if (ntokens !=3D 4) { + if (g_strv_length(tokens) !=3D 4) { virReportError(VIR_ERR_INTERNAL_ERROR, _("unexpected iscsi volume name '%s'"), src->srcpool->volume); --=20 2.29.2 From nobody Mon Feb 9 10:24:32 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1617285241; cv=none; d=zohomail.com; s=zohoarc; b=YLGzlnBTFXezzl83nin1b/olCYd2iYBFlkJD/r16zZd64PZMOEjQ1lxfbOpBzhWw7+eMEmSv81XTLEnmGCHvVxZ/bf/l4pJ+qUZJShw7kLkdGuPi1ippNVoSb9gGSYEaQISQYtyL4jUHTQRkpqDLsIgFuyAUVVJmpMtoVBfYNx4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1617285241; 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=b99nUC4FKZUkTiMIG32m1RXe7AgaP/syFzPRRjXpXHY=; b=ckphm8neIAxS0WAir7zVGl0goeEbbkjOqhcwJr/SeyjpWsb9MKrPzVpecDxm1Tj95bzw8lieqI/CjxXWdnpKAqMQTvEnQ7DL2A4HsUFJWNGSZmIFONwM+t+Y3wvVILY1oCVc0AOkrcjGJ52vtNPvcP/qGKnGF+FhNe18w9tfdpE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 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-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mx.zohomail.com with SMTPS id 1617285241064263.3064286506824; Thu, 1 Apr 2021 06:54:01 -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-467-8lZ1CRi4NDuU8HITN0nB2w-1; Thu, 01 Apr 2021 09:53:57 -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 97ECA801814; Thu, 1 Apr 2021 13:53:50 +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 67EC971294; Thu, 1 Apr 2021 13:53:50 +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 1F5594A7C9; Thu, 1 Apr 2021 13:53:50 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 131Dr4Xn023110 for ; Thu, 1 Apr 2021 09:53:04 -0400 Received: by smtp.corp.redhat.com (Postfix) id 712931DB; Thu, 1 Apr 2021 13:53:04 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.33]) by smtp.corp.redhat.com (Postfix) with ESMTP id CB1045C1A1 for ; Thu, 1 Apr 2021 13:53:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1617285240; 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=b99nUC4FKZUkTiMIG32m1RXe7AgaP/syFzPRRjXpXHY=; b=eOyJNGZROv/fGEKeBBYAQ0252iHRsrwUHSJgdOwv+A55fh1RZ5+qm9u8NXa4EU2ucXdZhf IIggUYMgVDKDVo7Zz9+0vCeQjTpvhH/vkPc3rZGhjEcMklH3Yr5eaYGpo+DuDm6J775C/W 3o+qeLSOLoKp2twPDWH57tK2yXqqCRs= X-MC-Unique: 8lZ1CRi4NDuU8HITN0nB2w-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 09/39] virJSONValueObjectDeflattenWorker: use g_strsplit instead of virStringSplitCount Date: Thu, 1 Apr 2021 15:52:08 +0200 Message-Id: <82c09c4204fd5483800f30f9910ca68fa4570363.1617285119.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 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" The presence of the second element can be checked by looking at it directly. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/util/virjson.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/util/virjson.c b/src/util/virjson.c index 82081db870..f376490288 100644 --- a/src/util/virjson.c +++ b/src/util/virjson.c @@ -2029,7 +2029,6 @@ virJSONValueObjectDeflattenWorker(const char *key, g_autoptr(virJSONValue) newval =3D NULL; virJSONValuePtr existobj; g_auto(GStrv) tokens =3D NULL; - size_t ntokens =3D 0; /* non-nested keys only need to be copied */ if (!strchr(key, '.')) { @@ -2054,10 +2053,10 @@ virJSONValueObjectDeflattenWorker(const char *key, return 0; } - if (!(tokens =3D virStringSplitCount(key, ".", 2, &ntokens))) + if (!(tokens =3D g_strsplit(key, ".", 2))) return -1; - if (ntokens !=3D 2) { + if (!tokens[0] || !tokens[1]) { virReportError(VIR_ERR_INVALID_ARG, _("invalid nested value key '%s'"), key); return -1; --=20 2.29.2 From nobody Mon Feb 9 10:24:32 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) client-ip=63.128.21.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1617285245; cv=none; d=zohomail.com; s=zohoarc; b=Uw7ZTgfBSJsm7sTWbXBmf/+Wf4m46CUSZ3CDHDrstslyOBSMy/ZboueuVv8e/CBqBUredAUsJtBDDuTncOKV9N2tE3Fy1vmcgXNIqstIGUPqCUePUDKm/2nZEkgDNCL7RGbLkZctZo7eOWQQpX+KXctdr2/SGkZxGSL3cjvllG4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1617285245; 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=tnTE5Pr0o0DYB3qerqxRL+g8gOd577uExLVeke26i0E=; b=f0u5ZulNwMEGEybjt2JHyy0PAgHEITWF5IAD5o+PjAykfsgcO/JiAQtgo7GCe1Zz2QlHeeCl8roSZpMO6M3AhMFl0baaG+CR2U0HdEvIpemiS+l1smSCYZYazwjQDaoBIOtSIQQDb4LrHOIvARy2FOrlqvKwIDbT949rkh/TAAA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.124 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-124.mimecast.com (us-smtp-delivery-124.mimecast.com [63.128.21.124]) by mx.zohomail.com with SMTPS id 1617285245712761.7424622471375; Thu, 1 Apr 2021 06:54:05 -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-564-K6IMNAVDMgi23eQ8bOYKGg-1; Thu, 01 Apr 2021 09:54:02 -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 D936C8189F2; Thu, 1 Apr 2021 13:53:55 +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 31EE079453; Thu, 1 Apr 2021 13:53:54 +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 A20E94A7CB; Thu, 1 Apr 2021 13:53:53 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 131Dr8W6023154 for ; Thu, 1 Apr 2021 09:53:08 -0400 Received: by smtp.corp.redhat.com (Postfix) id 94EDA5C5FC; Thu, 1 Apr 2021 13:53:08 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.33]) by smtp.corp.redhat.com (Postfix) with ESMTP id EFCDF5C649 for ; Thu, 1 Apr 2021 13:53:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1617285244; 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=tnTE5Pr0o0DYB3qerqxRL+g8gOd577uExLVeke26i0E=; b=Ks2ZLAFcnSRVXRzccoXWvsHD2SAYwxAMQNOPMvqxTQ/rPdyhgdqENo/eUSFnzRXMCBff2M Aj6KV6FHWZNrnprq1trZwc8K5WxtYniUhuMxEkhLqLE0B7Edg4oAPVbwmxIcFLPTLetz30 02/LW/h4icQvzGYOOoPo7GLdoK3Thzs= X-MC-Unique: K6IMNAVDMgi23eQ8bOYKGg-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 10/39] virStorageFileParseBackingStoreStr: use g_strsplit instead of virStringSplitCount Date: Thu, 1 Apr 2021 15:52:09 +0200 Message-Id: <38cadcdd346160629d9531c8e0be085a49841c81.1617285119.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 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 presence of the second element can be checked by looking at it directly. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/util/virstoragefile.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/util/virstoragefile.c b/src/util/virstoragefile.c index e6bc723d1e..e3ec64486e 100644 --- a/src/util/virstoragefile.c +++ b/src/util/virstoragefile.c @@ -192,17 +192,16 @@ virStorageFileParseBackingStoreStr(const char *str, char **target, unsigned int *chainIndex) { - size_t nstrings; unsigned int idx =3D 0; char *suffix; g_auto(GStrv) strings =3D NULL; *chainIndex =3D 0; - if (!(strings =3D virStringSplitCount(str, "[", 2, &nstrings))) + if (!(strings =3D g_strsplit(str, "[", 2))) return -1; - if (nstrings =3D=3D 2) { + if (strings[0] && strings[1]) { if (virStrToLong_uip(strings[1], &suffix, 10, &idx) < 0 || STRNEQ(suffix, "]")) return -1; --=20 2.29.2 From nobody Mon Feb 9 10:24:32 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1617285329; cv=none; d=zohomail.com; s=zohoarc; b=JHmedMI547o9WzVbzMasqsjY6aLVDTQKHcyY0+rEmLIWEYilNJ/YhbyyjLKQ+ha8xfME48E3XaaW6XRkVHrzp+ReTndurV51HxYhsbcliOgvmU+NUyTEZ/xhao2sGnAPVNBVOtJ+N1WAwbF6E+9KQM5n15y+fHTE4gX3QeiLPeg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1617285329; 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=H1F8EQZ49b5Cutw+wVcUwonbzmv85YeAjtWEyk2Op1g=; b=W4yw0lFmNgBkQ0KfLgmiH1Uap++HCIX+ytui493KrphJr9CXa1XOus9fjPEVLEjiU7FLHDQL/pXfJ0H+G5spXubj+a468eN1c0htpxD4GZz/3HwrR2OIT6qCJ1nxoT3T+A8MBPt9D4q2B7K0OVFGSRSro2PBhoGiEfO3XNu0paY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 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-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mx.zohomail.com with SMTPS id 161728532908464.51260237768099; Thu, 1 Apr 2021 06:55: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-559-broHgVq5McewpPMm_vrMsw-1; Thu, 01 Apr 2021 09:55:23 -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 A84AF9125B; Thu, 1 Apr 2021 13:54:41 +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 815715D9CC; Thu, 1 Apr 2021 13:54:41 +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 430A5180B451; Thu, 1 Apr 2021 13:54:41 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 131DrCoi023174 for ; Thu, 1 Apr 2021 09:53:12 -0400 Received: by smtp.corp.redhat.com (Postfix) id AC67D5C649; Thu, 1 Apr 2021 13:53:12 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.33]) by smtp.corp.redhat.com (Postfix) with ESMTP id 119B45C5FC for ; Thu, 1 Apr 2021 13:53:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1617285326; 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=H1F8EQZ49b5Cutw+wVcUwonbzmv85YeAjtWEyk2Op1g=; b=iGFRCsuU2Nwbb7Ow6rjoEOdshZK+/WoxB4XvYMQ9q6Zt4M3ScUTbLN1FDtgkTfnxdqCm4s 9z/LNj83E/Yys8sshCOyS0bIMCo2APDycyWIWBgyg0qocxAaiahX9uqcyD6BGSYgotX5uM h8UK4+YvZyN8pbDzqoV6JURK5dW4qgM= X-MC-Unique: broHgVq5McewpPMm_vrMsw-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 11/39] util: virlog: Use g_auto(GStrv) instead of g_strfreev in cleanup section Date: Thu, 1 Apr 2021 15:52:10 +0200 Message-Id: <3e34e983a7edfa8fb6a7ec468516ae75ee3d8ccf.1617285119.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 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: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/util/virlog.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/src/util/virlog.c b/src/util/virlog.c index 934c96915b..4782f6f27d 100644 --- a/src/util/virlog.c +++ b/src/util/virlog.c @@ -1459,7 +1459,7 @@ virLogOutputPtr virLogParseOutput(const char *src) { virLogOutputPtr ret =3D NULL; - char **tokens =3D NULL; + g_auto(GStrv) tokens =3D NULL; char *abspath =3D NULL; size_t count =3D 0; virLogPriority prio; @@ -1526,7 +1526,6 @@ virLogParseOutput(const char *src) } cleanup: - g_strfreev(tokens); return ret; } @@ -1561,7 +1560,7 @@ virLogParseFilter(const char *src) virLogFilterPtr ret =3D NULL; size_t count =3D 0; virLogPriority prio; - char **tokens =3D NULL; + g_auto(GStrv) tokens =3D NULL; char *match =3D NULL; VIR_DEBUG("filter=3D%s", src); @@ -1601,7 +1600,6 @@ virLogParseFilter(const char *src) goto cleanup; cleanup: - g_strfreev(tokens); return ret; } @@ -1623,7 +1621,7 @@ virLogParseOutputs(const char *src, virLogOutputPtr *= *outputs) int at =3D -1; size_t noutputs =3D 0; size_t i, count; - char **strings =3D NULL; + g_auto(GStrv) strings =3D NULL; virLogOutputPtr output =3D NULL; virLogOutputPtr *list =3D NULL; @@ -1660,7 +1658,6 @@ virLogParseOutputs(const char *src, virLogOutputPtr *= *outputs) ret =3D noutputs; *outputs =3D g_steal_pointer(&list); cleanup: - g_strfreev(strings); return ret; } @@ -1683,7 +1680,7 @@ virLogParseFilters(const char *src, virLogFilterPtr *= *filters) int ret =3D -1; size_t nfilters =3D 0; size_t i, count; - char **strings =3D NULL; + g_auto(GStrv) strings =3D NULL; virLogFilterPtr filter =3D NULL; virLogFilterPtr *list =3D NULL; @@ -1709,7 +1706,6 @@ virLogParseFilters(const char *src, virLogFilterPtr *= *filters) ret =3D nfilters; *filters =3D g_steal_pointer(&list); cleanup: - g_strfreev(strings); return ret; } --=20 2.29.2 From nobody Mon Feb 9 10:24:32 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1617285427; cv=none; d=zohomail.com; s=zohoarc; b=gN9fBImsvbefNEnStU41RgnfidErNSzlBCnSprvTjqkJTG+/d8UqBBOK2LggNQmtpprhiAlCbhEJvL1AQ5FURkyePGQO5BMQoJojhk+XT1cACfnznrg0D8DZM/wrw27lE2fhyd/2bS62W5XLycJKHIFP5l5e+enn4QtNs9g1Fyw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1617285427; 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=qARwQdJITkWY5aJVoY2kELB+BOfQTx4IvRoVXOaqMAM=; b=Fhclnx9SPE/qVTU9dA9PH5+H7eKgaCJjEk1WNXOLl1a6G7lupiksZ4iCA8t5K1MNZLty8ahii+TCwphWZFWX48zgX43KKO2CZOfuxN5YZdgrxo+vG+cEHnVi7uwhJCqmJitltDdAvQgBDgS5IlYn5oV8slZApRW+Qdspxa40Al4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 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-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mx.zohomail.com with SMTPS id 1617285427052860.019216393626; Thu, 1 Apr 2021 06:57: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-228-AkI3D2fCNZiHSOY0-V4Pfg-1; Thu, 01 Apr 2021 09:54:55 -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 E2106192298D; Thu, 1 Apr 2021 13:54:44 +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 B7B57424D; Thu, 1 Apr 2021 13:54:44 +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 6982A4A700; Thu, 1 Apr 2021 13:54:44 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 131DrGC0023192 for ; Thu, 1 Apr 2021 09:53:16 -0400 Received: by smtp.corp.redhat.com (Postfix) id 9CFCE5F9C5; Thu, 1 Apr 2021 13:53:16 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.33]) by smtp.corp.redhat.com (Postfix) with ESMTP id 095C95F705 for ; Thu, 1 Apr 2021 13:53:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1617285426; 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=qARwQdJITkWY5aJVoY2kELB+BOfQTx4IvRoVXOaqMAM=; b=dbq3fiEQBCaMSEc7+Cbc0XbKLB45S/+3ifw7c6ldUA5FnCI5fzIJW8MpBC1q+CGa7m/QU6 XZ8ujAHaqIIqeSDqR+nthBrAOm+uBLKuNJkp0MWljR20CctMecqLfoEQOFnIIm8PPDvObH ghInM8Ax7JwZOA2BMIhjbKz60TtkRRc= X-MC-Unique: AkI3D2fCNZiHSOY0-V4Pfg-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 12/39] util: virlog: Remove pointless 'cleanup' labels Date: Thu, 1 Apr 2021 15:52:11 +0200 Message-Id: <38760b6571999b7c53efd640dbc45afbc7607e04.1617285119.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 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" Previous refactors left empty cleanup labels. Remove them. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/util/virlog.c | 47 +++++++++++++++++------------------------------ 1 file changed, 17 insertions(+), 30 deletions(-) diff --git a/src/util/virlog.c b/src/util/virlog.c index 4782f6f27d..004792db01 100644 --- a/src/util/virlog.c +++ b/src/util/virlog.c @@ -1473,7 +1473,7 @@ virLogParseOutput(const char *src) if (!(tokens =3D virStringSplitCount(src, ":", 0, &count)) || count < = 2) { virReportError(VIR_ERR_INVALID_ARG, _("Malformed format for output '%s'"), src); - goto cleanup; + return NULL; } if (virStrToLong_uip(tokens[0], NULL, 10, &prio) < 0 || @@ -1481,14 +1481,14 @@ virLogParseOutput(const char *src) virReportError(VIR_ERR_INVALID_ARG, _("Invalid priority '%s' for output '%s'"), tokens[0], src); - goto cleanup; + return NULL; } if ((dest =3D virLogDestinationTypeFromString(tokens[1])) < 0) { virReportError(VIR_ERR_INVALID_ARG, _("Invalid destination '%s' for output '%s'"), tokens[1], src); - goto cleanup; + return NULL; } if (((dest =3D=3D VIR_LOG_TO_STDERR || @@ -1498,7 +1498,7 @@ virLogParseOutput(const char *src) virReportError(VIR_ERR_INVALID_ARG, _("Output '%s' does not meet the format requirement= s " "for destination type '%s'"), src, tokens[1]); - goto cleanup; + return NULL; } switch ((virLogDestination) dest) { @@ -1512,7 +1512,7 @@ virLogParseOutput(const char *src) break; case VIR_LOG_TO_FILE: if (virFileAbsPath(tokens[2], &abspath) < 0) - goto cleanup; + return NULL; ret =3D virLogNewOutputToFile(prio, abspath); VIR_FREE(abspath); break; @@ -1525,7 +1525,6 @@ virLogParseOutput(const char *src) break; } - cleanup: return ret; } @@ -1557,7 +1556,6 @@ virLogParseOutput(const char *src) virLogFilterPtr virLogParseFilter(const char *src) { - virLogFilterPtr ret =3D NULL; size_t count =3D 0; virLogPriority prio; g_auto(GStrv) tokens =3D NULL; @@ -1569,7 +1567,7 @@ virLogParseFilter(const char *src) if (!(tokens =3D virStringSplitCount(src, ":", 0, &count)) || count != =3D 2) { virReportError(VIR_ERR_INVALID_ARG, _("Malformed format for filter '%s'"), src); - goto cleanup; + return NULL; } if (virStrToLong_uip(tokens[0], NULL, 10, &prio) < 0 || @@ -1577,7 +1575,7 @@ virLogParseFilter(const char *src) virReportError(VIR_ERR_INVALID_ARG, _("Invalid priority '%s' for filter '%s'"), tokens[0], src); - goto cleanup; + return NULL; } match =3D tokens[1]; @@ -1592,15 +1590,10 @@ virLogParseFilter(const char *src) if (!*match) { virReportError(VIR_ERR_INVALID_ARG, _("Invalid match string '%s'"), tokens[1]); - - goto cleanup; + return NULL; } - if (!(ret =3D virLogFilterNew(match, prio))) - goto cleanup; - - cleanup: - return ret; + return virLogFilterNew(match, prio); } /** @@ -1617,7 +1610,6 @@ virLogParseFilter(const char *src) int virLogParseOutputs(const char *src, virLogOutputPtr **outputs) { - int ret =3D -1; int at =3D -1; size_t noutputs =3D 0; size_t i, count; @@ -1628,7 +1620,7 @@ virLogParseOutputs(const char *src, virLogOutputPtr *= *outputs) VIR_DEBUG("outputs=3D%s", src); if (!(strings =3D virStringSplitCount(src, " ", 0, &count))) - goto cleanup; + return -1; for (i =3D 0; i < count; i++) { /* virStringSplit may return empty strings */ @@ -1636,7 +1628,7 @@ virLogParseOutputs(const char *src, virLogOutputPtr *= *outputs) continue; if (!(output =3D virLogParseOutput(strings[i]))) - goto cleanup; + return -1; /* let's check if a duplicate output does not already exist in whi= ch * case we need to replace it with its last occurrence, however, r= ather @@ -1647,7 +1639,7 @@ virLogParseOutputs(const char *src, virLogOutputPtr *= *outputs) at =3D virLogFindOutput(list, noutputs, output->dest, output->name= ); if (VIR_APPEND_ELEMENT(list, noutputs, output) < 0) { virLogOutputFree(output); - goto cleanup; + return -1; } if (at >=3D 0) { virLogOutputFree(list[at]); @@ -1655,10 +1647,8 @@ virLogParseOutputs(const char *src, virLogOutputPtr = **outputs) } } - ret =3D noutputs; *outputs =3D g_steal_pointer(&list); - cleanup: - return ret; + return noutputs; } /** @@ -1677,7 +1667,6 @@ virLogParseOutputs(const char *src, virLogOutputPtr *= *outputs) int virLogParseFilters(const char *src, virLogFilterPtr **filters) { - int ret =3D -1; size_t nfilters =3D 0; size_t i, count; g_auto(GStrv) strings =3D NULL; @@ -1687,7 +1676,7 @@ virLogParseFilters(const char *src, virLogFilterPtr *= *filters) VIR_DEBUG("filters=3D%s", src); if (!(strings =3D virStringSplitCount(src, " ", 0, &count))) - goto cleanup; + return -1; for (i =3D 0; i < count; i++) { /* virStringSplit may return empty strings */ @@ -1695,18 +1684,16 @@ virLogParseFilters(const char *src, virLogFilterPtr= **filters) continue; if (!(filter =3D virLogParseFilter(strings[i]))) - goto cleanup; + return -1; if (VIR_APPEND_ELEMENT(list, nfilters, filter)) { virLogFilterFree(filter); - goto cleanup; + return -1; } } - ret =3D nfilters; *filters =3D g_steal_pointer(&list); - cleanup: - return ret; + return nfilters; } /** --=20 2.29.2 From nobody Mon Feb 9 10:24:32 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1617285547; cv=none; d=zohomail.com; s=zohoarc; b=YtaFubDfhqwL0W05VOFiMiRxOu38okg55g3bu+nT8zOK+kNbTmubcNYlJQUDLBQ3MRmGYKrVSWq0kKC0sPdY7LtGYRePoRthdr5lyhV4W8k3OGmXyhrB86cqiSXo8cvWBHlIpwinJFov4TTSkH0i5eRZOXirgragRtmRaoUZe8c= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1617285547; 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=vEmMIHwLh4GhTaEQo23JoUyt5eUQGvVdtAiHw/ratyg=; b=EAYaYuxc3fr/NOj5wpb4dd2QUel7f363sndr+8Muiy5VxHfEejj4ga5K+7a7k2AXH/KnZS9WfokoC0qg+8NgkpCpnw+OJNlNqVwL+xas9gKCGhXe+sF1ux5Kgy+7u/VexSqdD9jkHV0gUo2OM/eoUBJKJdX9EyZPRvQWGEYG1NA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 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-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mx.zohomail.com with SMTPS id 1617285547236122.22941158629305; Thu, 1 Apr 2021 06:59: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-349-qow_67moNoaToKi7Ts_wWQ-1; Thu, 01 Apr 2021 09:54:08 -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 251CA9CC38; Thu, 1 Apr 2021 13:53:58 +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 A2EC3795A7; Thu, 1 Apr 2021 13:53:56 +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 041A8180B763; Thu, 1 Apr 2021 13:53:56 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 131DrQpP023211 for ; Thu, 1 Apr 2021 09:53:26 -0400 Received: by smtp.corp.redhat.com (Postfix) id D3D565F705; Thu, 1 Apr 2021 13:53:26 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.33]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3719A764F2 for ; Thu, 1 Apr 2021 13:53:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1617285546; 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=vEmMIHwLh4GhTaEQo23JoUyt5eUQGvVdtAiHw/ratyg=; b=fUozEit/QmrZnwSSA1PtLgSU7FfgB4cLBpfF2cLhHY0gEp6dOnU+rIADQXZk4zOVJcEfdz Ziqb1sg2iboqHmyM5QSogQvGEhFQZ8FzJ2hWD31seK8GoaeXbQwlGxZoy3GxGYiTOXDoY6 AlwkM6KOENvg2KWk8nKYKZiwgFSTglw= X-MC-Unique: qow_67moNoaToKi7Ts_wWQ-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 13/39] virLogParseOutputs: Refactor string list handling Date: Thu, 1 Apr 2021 15:52:12 +0200 Message-Id: <8ffb31d1f53fc55fe459696462823df145b34bcd.1617285119.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 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" Rewrite the code to remove the need to calculate the string list count. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/util/virlog.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/util/virlog.c b/src/util/virlog.c index 004792db01..56059f62f1 100644 --- a/src/util/virlog.c +++ b/src/util/virlog.c @@ -1612,22 +1612,22 @@ virLogParseOutputs(const char *src, virLogOutputPtr= **outputs) { int at =3D -1; size_t noutputs =3D 0; - size_t i, count; g_auto(GStrv) strings =3D NULL; + GStrv next; virLogOutputPtr output =3D NULL; virLogOutputPtr *list =3D NULL; VIR_DEBUG("outputs=3D%s", src); - if (!(strings =3D virStringSplitCount(src, " ", 0, &count))) + if (!(strings =3D g_strsplit(src, " ", 0))) return -1; - for (i =3D 0; i < count; i++) { + for (next =3D strings; *next; next++) { /* virStringSplit may return empty strings */ - if (STREQ(strings[i], "")) + if (STREQ(*next, "")) continue; - if (!(output =3D virLogParseOutput(strings[i]))) + if (!(output =3D virLogParseOutput(*next))) return -1; /* let's check if a duplicate output does not already exist in whi= ch --=20 2.29.2 From nobody Mon Feb 9 10:24:32 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1617285308; cv=none; d=zohomail.com; s=zohoarc; b=CVbGokPlMjufNGW2oSSkpz+wKfxYqqSje7FTUwyDnhatz1fhoWrvcVBgIWZCNUoz5HOn0skJbNztViFbHcoR7FIcZ74FZOYxWAqQ0LCzZC9kP030LxvFi85HkO0rBQYrUFKnEYctoAhWsK8BcrOxOjQ9szqGyxgaCgTdgvvGzAo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1617285308; 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=Y1DBrOgOn11Lkn6d58B4M+5EapuqaCYxrTSMf/+Rm68=; b=fcGzXTYDAaeeBPxYFZASLjpm+a+6CjQabctsg1e2LLFuKtJXtcK4OL/iF7ntZEOfImPFHCuCW66HU1jkz8nEeMyiC9Twu2HATxckULIUna/ei2JLMh5mSX8ufkm6lGgQUzs+6bcWXMc2lFmqIMREKf/SK3twByp8dJAvqvnnEvw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 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-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mx.zohomail.com with SMTPS id 1617285308621136.7983534583309; Thu, 1 Apr 2021 06:55: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-342-WTsodEDTN-6Bzn7_5chpww-1; Thu, 01 Apr 2021 09:54:56 -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 7C83319251A8; Thu, 1 Apr 2021 13:54:48 +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 585425D6B1; Thu, 1 Apr 2021 13:54: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 112C44A701; Thu, 1 Apr 2021 13:54:48 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 131DruRf023251 for ; Thu, 1 Apr 2021 09:53:56 -0400 Received: by smtp.corp.redhat.com (Postfix) id 719EC79583; Thu, 1 Apr 2021 13:53:55 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.33]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8B77879824 for ; Thu, 1 Apr 2021 13:53:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1617285307; 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=Y1DBrOgOn11Lkn6d58B4M+5EapuqaCYxrTSMf/+Rm68=; b=UoJTrilZ2zMLdIWKxdbt/p3RCnoyBON1b/rpzG9x+xi3lffnrgdEACJWdi2oplXcqvxzIy vpxCl8hXC4yQ5Y+HvU/fGPqza74iabsAC/reOy75V0tzAe+G6K5d0z7tQ2P/+ndV3VJyXw FJByfDmyK6iPUitoaSwOzE7phw0G91E= X-MC-Unique: WTsodEDTN-6Bzn7_5chpww-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 14/39] virLogParseFilters: Refactor string list handling Date: Thu, 1 Apr 2021 15:52:13 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 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" Rewrite the code to remove the need to calculate the string list count. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/util/virlog.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/util/virlog.c b/src/util/virlog.c index 56059f62f1..57eb0de538 100644 --- a/src/util/virlog.c +++ b/src/util/virlog.c @@ -1668,22 +1668,22 @@ int virLogParseFilters(const char *src, virLogFilterPtr **filters) { size_t nfilters =3D 0; - size_t i, count; g_auto(GStrv) strings =3D NULL; + GStrv next; virLogFilterPtr filter =3D NULL; virLogFilterPtr *list =3D NULL; VIR_DEBUG("filters=3D%s", src); - if (!(strings =3D virStringSplitCount(src, " ", 0, &count))) + if (!(strings =3D g_strsplit(src, " ", 0))) return -1; - for (i =3D 0; i < count; i++) { + for (next =3D strings; *next; next++) { /* virStringSplit may return empty strings */ - if (STREQ(strings[i], "")) + if (STREQ(*next, "")) continue; - if (!(filter =3D virLogParseFilter(strings[i]))) + if (!(filter =3D virLogParseFilter(*next))) return -1; if (VIR_APPEND_ELEMENT(list, nfilters, filter)) { --=20 2.29.2 From nobody Mon Feb 9 10:24:32 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1617285377; cv=none; d=zohomail.com; s=zohoarc; b=kXj28dKxtf+1oGAI12viXYG3Ye5asVHjUzVEyLDVWy0O5ReCpbuVig1PY0FgNAxnG6/mNvOmbioNq99EbiuRSD7qVvpVExmdKc822y55+MzS3aO54Pmq8j7NF50sjelLojdPr9k64DpT+FQPYJnCObpyOWzI+8qbWlDGXmQvh1I= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1617285377; 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=e2YJMXl+ExqKEKVhP32VAEz6KLQuYA5qDFQ6vg1b+f0=; b=GMCHk1/BxRQ+ZQmrDtCkghlQFvFFv1DvDzm+WXV2G4bPLkbHSWJh7H66i4/BsdWP5QcmZrQgR5o9JGQG/aKsrxwwbAKsAvyS9U3uzxfF+fIguXJFf8Zbc6nDDKOMy58ggwW91ejFo4J6vnn/CjKVyY9LtuQt30mCDDYlol6cxAY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 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-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mx.zohomail.com with SMTPS id 1617285377590449.83344322986795; Thu, 1 Apr 2021 06:56:17 -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-603-NrQ1TdDJM7eWDlJF2zwEUw-1; Thu, 01 Apr 2021 09:54:15 -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 0EAFDCC639; Thu, 1 Apr 2021 13:54:01 +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 5FE0776E39; Thu, 1 Apr 2021 13:54:00 +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 EDE7A18155DD; Thu, 1 Apr 2021 13:53:59 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 131DrxtV023276 for ; Thu, 1 Apr 2021 09:53:59 -0400 Received: by smtp.corp.redhat.com (Postfix) id 61D59794D8; Thu, 1 Apr 2021 13:53:57 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.33]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9DB23795B4 for ; Thu, 1 Apr 2021 13:53:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1617285376; 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=e2YJMXl+ExqKEKVhP32VAEz6KLQuYA5qDFQ6vg1b+f0=; b=MTzWdiVYDnP6bho1TF+YuLno5xcRvgWuv26Iz/u8rjwujUdCJhtL7ufHp7tp5Ah6YEOoxN 7QMBAXvPyxYIotpzTJbsyh2uMKZOaRkHEYo8qK+Nwf8otfR1WZxRwI5zYZL4nXE/PPjFfG RFzNL1fjjdf7TjTg4iLVKALjT5MmAms= X-MC-Unique: NrQ1TdDJM7eWDlJF2zwEUw-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 15/39] virLogParseFilter: Replace virStringSplitCount by g_strsplit Date: Thu, 1 Apr 2021 15:52:14 +0200 Message-Id: <39e57196edab90441e3408342d25b404bb86b900.1617285119.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 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" We don't really need the count. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/util/virlog.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/util/virlog.c b/src/util/virlog.c index 57eb0de538..8a4cfbfdc2 100644 --- a/src/util/virlog.c +++ b/src/util/virlog.c @@ -1556,7 +1556,6 @@ virLogParseOutput(const char *src) virLogFilterPtr virLogParseFilter(const char *src) { - size_t count =3D 0; virLogPriority prio; g_auto(GStrv) tokens =3D NULL; char *match =3D NULL; @@ -1564,7 +1563,8 @@ virLogParseFilter(const char *src) VIR_DEBUG("filter=3D%s", src); /* split our format prio:match_str to tokens and parse them individual= ly */ - if (!(tokens =3D virStringSplitCount(src, ":", 0, &count)) || count != =3D 2) { + if (!(tokens =3D g_strsplit(src, ":", 0)) || + !tokens[0] || !tokens[1]) { virReportError(VIR_ERR_INVALID_ARG, _("Malformed format for filter '%s'"), src); return NULL; --=20 2.29.2 From nobody Mon Feb 9 10:24:32 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1617285264; cv=none; d=zohomail.com; s=zohoarc; b=butoLFEpH0VZH3WRNw4E746JUQLrI1oUPGNUJr6PwMcP8Xr2jAZQQvq14R2VlN9rXnsamXuJXGNKnULATPJmK5BrFKz/n6TrHEzHlZKvmJ3/dk90vCuGWqrIhES3fU+8mQ/RXxyuJeUoWJ3er3mwyxhQqQy+B5Z53p4pfIGbgJQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1617285264; 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=cf3XGOOjQTLb2J9htFw1hKhub6/o7igYwS594ill2D4=; b=nDxyBnuaq5hNJQCirrXZscrezMVLN74GOkp8Sb0actolgTIY+WyGizK5fOtkhXyGNyA9SIPDfWAB9k92emDS2PNEQg2C12yRLQnNKEtHVnlkH0CwLHuyRJ1WnEIvH4IcUTRcS5hTo9OEx3JDSoAfE6+2XjlZBHkjgn+9qha+Nzk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 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-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mx.zohomail.com with SMTPS id 1617285264600293.714451666316; Thu, 1 Apr 2021 06:54:24 -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-515-G4U40WIbMvOaUrEYfXu9cw-1; Thu, 01 Apr 2021 09:54:21 -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 E38951005D69; Thu, 1 Apr 2021 13:54: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 AF8875C1A1; Thu, 1 Apr 2021 13:54: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 4E9491802138; Thu, 1 Apr 2021 13:54:05 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 131DrxrC023284 for ; Thu, 1 Apr 2021 09:53:59 -0400 Received: by smtp.corp.redhat.com (Postfix) id 5FDC3795BB; Thu, 1 Apr 2021 13:53:58 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.33]) by smtp.corp.redhat.com (Postfix) with ESMTP id D237179800 for ; Thu, 1 Apr 2021 13:53:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1617285263; 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=cf3XGOOjQTLb2J9htFw1hKhub6/o7igYwS594ill2D4=; b=VO/bViNqBC98NnjWz4lDtTeEcM2CRX5x1qzqz2kEIpQSh6opjFet3RoELX+GA1eLLP/ifY ibxdp2FwTgmJaX9t9ysxnzhfsrRd2LJmHCmwM+Q6wCo5pBCO3qLE17aQwD4nz0sr4QYJdG lWMfaHlcjhzvP9DQWZdmtRNNew0tE18= X-MC-Unique: G4U40WIbMvOaUrEYfXu9cw-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 16/39] virLogParseOutput: Replace virStringSplitCount by g_strsplit Date: Thu, 1 Apr 2021 15:52:15 +0200 Message-Id: <9b0bd577bd98bc54f15268387562aa693b153c34.1617285119.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 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" Unfortunately here we do need the count of elements. Use g_strv_length to calculate it so that virStringSplitCount can be removed later. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/util/virlog.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/util/virlog.c b/src/util/virlog.c index 8a4cfbfdc2..3fb27fcb25 100644 --- a/src/util/virlog.c +++ b/src/util/virlog.c @@ -1470,7 +1470,8 @@ virLogParseOutput(const char *src) /* split our format prio:destination:additional_data to tokens and par= se * them individually */ - if (!(tokens =3D virStringSplitCount(src, ":", 0, &count)) || count < = 2) { + if (!(tokens =3D g_strsplit(src, ":", 0)) || + (count =3D g_strv_length(tokens))< 2) { virReportError(VIR_ERR_INVALID_ARG, _("Malformed format for output '%s'"), src); return NULL; --=20 2.29.2 From nobody Mon Feb 9 10:24:32 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) client-ip=63.128.21.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1617285300; cv=none; d=zohomail.com; s=zohoarc; b=Wp1o0ad0drCZv641X8Y9eSU0hqiyQ92P4k0k2zAjADpO2MWVRT1ZPFM9/6oUVoA3GtbkD7eeIm+tGYVXqSutcBRbbn35MIJPHKaHVUqZEYdmP/KlMVpwYq9Nw4secrq/nWh/TvMuSgMVfu1oZc6dyZZk/twW/7EfpA7bbHlb/s8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1617285300; 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=nmk73VYiiGMWhbkpZZUsYYfQoqjQFy3jEFExa9IeJbY=; b=ZeuBXuUObChbZt5vBBm3UKf9oXOjFgHmJHX3b/2zlEVly8NsC2DigcyrZ8F12xtHbtzl+ua50/TUAXqL9uXMsbc2qFWHsKmp7Ypzn+UlV54I9w1walXyY6Io1QAVhAFyL9L4lyH5L7KoItbSXzUuWXa055a6X7jgRyLcbAUwPJM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.124 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-124.mimecast.com (us-smtp-delivery-124.mimecast.com [63.128.21.124]) by mx.zohomail.com with SMTPS id 1617285300035549.7531405162732; Thu, 1 Apr 2021 06:55:00 -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-498-ghjdBHrlNzG4wULo2OYjzA-1; Thu, 01 Apr 2021 09:54:56 -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 DD93E19251C1; Thu, 1 Apr 2021 13:54:51 +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 B66FA424D; Thu, 1 Apr 2021 13:54:51 +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 7818B4A700; Thu, 1 Apr 2021 13:54:51 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 131Ds1N2023299 for ; Thu, 1 Apr 2021 09:54:01 -0400 Received: by smtp.corp.redhat.com (Postfix) id 616107945F; Thu, 1 Apr 2021 13:54:00 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.33]) by smtp.corp.redhat.com (Postfix) with ESMTP id E2529795B4 for ; Thu, 1 Apr 2021 13:53:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1617285299; 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=nmk73VYiiGMWhbkpZZUsYYfQoqjQFy3jEFExa9IeJbY=; b=OR0+Xvx9t4ZWdE0PiyqGZYkGRruYc9+7ARZVCIel3sf7EZQwL7HD+yURP1+oaBI5uq4s3Z v3nhoTtCYdtwLPEKgwWWCXnBj8hkIVyEcxMKVMQmIsVw6YXLGVFya2DmaLVWGVScO51hSk fuUQ8Vxe9qGpXBvHgJ4mRWG5DgXDki8= X-MC-Unique: ghjdBHrlNzG4wULo2OYjzA-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 17/39] virshParseEventStr: Use g_strsplit and automatic memory freeing Date: Thu, 1 Apr 2021 15:52:16 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 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: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- tools/virsh-domain.c | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c index a778421b66..86de4255fa 100644 --- a/tools/virsh-domain.c +++ b/tools/virsh-domain.c @@ -9342,24 +9342,21 @@ virshParseEventStr(const char *event, int *nparams, int *maxparams) { - char **tok =3D NULL; - size_t i, ntok; - int ret =3D -1; + g_auto(GStrv) tok =3D NULL; + GStrv next; - if (!(tok =3D virStringSplitCount(event, ",", 0, &ntok))) + if (!(tok =3D g_strsplit(event, ",", 0))) return -1; - for (i =3D 0; i < ntok; i++) { - if ((*tok[i] !=3D '\0') && - virTypedParamsAddBoolean(params, nparams, - maxparams, tok[i], state) < 0) - goto cleanup; + for (next =3D tok; *next; next++) { + if (*next[0] =3D=3D '\0') + continue; + + if (virTypedParamsAddBoolean(params, nparams, maxparams, *next, st= ate) < 0) + return -1; } - ret =3D 0; - cleanup: - g_strfreev(tok); - return ret; + return 0; } static void --=20 2.29.2 From nobody Mon Feb 9 10:24:32 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) client-ip=63.128.21.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1617285290; cv=none; d=zohomail.com; s=zohoarc; b=nZwu0VTJFeMmL2kC3um920/yLTpd03Y4m8a9LPxpzAALajQhLZYkebiu/8qQFXrfmf77iUTA3Dt332LXUGiCLwzAZFJMZNDM/RWl/OlVtMh/TJO9vfqqyrR7PJE6ilswjATleYDZxnTBRuHdBcPJG9p3cPke7qnY4w2bojXDGT4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1617285290; 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=2llKg1z1UNs1nX1LC+uGH+wJB5vr/4i5KNVhyIhlIVY=; b=oAfmkS0pLVPp4m86nyOpYz8t9rJXDO0skYr2mgFVjJyI1M24BZDsgCuMbsYi/T/39TdsFej0jO/QwiKH7DYX/Z/zuyT81C0yXnCwXrXAhS3vn4OjxAAOrxm1/KcBYLGTZwFILFR36aN4C8RwguGyFavCsKKqd2P2RyWc+/A3C4w= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.124 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-124.mimecast.com (us-smtp-delivery-124.mimecast.com [63.128.21.124]) by mx.zohomail.com with SMTPS id 1617285290878312.6096666220801; Thu, 1 Apr 2021 06:54:50 -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-474-QdnctE-6OpK4JeuWUmPrJw-1; Thu, 01 Apr 2021 09:54:47 -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 3CB4CDF8A0; Thu, 1 Apr 2021 13:54:10 +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 08C855D6B1; Thu, 1 Apr 2021 13:54:10 +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 9EF7E1802139; Thu, 1 Apr 2021 13:54:09 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 131Ds17S023324 for ; Thu, 1 Apr 2021 09:54:01 -0400 Received: by smtp.corp.redhat.com (Postfix) id D1AFC79C6E; Thu, 1 Apr 2021 13:54:01 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.33]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2BA9C79C76 for ; Thu, 1 Apr 2021 13:53:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1617285289; 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=2llKg1z1UNs1nX1LC+uGH+wJB5vr/4i5KNVhyIhlIVY=; b=LzHgYdPYV4uc2yHiyejCJ1rpqfKh2WM6kiBdk/i7Oaey78vMB2z6sV/9gvSKPQtCJceorN b0lixRjYFkL59Zxxuv9Xdo8XzInW6ZCmKArNid5leW7xLMQzbBbQCSn2jL3jRrOrAuQj49 wo07A0D+Z1GoSmgrid8RKwd6ro6lHAM= X-MC-Unique: QdnctE-6OpK4JeuWUmPrJw-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 18/39] bhyveParsePCIFbuf: Use g_strsplit instead of virStringSplitCount Date: Thu, 1 Apr 2021 15:52:17 +0200 Message-Id: <9fbc344893d8a1f7e5baffcb097aeca570209369.1617285119.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 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: Peter Krempa --- src/bhyve/bhyve_parse_command.c | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/src/bhyve/bhyve_parse_command.c b/src/bhyve/bhyve_parse_comman= d.c index 70f5ac42a0..d86d37b697 100644 --- a/src/bhyve/bhyve_parse_command.c +++ b/src/bhyve/bhyve_parse_command.c @@ -558,10 +558,8 @@ bhyveParsePCIFbuf(virDomainDefPtr def, virDomainVideoDefPtr video =3D NULL; virDomainGraphicsDefPtr graphics =3D NULL; - char **params =3D NULL; - char *param =3D NULL, *separator =3D NULL; - size_t nparams =3D 0; - size_t i =3D 0; + g_auto(GStrv) **params =3D NULL; + GStrv next; if (!(video =3D virDomainVideoDefNew(xmlopt))) goto cleanup; @@ -579,11 +577,11 @@ bhyveParsePCIFbuf(virDomainDefPtr def, if (!config) goto error; - if (!(params =3D virStringSplitCount(config, ",", 0, &nparams))) + if (!(params =3D g_strsplit(config, ",", 0))) goto error; - for (i =3D 0; i < nparams; i++) { - param =3D params[i]; + for (next =3D params; *next; next++) { + char *param =3D *next; if (!video->driver) video->driver =3D g_new0(virDomainVideoDriverDef, 1); @@ -649,13 +647,11 @@ bhyveParsePCIFbuf(virDomainDefPtr def, if (VIR_APPEND_ELEMENT(def->graphics, def->ngraphics, graphics) < 0) goto error; - g_strfreev(params); return 0; error: virDomainVideoDefFree(video); virDomainGraphicsDefFree(graphics); - g_strfreev(params); return -1; } --=20 2.29.2 From nobody Mon Feb 9 10:24:32 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1617285276; cv=none; d=zohomail.com; s=zohoarc; b=banTMPcRIUn6aw//zMKK/81TGdClDTC0wfs8JA4W8TYHRqkBXvoZBYcSV8UABxuIe6nXO/xOPxFuT3C8b24IBm5rNMRhznxsCx9G0IoQyoGz1zMwuFB7IWPv2TbNAIdCWpqgCLVu73heXyt1//+V6LYu93gP7gFy2S0rs3sOABo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1617285276; 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=Dp5/gbAWOgoDIkbS1vFJiOzSldHxfsvJWHJr7EpHHjM=; b=lTXj0EsL/HG+wBEJR3GaYsepemnQ0BHFhtlp3lkqm4sdksDJQ05e09QPi8Dc8K/GG/7HVgCVmy1jWYlrkJewfY+vAlrbYn3evHSqh9M8om2A/mr40ke+J0aFIYxg2m47PbcfyCJWqjTC52SCupAd7SutsyaTtAaa5KtgdgGJO7Y= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 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-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1617285276398162.4502941846904; Thu, 1 Apr 2021 06:54: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-132-vi5uYp2nP0O8B7CUcF6GDg-1; Thu, 01 Apr 2021 09:54:32 -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 B50C81011FD2; Thu, 1 Apr 2021 13:54: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 41CCE7C453; Thu, 1 Apr 2021 13:54: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 E8F0E4A7C8; Thu, 1 Apr 2021 13:54:04 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 131Ds3hB023335 for ; Thu, 1 Apr 2021 09:54:03 -0400 Received: by smtp.corp.redhat.com (Postfix) id 57EFE7B6F5; Thu, 1 Apr 2021 13:54:03 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.33]) by smtp.corp.redhat.com (Postfix) with ESMTP id 66E458478E for ; Thu, 1 Apr 2021 13:54:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1617285275; 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=Dp5/gbAWOgoDIkbS1vFJiOzSldHxfsvJWHJr7EpHHjM=; b=HKL4DHjQYS6yGdx60qd71Ly97mhRy18cufEmwBFmK/603XV0BwIEBGoCpvOvSbDpcjVbNV gdFkAJIaiHzeccodHjkZ5P3kc7yN9aZzc0QP98FdZiKQh7UapUhoKWLdDmAZ9o/puNJW+A fzjAW+nzyLUwVRBn2IS2QCyb6M4lEMA= X-MC-Unique: vi5uYp2nP0O8B7CUcF6GDg-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 19/39] virHostValidateGetCPUFlags: Use g_strsplit instead of virStringSplitCount Date: Thu, 1 Apr 2021 15:52:18 +0200 Message-Id: <3492ca4fc782124553587c468bbe40ad353c3809.1617285119.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 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" We don't need the count of elements to iterate the list. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- tools/virt-host-validate-common.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/tools/virt-host-validate-common.c b/tools/virt-host-validate-c= ommon.c index fc43b2ddc8..7e9f5a667c 100644 --- a/tools/virt-host-validate-common.c +++ b/tools/virt-host-validate-common.c @@ -201,9 +201,8 @@ virBitmapPtr virHostValidateGetCPUFlags(void) do { char line[1024]; char *start; - char **tokens; - size_t ntokens; - size_t i; + g_auto(GStrv) tokens =3D NULL; + GStrv next; if (!fgets(line, sizeof(line), fp)) break; @@ -228,20 +227,18 @@ virBitmapPtr virHostValidateGetCPUFlags(void) /* Split the line using " " as a delimiter. The first token * will always be ":", but that's okay */ - if (!(tokens =3D virStringSplitCount(start, " ", 0, &ntokens))) + if (!(tokens =3D g_strsplit(start, " ", 0))) continue; /* Go through all flags and check whether one of those we * might want to check for later on is present; if that's * the case, set the relevant bit in the bitmap */ - for (i =3D 0; i < ntokens; i++) { + for (next =3D tokens; *next; next++) { int value; - if ((value =3D virHostValidateCPUFlagTypeFromString(tokens[i])= ) >=3D 0) + if ((value =3D virHostValidateCPUFlagTypeFromString(*next)) >= =3D 0) ignore_value(virBitmapSetBit(flags, value)); } - - virStringListFreeCount(tokens, ntokens); } while (1); VIR_FORCE_FCLOSE(fp); --=20 2.29.2 From nobody Mon Feb 9 10:24:32 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1617285311; cv=none; d=zohomail.com; s=zohoarc; b=RkpWPdsX+JTFcuvX3coS5hXe3ErLdwlhFeWEXU4HrsAPsrYrsrkzPhG3h20d0OsPn6+WVf4hOBID97Zdf6C9LNUScA6H1o8Do5VCp1wymr7XgAGGGAghQpFuzBeKdvOSArHfOnczUEKQjzaTQQ5v5bEhCWOCYA8jViF6AOER6Ws= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1617285311; 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=ZOSRNVHLLmThwHe7R0qZYDd2wfPfA5094ZEJwFbgd9U=; b=NQevD3YgdJdgKpD45ran4jvxmwJ/B2LgSm+2JeTCaWYiidr1Y7/Y3WR8RG/27dR2He5MUkHQYitCTk1BTwjPh2UR8opTeueVgqNyT6tA97Q8OteJetNlecqz8XrwxeeJBhTS8VqBHoaSWsmUeV3vJaQ7bmJANnAY3VwuThTaiMg= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 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-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mx.zohomail.com with SMTPS id 1617285311483731.3753019148645; Thu, 1 Apr 2021 06:55:11 -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-427-67WvPGTwNk6FfoylvMP4kg-1; Thu, 01 Apr 2021 09:55:08 -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 3D27772F6E; Thu, 1 Apr 2021 13:54:14 +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 004C982AD9; Thu, 1 Apr 2021 13:54: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 9CC164A700; Thu, 1 Apr 2021 13:54:13 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 131Ds4kH023381 for ; Thu, 1 Apr 2021 09:54:04 -0400 Received: by smtp.corp.redhat.com (Postfix) id 834B5764EF; Thu, 1 Apr 2021 13:54:04 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.33]) by smtp.corp.redhat.com (Postfix) with ESMTP id D1E2C79818 for ; Thu, 1 Apr 2021 13:54:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1617285310; 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=ZOSRNVHLLmThwHe7R0qZYDd2wfPfA5094ZEJwFbgd9U=; b=DRh/3ukwMZaG8fzR18csd6gwXI2HxHYkmGxMlVKwfMuuTpiLNU/J8ITfdmd3SHxqbsTvQK buuvy4wvgw2TW0HYYS2bcj4dyselMAda4P9SC/LCvWsjUnEjjDewPKTGel3oZsFw22+jOz TXxyP6m2EBG0shUPUHpWiFnV98H6qK8= X-MC-Unique: 67WvPGTwNk6FfoylvMP4kg-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 20/39] virshParseRateStr: Refactor cleanup Date: Thu, 1 Apr 2021 15:52:19 +0200 Message-Id: <26e123f92a1143881f4dc83d3eec258cf217e1c1.1617285119.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 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" Use g_auto for the string list and remove 'ret' and 'cleanup:'. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- tools/virsh-domain.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c index 86de4255fa..37be298809 100644 --- a/tools/virsh-domain.c +++ b/tools/virsh-domain.c @@ -848,7 +848,7 @@ static const vshCmdOptDef opts_attach_interface[] =3D { *tok[index] !=3D '\0' && \ virStrToLong_ullp(tok[index], NULL, 10, &rate->name) < 0) { \ vshError(ctl, _("field '%s' is malformed"), #name); \ - goto cleanup; \ + return -1; \ } \ } while (0) @@ -857,16 +857,15 @@ virshParseRateStr(vshControl *ctl, const char *rateStr, virNetDevBandwidthRatePtr rate) { - char **tok =3D NULL; + g_auto(GStrv) tok =3D NULL; size_t ntok; - int ret =3D -1; if (!(tok =3D virStringSplitCount(rateStr, ",", 0, &ntok))) return -1; if (ntok > 4) { vshError(ctl, _("Rate string '%s' has too many fields"), rateStr); - goto cleanup; + return -1; } VIRSH_PARSE_RATE_FIELD(0, average); @@ -874,10 +873,7 @@ virshParseRateStr(vshControl *ctl, VIRSH_PARSE_RATE_FIELD(2, burst); VIRSH_PARSE_RATE_FIELD(3, floor); - ret =3D 0; - cleanup: - g_strfreev(tok); - return ret; + return 0; } #undef VIRSH_PARSE_RATE_FIELD --=20 2.29.2 From nobody Mon Feb 9 10:24:32 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1617285276; cv=none; d=zohomail.com; s=zohoarc; b=PV+yGfHovU3iWFdmIoUuQQ6PZScUtB+Pv1Vv12aPdGd2A0UAd857dEMUYk/m46YCJFVJ6fNHYDYrRDRJleBh4bFHYO1c7Ucq8HfFRDIxqSzc/MngB1i8/j3coc27vU/j0bNiPiB6mBI3TF2a2/G+g98UaN2bAheC9Kro+AJjNZk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1617285276; 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=ULWtbOeYLZAfGnuBM0O5ZL3V3pxbt5tIrd6rZLv9LB4=; b=FARaQw9Y3JOijiAVr8SDnakz2WCO+mXpoG85qVssjys1Lwoeo2u9D3uiYpjsFiUD3YTlfpS9Xs9oYlWshTe9GLONhP3uik7rJ0CZ2qooZtN/x2cHGe7ustAGUxPktk73bMBcjA7xFVTvt4HdJvn6LRfXqaMq5tBbKH65eAIgcH4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 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-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mx.zohomail.com with SMTPS id 1617285276557398.69626399017204; Thu, 1 Apr 2021 06:54: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-5-SsgtmyfOPoyXExBv15vr5w-1; Thu, 01 Apr 2021 09:54:32 -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 CA58319251BB; Thu, 1 Apr 2021 13:54:10 +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 D9E78804E7; Thu, 1 Apr 2021 13:54: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 7907C1802138; Thu, 1 Apr 2021 13:54:09 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 131Ds5dD023388 for ; Thu, 1 Apr 2021 09:54:05 -0400 Received: by smtp.corp.redhat.com (Postfix) id D7C065C239; Thu, 1 Apr 2021 13:54:05 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.33]) by smtp.corp.redhat.com (Postfix) with ESMTP id 17CE75C701 for ; Thu, 1 Apr 2021 13:54:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1617285275; 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=ULWtbOeYLZAfGnuBM0O5ZL3V3pxbt5tIrd6rZLv9LB4=; b=iJQK472kWGLqJhd/wne15lRMM0WK5jx4+sBIUMqwrFi6L9FGZnnRE0XOkKb8FgkDB65r5I SwLefTU/Ecq0RcXA8ks43NkBXeSEG15zBl4UUX8KPjkHLCMb9V6PQkZJKMF8hCQ2Vf2eEM jMBgfbz0tyd0i9JUpkOnIEFoZy/Kq/8= X-MC-Unique: SsgtmyfOPoyXExBv15vr5w-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 21/39] virshParseRateStr: Use g_strsplit instead of virStringSplitCount Date: Thu, 1 Apr 2021 15:52:20 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 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" Count the elements after splitting the string. Signed-off-by: Peter Krempa --- tools/virsh-domain.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c index 37be298809..532169d8d7 100644 --- a/tools/virsh-domain.c +++ b/tools/virsh-domain.c @@ -860,10 +860,10 @@ virshParseRateStr(vshControl *ctl, g_auto(GStrv) tok =3D NULL; size_t ntok; - if (!(tok =3D virStringSplitCount(rateStr, ",", 0, &ntok))) + if (!(tok =3D g_strsplit(rateStr, ",", 0))) return -1; - if (ntok > 4) { + if ((ntok =3D g_strv_length(tok)) > 4) { vshError(ctl, _("Rate string '%s' has too many fields"), rateStr); return -1; } --=20 2.29.2 From nobody Mon Feb 9 10:24:32 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) client-ip=63.128.21.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1617285307; cv=none; d=zohomail.com; s=zohoarc; b=l4eoqj+xA/Pl6JESFWZjfNd+MSb7U59koHE1fc74dY5ApXgmVwQKkFsG5u+SDaz6dUC47bUxjNmMF1cvCgaAmyeMSS7zhHDsWH4uw/zL1qgBjN8KsYDFVTYYHVVkvtFRXFccn46WWL0q+bZjBzUY7LhYmarGn+Dz700KlVMWv3c= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1617285307; 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=Flao8T3ET7cf/XFrFtVQd3qNfXXT1c9wFxk9TzeUOyQ=; b=jxILzY6K7OvEMVqBdoubGQjlEkWYTeb6kY+dVlyFGGzICdAGU4CFj/YB6M8dk/TCgMTgpAcGai4ueMFBWwoS0Dw+cg3cHuXD+yBZPBp8wH2wK6Du4Ws9MgO4FgpZAuLujH6ZpZf8jnj8m3ZjlIm4Mc+bMlKGDjvHMW+YwaT17nY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.124 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-124.mimecast.com (us-smtp-delivery-124.mimecast.com [63.128.21.124]) by mx.zohomail.com with SMTPS id 1617285307330668.8328391131828; Thu, 1 Apr 2021 06:55: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-596-bu8Lw9CzN7iMRK7xJ2HFFw-1; Thu, 01 Apr 2021 09:55:04 -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 B40CD107B795; Thu, 1 Apr 2021 13:54:55 +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 894671001281; Thu, 1 Apr 2021 13:54:55 +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 33EF14A700; Thu, 1 Apr 2021 13:54:55 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 131Ds76t023402 for ; Thu, 1 Apr 2021 09:54:07 -0400 Received: by smtp.corp.redhat.com (Postfix) id 0BB745C649; Thu, 1 Apr 2021 13:54:07 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.33]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3E42D5C238 for ; Thu, 1 Apr 2021 13:54:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1617285306; 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=Flao8T3ET7cf/XFrFtVQd3qNfXXT1c9wFxk9TzeUOyQ=; b=SPY3FHKEI8HR+rnUz7+Zi7FkV2RKkCMa8LIDZ5sXHXG89PeCLAyHUsBMJ4FM28KbbjIvIm g1C6rm8z8jcde9M/Hzb57fCujnnIYUIKUvT5Kxhcvh10L76BeiPgxBpwaXeqW8Shdo31h2 94/TlWI3L+TNqknGXvi1CnZFjMnwzyE= X-MC-Unique: bu8Lw9CzN7iMRK7xJ2HFFw-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 22/39] virStorageSourceParseBackingJSONUriCookies: Use g_strsplit instead of virStringSplitCount Date: Thu, 1 Apr 2021 15:52:21 +0200 Message-Id: <8556059ae5d7784721da42e86a0e4e9881e42b50.1617285119.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 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" Count the elements after splitting the string. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/storage_file/storage_source_backingstore.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/storage_file/storage_source_backingstore.c b/src/storage_f= ile/storage_source_backingstore.c index bac5a043e5..9a67d64fd6 100644 --- a/src/storage_file/storage_source_backingstore.c +++ b/src/storage_file/storage_source_backingstore.c @@ -483,7 +483,6 @@ virStorageSourceParseBackingJSONUriCookies(virStorageSo= urcePtr src, { const char *cookiestr; g_auto(GStrv) cookies =3D NULL; - size_t ncookies =3D 0; size_t i; if (!virJSONValueObjectHasKey(json, "cookie")) @@ -496,13 +495,13 @@ virStorageSourceParseBackingJSONUriCookies(virStorage= SourcePtr src, return -1; } - if (!(cookies =3D virStringSplitCount(cookiestr, ";", 0, &ncookies))) + if (!(cookies =3D g_strsplit(cookiestr, ";", 0))) return -1; - src->cookies =3D g_new0(virStorageNetCookieDefPtr, ncookies); - src->ncookies =3D ncookies; + src->ncookies =3D g_strv_length(cookies); + src->cookies =3D g_new0(virStorageNetCookieDefPtr, src->ncookies); - for (i =3D 0; i < ncookies; i++) { + for (i =3D 0; i < src->ncookies; i++) { char *cookiename =3D cookies[i]; char *cookievalue; --=20 2.29.2 From nobody Mon Feb 9 10:24:32 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) client-ip=63.128.21.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1617285313; cv=none; d=zohomail.com; s=zohoarc; b=jivOOXRLc4QGGRVdBmZ2/Ohl8EKJaHx3m5/H9Eko1PRgq3Cd8g4Uzmsrv7RoZpBEI59vX59qCtIB0ji5A7RsxUVj7iMvfCNVm3rbrSSUSWaMPGt8Tokb7DJlzV3B/cKxbRRznZXqx+vRDRrtbc5wFOFqvQ5c2vjK+yVEV4ZpVMA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1617285313; 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=mTsD2hxgNyI/HXJoUtfqOq1ZtVkNSXKGnRvSNh06+Sw=; b=cGH1CX5dl19cWvg605B29Be68PnJ3XcSJbtErMK9zGjsX+PQ2Q0SojT2ODkd5oJLdGGinfvqKqA+VCONMa+mi1G9GSANwEYbM1pSnIIKQdl9wb3immo/FcMT5ah5fe0yO7WzY8pJdx/JXzNzMRZfutg8ZaqGEimtZUTB/aSskOY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.124 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-124.mimecast.com (us-smtp-delivery-124.mimecast.com [63.128.21.124]) by mx.zohomail.com with SMTPS id 1617285313788650.2984070423006; Thu, 1 Apr 2021 06:55:13 -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-586-H_B-6jJWNVSlDRQxk6PZig-1; Thu, 01 Apr 2021 09:55:09 -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 1A981107B786; Thu, 1 Apr 2021 13:55:00 +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 E2F595D9CC; Thu, 1 Apr 2021 13:54:59 +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 9F4CA4A701; Thu, 1 Apr 2021 13:54:59 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 131Ds8Ka023420 for ; Thu, 1 Apr 2021 09:54:08 -0400 Received: by smtp.corp.redhat.com (Postfix) id 01D6F5C1A1; Thu, 1 Apr 2021 13:54:08 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.33]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4F1A35F9B7 for ; Thu, 1 Apr 2021 13:54:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1617285312; 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=mTsD2hxgNyI/HXJoUtfqOq1ZtVkNSXKGnRvSNh06+Sw=; b=SqYJ0T8xxz8poB69y9f5sSS/xjrFOfGCHChqZBKx2wGm5FIWOfYlhYzWtGj33fb4P1yNFA WUzcuZKb+1Jci48HNnK8AaW0PlQGUN02ffBWpLEQsCQzhlirXBNBj+xetKzNNrCvOzUhuc OrpS05cboeNaWGesc+v38krfDCJsCA0= X-MC-Unique: H_B-6jJWNVSlDRQxk6PZig-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 23/39] storage: zfs: Don't split string if we need only first/last component Date: Thu, 1 Apr 2021 15:52:22 +0200 Message-Id: <493c95bc7791cd572c14c0aaa1e6bbbb511812eb.1617285119.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 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" Use str(r)chr to find the correct bit rather than fully splitting the string. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/storage/storage_backend_zfs.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/storage/storage_backend_zfs.c b/src/storage/storage_backen= d_zfs.c index e4ef06722f..cab1fd1637 100644 --- a/src/storage/storage_backend_zfs.c +++ b/src/storage/storage_backend_zfs.c @@ -102,7 +102,7 @@ virStorageBackendZFSParseVol(virStoragePoolObjPtr pool, virStorageVolDefPtr volume =3D NULL; virStoragePoolDefPtr def =3D virStoragePoolObjGetDef(pool); g_auto(GStrv) tokens =3D NULL; - g_auto(GStrv) name_tokens =3D NULL; + char *tmp; if (!(tokens =3D virStringSplitCount(volume_string, "\t", 0, &count))) return -1; @@ -110,10 +110,9 @@ virStorageBackendZFSParseVol(virStoragePoolObjPtr pool, if (count !=3D 3) goto cleanup; - if (!(name_tokens =3D virStringSplitCount(tokens[0], "/", 0, &count))) - goto cleanup; - - vol_name =3D name_tokens[count-1]; + vol_name =3D tokens[0]; + if ((tmp =3D strrchr(vol_name, '/'))) + vol_name =3D tmp + 1; if (vol =3D=3D NULL) volume =3D virStorageVolDefFindByName(pool, vol_name); @@ -218,7 +217,8 @@ virStorageBackendZFSRefreshPool(virStoragePoolObjPtr po= ol G_GNUC_UNUSED) g_autoptr(virCommand) cmd =3D NULL; g_auto(GStrv) lines =3D NULL; g_auto(GStrv) tokens =3D NULL; - g_auto(GStrv) name_tokens =3D NULL; + g_autofree char *name =3D g_strdup(def->source.name); + char *tmp; /** * $ zpool get -Hp health,size,free,allocated test @@ -230,13 +230,13 @@ virStorageBackendZFSRefreshPool(virStoragePoolObjPtr = pool G_GNUC_UNUSED) * * Here we just provide a list of properties we want to see */ - if (!(name_tokens =3D g_strsplit(def->source.name, "/", 0))) - goto cleanup; + if ((tmp =3D strchr(name, '/'))) + *tmp =3D '\0'; cmd =3D virCommandNewArgList(ZPOOL, "get", "-Hp", "health,size,free,allocated", - name_tokens[0], + name, NULL); virCommandSetOutputBuffer(cmd, &zpool_props); if (virCommandRun(cmd, NULL) < 0) --=20 2.29.2 From nobody Mon Feb 9 10:24:32 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1617285288; cv=none; d=zohomail.com; s=zohoarc; b=hzYiCKW6IU2g3XajSLAeLrTeEA/Xdat/W36utCqTCXtBUDGgTiHQuzAGIrAQ8nYsZRz1hP7nT/1BKFtsfiD6UXYfu8voS6Wqck0/NokFYlm+YAoE8hse8ki+71sdKraxaeJG9Fe/9T3fa1WFK2glgB/+nqnFeUMY5EJ+wDQEZFg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1617285288; 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=fSSI6j5p66stLzoH07hHvH9GPgYcofwgvo7UgZodADQ=; b=Izh9ULFf2QWjeyEjU7jn2qUZpsw+Ec5J0kZIuYN0eggMENpufX9wJw8fHJDsmDx708Os0qs7qm+/Kk5iYhbNjrPbEpEkzN9NvOgJBGHwwH2693LWu8GuC8RuKScfJ9x0+Vbg4uBXv3MgmEL/sTyE3uTA2aFpZw03ZNBIXtkRGcE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 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-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1617285288492868.7423083546626; Thu, 1 Apr 2021 06:54:48 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-418-XD9YSoPMPNuAUMrWu5-7GA-1; Thu, 01 Apr 2021 09:54:45 -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 3E8171009E49; Thu, 1 Apr 2021 13:54:18 +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 089C7614FC; Thu, 1 Apr 2021 13:54:18 +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 AA99D1809C83; Thu, 1 Apr 2021 13:54:17 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 131Ds9DP023481 for ; Thu, 1 Apr 2021 09:54:09 -0400 Received: by smtp.corp.redhat.com (Postfix) id 6CC1A1DB; Thu, 1 Apr 2021 13:54:09 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.33]) by smtp.corp.redhat.com (Postfix) with ESMTP id 815035C8AB for ; Thu, 1 Apr 2021 13:54:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1617285287; 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=fSSI6j5p66stLzoH07hHvH9GPgYcofwgvo7UgZodADQ=; b=IA0/7zWAMfnBrJo6l9qPJpb8+QxcXzPRoJQW00VWV0DnCZsHJilyVM74UD6F0mCxp2J1cO onacAIDFr46lwOPz3vVGFaq+saLVIy07Y5m6aA5iqyAERyodDZnzGgQorXgb2+1hFIq9l0 G8YVeEJFNxGQnwuFEWmyPDnX6/EJV0o= X-MC-Unique: XD9YSoPMPNuAUMrWu5-7GA-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 24/39] virStorageBackendZFSRefreshPool: Reduce scope of 'tokens' Date: Thu, 1 Apr 2021 15:52:23 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 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" Declare it in the loop that actually uses it. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/storage/storage_backend_zfs.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/storage/storage_backend_zfs.c b/src/storage/storage_backen= d_zfs.c index cab1fd1637..6fed25cf4d 100644 --- a/src/storage/storage_backend_zfs.c +++ b/src/storage/storage_backend_zfs.c @@ -216,7 +216,6 @@ virStorageBackendZFSRefreshPool(virStoragePoolObjPtr po= ol G_GNUC_UNUSED) size_t i; g_autoptr(virCommand) cmd =3D NULL; g_auto(GStrv) lines =3D NULL; - g_auto(GStrv) tokens =3D NULL; g_autofree char *name =3D g_strdup(def->source.name); char *tmp; @@ -246,13 +245,13 @@ virStorageBackendZFSRefreshPool(virStoragePoolObjPtr = pool G_GNUC_UNUSED) goto cleanup; for (i =3D 0; lines[i]; i++) { + g_auto(GStrv) tokens =3D NULL; size_t count; char *prop_name; if (STREQ(lines[i], "")) continue; - g_strfreev(tokens); if (!(tokens =3D virStringSplitCount(lines[i], "\t", 0, &count))) goto cleanup; --=20 2.29.2 From nobody Mon Feb 9 10:24:32 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1617285377; cv=none; d=zohomail.com; s=zohoarc; b=Y0WdrjvngZ7KUAhqMngzknteATjinYhC5VBBtGYM4UophX58HUxz4LTYDUFgM4NlCxcLodZarXVqxwTGKB13r/cKb73kiWVNS6BXy4ytMx9QByTEL42LMX/jy1bf27Z5G64+9UH1ryAx96ExinI8+R3VOr6QAIzOzK+3qwljREo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1617285377; 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=giu1SB2NrUgXXC/HDTvXyc7LkZasQSt9TcMSDRZ01zA=; b=Qou1cfWQNMPg05noiNQnVXgVmjhUG58egPFkM0+t6BdRsuTI4OKPo1lFCaTp0odqvknC4GVHWq8XLXloePwn0xghPcdE7McOmVyL33StfK11pYESilu4bSbv/v/QY67BA+RfA6efoJ06UGZJQnvBDcQ4qDVzJVqiVwr8D2g1jmg= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 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-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1617285377682301.8046358362619; Thu, 1 Apr 2021 06:56:17 -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-31-7QHq09aAO1GFwobBBAowAg-1; Thu, 01 Apr 2021 09:55:25 -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 AA0348B99E5; Thu, 1 Apr 2021 13:55:07 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 6DFCA51C4E; Thu, 1 Apr 2021 13:55:07 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 231A24A700; Thu, 1 Apr 2021 13:55:07 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 131DsACw023502 for ; Thu, 1 Apr 2021 09:54:10 -0400 Received: by smtp.corp.redhat.com (Postfix) id 4B73C5C5FC; Thu, 1 Apr 2021 13:54:10 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.33]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9CB615C237 for ; Thu, 1 Apr 2021 13:54:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1617285376; 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=giu1SB2NrUgXXC/HDTvXyc7LkZasQSt9TcMSDRZ01zA=; b=dBGr1Gf5H43W79WaotgiS5uNfZgcuPd2rub5x+5ORAS3D49Y11MRGyDHH3wxXT6fFyNotI gpjVkogR1eJ6XidnjuTngP8/z40cqJZhlF6cmUPjUzSUwWqTzwBpKLd+kNrISTUlkFfqP8 /ItEMHwG5HlwukF71lweXob5Di3Kqas= X-MC-Unique: 7QHq09aAO1GFwobBBAowAg-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 25/39] storage: zfs: Use g_strsplit instead of virStringSplitCount Date: Thu, 1 Apr 2021 15:52:24 +0200 Message-Id: <0244b07b868f68b2ffa2ec7771a01792cffeef07.1617285119.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 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" Both instances just check the length once. Replicate that faithfully. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/storage/storage_backend_zfs.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/storage/storage_backend_zfs.c b/src/storage/storage_backen= d_zfs.c index 6fed25cf4d..c36deb9dac 100644 --- a/src/storage/storage_backend_zfs.c +++ b/src/storage/storage_backend_zfs.c @@ -96,7 +96,6 @@ virStorageBackendZFSParseVol(virStoragePoolObjPtr pool, const char *volume_string) { int ret =3D -1; - size_t count; char *vol_name; bool is_new_vol =3D false; virStorageVolDefPtr volume =3D NULL; @@ -104,10 +103,10 @@ virStorageBackendZFSParseVol(virStoragePoolObjPtr poo= l, g_auto(GStrv) tokens =3D NULL; char *tmp; - if (!(tokens =3D virStringSplitCount(volume_string, "\t", 0, &count))) + if (!(tokens =3D g_strsplit(volume_string, "\t", 0))) return -1; - if (count !=3D 3) + if (g_strv_length(tokens) !=3D 3) goto cleanup; vol_name =3D tokens[0]; @@ -246,16 +245,15 @@ virStorageBackendZFSRefreshPool(virStoragePoolObjPtr = pool G_GNUC_UNUSED) for (i =3D 0; lines[i]; i++) { g_auto(GStrv) tokens =3D NULL; - size_t count; char *prop_name; if (STREQ(lines[i], "")) continue; - if (!(tokens =3D virStringSplitCount(lines[i], "\t", 0, &count))) + if (!(tokens =3D g_strsplit(lines[i], "\t", 0))) goto cleanup; - if (count !=3D 4) + if (g_strv_length(tokens) !=3D 4) continue; prop_name =3D tokens[1]; --=20 2.29.2 From nobody Mon Feb 9 10:24:32 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1617285381; cv=none; d=zohomail.com; s=zohoarc; b=T/ne6PUCRYw7yOXLeO4c245Nx+mXwBCFZDdlPlwmLv4d20qr7Yr3OI5VpA/SoFF3vr9nTP7r8d2NGGRDu0jV/j98vM3oMEbsqhbCSSfbC9XIejRKCQIhuvuL7DJauDLz73EW1rNfnlrmNfS8cPQgSlCvB3+0lOzWp5/zDSzG0fY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1617285381; 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=0u/12PA83XwYeIkd0BMC0CtE23hUjmD3oagIG0QqmgE=; b=MfBV2ZBTQ5py+BMAH3dH2oLvdRNdZ/HIqDE2IQXS4yewI7g8MbaHKMoBWyG/NqK99QMnOlD+1eQDbeCQSdg7fVCBoT/fsR3trDz0MnKDpWzxLT8oaN+xb6eJZIwE3rqGO5mU+izmapKAZRu3CrtIzNyomuwdPQnpXIFnmDlL0yw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 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-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mx.zohomail.com with SMTPS id 1617285381992953.8996212596555; Thu, 1 Apr 2021 06:56: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-369-joJFYZXqMoO-3LDIILDB0w-1; Thu, 01 Apr 2021 09:55:18 -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 EDE0819251BF; Thu, 1 Apr 2021 13:55: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 B85A96B8F7; Thu, 1 Apr 2021 13:55: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 555CE4A703; Thu, 1 Apr 2021 13:55:11 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 131DsBbn023544 for ; Thu, 1 Apr 2021 09:54:11 -0400 Received: by smtp.corp.redhat.com (Postfix) id 80B6D5C237; Thu, 1 Apr 2021 13:54:11 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.33]) by smtp.corp.redhat.com (Postfix) with ESMTP id D90AE71C5A for ; Thu, 1 Apr 2021 13:54:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1617285381; 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=0u/12PA83XwYeIkd0BMC0CtE23hUjmD3oagIG0QqmgE=; b=Bv7YzzQCXt0SYotq2MNw38EfS89Oq2ijmx4M3wWaY+mJzGa+jjGG0IEcQyu0diIUfTMeIN +QruKlg6GKiJeiv5VBUYAGUheO1Y9eI4teS64siwNa3VWcvjTy3PYpC57Ca8dmm399xQ4t l825NvcIfkXsaQfGFv+P5EkF2fXXsFw= X-MC-Unique: joJFYZXqMoO-3LDIILDB0w-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 26/39] virResctrlGetCacheInfo: Restrict variable scope and use automatic freeing Date: Thu, 1 Apr 2021 15:52:25 +0200 Message-Id: <860253e6b3154c18cf5875326a98e115df83c4e1.1617285119.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 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" Move variables into the loop which uses them and use automatic freeing for temporarily allocated variables. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/util/virresctrl.c | 30 +++++++++++++----------------- 1 file changed, 13 insertions(+), 17 deletions(-) diff --git a/src/util/virresctrl.c b/src/util/virresctrl.c index 8458db96bc..fbc8e9c766 100644 --- a/src/util/virresctrl.c +++ b/src/util/virresctrl.c @@ -526,18 +526,19 @@ static int virResctrlGetCacheInfo(virResctrlInfoPtr resctrl, DIR *dirp) { - char *endptr =3D NULL; - char *tmp_str =3D NULL; - int ret =3D -1; int rv =3D -1; - int type =3D 0; + int ret =3D -1; struct dirent *ent =3D NULL; - unsigned int level =3D 0; - virBitmapPtr tmp_map =3D NULL; - virResctrlInfoPerLevelPtr i_level =3D NULL; - virResctrlInfoPerTypePtr i_type =3D NULL; while ((rv =3D virDirRead(dirp, &ent, SYSFS_RESCTRL_PATH "/info")) > 0= ) { + g_autofree char *cbm_mask_str =3D NULL; + g_autoptr(virBitmap) cbm_mask_map =3D NULL; + char *endptr =3D NULL; + int type =3D 0; + unsigned int level =3D 0; + virResctrlInfoPerLevelPtr i_level =3D NULL; + g_autofree virResctrlInfoPerTypePtr i_type =3D NULL; + VIR_DEBUG("Parsing info type '%s'", ent->d_name); if (ent->d_name[0] !=3D 'L') continue; @@ -570,7 +571,7 @@ virResctrlGetCacheInfo(virResctrlInfoPtr resctrl, goto cleanup; } - rv =3D virFileReadValueString(&tmp_str, + rv =3D virFileReadValueString(&cbm_mask_str, SYSFS_RESCTRL_PATH "/info/%s/cbm_mask", ent->d_name); @@ -585,19 +586,15 @@ virResctrlGetCacheInfo(virResctrlInfoPtr resctrl, if (rv < 0) goto cleanup; - virStringTrimOptionalNewline(tmp_str); + virStringTrimOptionalNewline(cbm_mask_str); - tmp_map =3D virBitmapNewString(tmp_str); - VIR_FREE(tmp_str); - if (!tmp_map) { + if (!(cbm_mask_map =3D virBitmapNewString(cbm_mask_str))) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Cannot parse cbm_mask from resctrl cache inf= o")); goto cleanup; } - i_type->bits =3D virBitmapCountBits(tmp_map); - virBitmapFree(tmp_map); - tmp_map =3D NULL; + i_type->bits =3D virBitmapCountBits(cbm_mask_map); rv =3D virFileReadValueUint(&i_type->min_cbm_bits, SYSFS_RESCTRL_PATH "/info/%s/min_cbm_bit= s", @@ -635,7 +632,6 @@ virResctrlGetCacheInfo(virResctrlInfoPtr resctrl, ret =3D 0; cleanup: - VIR_FREE(i_type); return ret; } --=20 2.29.2 From nobody Mon Feb 9 10:24:32 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1617285317; cv=none; d=zohomail.com; s=zohoarc; b=B+CbbyFGbRzjJAwHCSMyTPn186m3q2wUR7C2etpO6x+aERpCVhZ3bWywXZ9CvquPvwac0cgE9VaG28/mROR8wO/maqft32BM/4ifzAnaKeOIdHcS7B1YvfdsmizXi5EFq/yY3ake+fWigSk7UBiO3OngTt7VxdJ1nflAw7jP3fM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1617285317; 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=JPO5THN+rf9FmtoA57fdO8mn5rJrObS4mWp3Y1uQ638=; b=bPvvLLzlbCfuCnf+xR1QI7IjTBxSMCo5KkP2TuTQmfCq73MczUkzb1rzBAKZCbU4yYaIPw3icwhfU60UYyMLrMNL6Gd4JNgu2IuFPfgAPP/X+SajzIrYSf5HhyooFaXXF1zk7HXBWSnkIvZUn7PxfMZbUNzKiNIFtMixtXhmy7I= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 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-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mx.zohomail.com with SMTPS id 1617285317092631.0148611862584; Thu, 1 Apr 2021 06:55:17 -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-211-4miWshGhOAqiGEJtRs2wcg-1; Thu, 01 Apr 2021 09:55:12 -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 9A2AD8B5BB9; Thu, 1 Apr 2021 13:54:15 +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 CBB181048120; Thu, 1 Apr 2021 13:54: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 7B72B4A701; Thu, 1 Apr 2021 13:54:14 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 131DsCYk023551 for ; Thu, 1 Apr 2021 09:54:12 -0400 Received: by smtp.corp.redhat.com (Postfix) id B3E755C239; Thu, 1 Apr 2021 13:54:12 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.33]) by smtp.corp.redhat.com (Postfix) with ESMTP id 021875C237 for ; Thu, 1 Apr 2021 13:54:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1617285316; 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=JPO5THN+rf9FmtoA57fdO8mn5rJrObS4mWp3Y1uQ638=; b=cbjjv+pvRxnZ641+RAKllVv15KWrSQc60J1VbjivKIDWkpgB7+7+jbDDNKM+26JZ9OEkyp FdEE+ZEfvZz92ZXo0o+APA2y/uLl3a7bcYYASlzHjDD+j3aVPjcVKocYG6qVidPeryXfKc aolZJdPnpiu+1DiJJTEMFoaAjcMMRRo= X-MC-Unique: 4miWshGhOAqiGEJtRs2wcg-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 27/39] virResctrlAllocNewFromInfo: Restrict variable scope and use automatic freeing Date: Thu, 1 Apr 2021 15:52:26 +0200 Message-Id: <6f7a7a81a367a46cd71f059f6dd142e333fbbcc3.1617285119.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 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" Move variables into the loop which uses them and use automatic freeing for temporarily allocated variables. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/util/virresctrl.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/util/virresctrl.c b/src/util/virresctrl.c index fbc8e9c766..5e7c391524 100644 --- a/src/util/virresctrl.c +++ b/src/util/virresctrl.c @@ -1811,27 +1811,26 @@ static virResctrlAllocPtr virResctrlAllocNewFromInfo(virResctrlInfoPtr info) { size_t i =3D 0; - size_t j =3D 0; - size_t k =3D 0; virResctrlAllocPtr ret =3D virResctrlAllocNew(); - virBitmapPtr mask =3D NULL; if (!ret) return NULL; for (i =3D 0; i < info->nlevels; i++) { virResctrlInfoPerLevelPtr i_level =3D info->levels[i]; + size_t j =3D 0; if (!i_level) continue; for (j =3D 0; j < VIR_CACHE_TYPE_LAST; j++) { virResctrlInfoPerTypePtr i_type =3D i_level->types[j]; + g_autoptr(virBitmap) mask =3D NULL; + size_t k =3D 0; if (!i_type) continue; - virBitmapFree(mask); mask =3D virBitmapNew(i_type->bits); virBitmapSetAll(mask); @@ -1856,7 +1855,6 @@ virResctrlAllocNewFromInfo(virResctrlInfoPtr info) } cleanup: - virBitmapFree(mask); return ret; error: virObjectUnref(ret); --=20 2.29.2 From nobody Mon Feb 9 10:24:32 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1617285373; cv=none; d=zohomail.com; s=zohoarc; b=TZ1cfVJGmc0vSbyI8kiisn7RvCuG9nPK+ZfOWqHuW+fSx02vtdpegg/xgtCWddzvnOlrDgn4QCoer1sDfoX5mVhReA8mlIKDnnyJ/kliWAC1jE//4lN9G1B+YgkAwXI7m0Ey+V3C2UyADGHfBetH47UAuKkHWetV0em8aJYaFVQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1617285373; 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=N68zKoC6pcUN0xPAgGrNFJuaTwp3ANQjgpqiRP2RK54=; b=PTBKHU1Q7Wmaz2DoxK8O7Q4599pVIiolIKrHwNpOR9Ca0QIZORoXNpSA/bApaOEN0TCnnMb/K/R7pBifdvV7nOjpLaVFYhfgfdFTA0vVjwUWwIUjaQPX2eWZL3eTDL/QfJJGVT9deKwJvvXAD7Jv6TIxmfcdvTFxwMbbTuRfHL0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 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-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1617285373290207.28515145989286; Thu, 1 Apr 2021 06:56:13 -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-303-qD1TU38YNWWPlaJUjpxuWA-1; Thu, 01 Apr 2021 09:55:25 -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 A5C298189DE; Thu, 1 Apr 2021 13:55:15 +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 7D0CB5C239; Thu, 1 Apr 2021 13:55:15 +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 238CF180C5A9; Thu, 1 Apr 2021 13:55:15 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 131DsDLi023563 for ; Thu, 1 Apr 2021 09:54:13 -0400 Received: by smtp.corp.redhat.com (Postfix) id C667A5C701; Thu, 1 Apr 2021 13:54:13 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.33]) by smtp.corp.redhat.com (Postfix) with ESMTP id 30574764EE for ; Thu, 1 Apr 2021 13:54:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1617285372; 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=N68zKoC6pcUN0xPAgGrNFJuaTwp3ANQjgpqiRP2RK54=; b=CSa0QMLohqimxPRCX3DBStHt9JVKcN4oq8vV/Mhtm67kBvGOlbTvBRMn/PT1w+hrsX6uGH 22BoEc6BuyWxW5SftfWjPiuxUmMOc/apObtS+hMsWMnbbYSiSggkEDv3kjzZIpf+KwQe/0 cJfXBYBbuoEdY9HdVStB8tw2OKrZX5M= X-MC-Unique: qD1TU38YNWWPlaJUjpxuWA-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 28/39] virResctrlAllocNewFromInfo: Use g_autoptr for 'ret' Date: Thu, 1 Apr 2021 15:52:27 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 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" Remove 'cleanup' and 'error' labels by switching 'ret' to automatic pointer and stealing it in the return statement. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/util/virresctrl.c | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/src/util/virresctrl.c b/src/util/virresctrl.c index 5e7c391524..c66cf4b087 100644 --- a/src/util/virresctrl.c +++ b/src/util/virresctrl.c @@ -1811,7 +1811,7 @@ static virResctrlAllocPtr virResctrlAllocNewFromInfo(virResctrlInfoPtr info) { size_t i =3D 0; - virResctrlAllocPtr ret =3D virResctrlAllocNew(); + g_autoptr(virResctrlAlloc) ret =3D virResctrlAllocNew(); if (!ret) return NULL; @@ -1836,7 +1836,7 @@ virResctrlAllocNewFromInfo(virResctrlInfoPtr info) for (k =3D 0; k <=3D i_type->max_cache_id; k++) { if (virResctrlAllocUpdateMask(ret, i, j, k, mask) < 0) - goto error; + return NULL; } } } @@ -1854,12 +1854,7 @@ virResctrlAllocNewFromInfo(virResctrlInfoPtr info) } } - cleanup: - return ret; - error: - virObjectUnref(ret); - ret =3D NULL; - goto cleanup; + return g_steal_pointer(&ret); } /* --=20 2.29.2 From nobody Mon Feb 9 10:24:32 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1617285291; cv=none; d=zohomail.com; s=zohoarc; b=aEVo5Z+xaxzrpcdAGDj8Fze9eJMHtBGk/j1fwQwocR14HwfuCMIQQ9gNWwG0pg8E4SrXroxCaqZaaZEcKHqWxY9kUndr4oSD3+5H9CtobggKJunBPTyIUSlu5VeN4XhCVZ+pOgJtpTDz6GCgv+K2qOUD0K4tmOYmkkch2A7fvTE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1617285291; 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=RfrCRPETn5HzC8sYdyRKQwaEx+tm/JERC3fXW9KwUM4=; b=H+BcRCWfc+095BZ1AdTyjX7epHehfQR24p0PSjeF6uitL227HbvqzY8XjcDrElBRgUQRYw3ov2D/i4CTYO5OoZ6WZNaBD+PNYuKiuk0XOEQ9jksuiJQn8R/JW3+P+ciemmzPrbp8S4jP6BLyjM2cMNSl5dGkAFTk4P0XzzRIKS0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 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-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1617285291719594.6638920358397; Thu, 1 Apr 2021 06:54:51 -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-280-oNCW8dMQMmyIoP1HAHYtkw-1; Thu, 01 Apr 2021 09:54:47 -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 78CC6881D75; Thu, 1 Apr 2021 13:54:19 +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 10C1E424D; Thu, 1 Apr 2021 13:54:19 +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 9192F4A701; Thu, 1 Apr 2021 13:54:18 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 131DsFK3023587 for ; Thu, 1 Apr 2021 09:54:15 -0400 Received: by smtp.corp.redhat.com (Postfix) id 1E98B5C1A1; Thu, 1 Apr 2021 13:54:15 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.33]) by smtp.corp.redhat.com (Postfix) with ESMTP id 554B85C237 for ; Thu, 1 Apr 2021 13:54:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1617285290; 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=RfrCRPETn5HzC8sYdyRKQwaEx+tm/JERC3fXW9KwUM4=; b=aVrxGshd6WK6wkZhjPneOu5SgzOYO6Sv1iHchdORtYKpuDj+5IT4YcdZQhCJyLonw+fjzp SMjFdS9nLhjCr9rxhVaNpANJE9V0zRT3qaEDRLVwXsaFZyVOPmHaBhg1+z5u10RDdFV80c VPucq+GDmw8xoxr0B/+2sRuTuGcVGAQ= X-MC-Unique: oNCW8dMQMmyIoP1HAHYtkw-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 29/39] virResctrlAllocGetUnused: Use g_autoptr for variables of virResctrlAlloc type Date: Thu, 1 Apr 2021 15:52:28 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 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" Refactor the handling of variables so that the cleanup section can be sanitized. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/util/virresctrl.c | 32 ++++++++++++-------------------- 1 file changed, 12 insertions(+), 20 deletions(-) diff --git a/src/util/virresctrl.c b/src/util/virresctrl.c index c66cf4b087..53c202f99f 100644 --- a/src/util/virresctrl.c +++ b/src/util/virresctrl.c @@ -1874,8 +1874,8 @@ virResctrlAllocNewFromInfo(virResctrlInfoPtr info) virResctrlAllocPtr virResctrlAllocGetUnused(virResctrlInfoPtr resctrl) { - virResctrlAllocPtr ret =3D NULL; - virResctrlAllocPtr alloc =3D NULL; + g_autoptr(virResctrlAlloc) ret =3D NULL; + g_autoptr(virResctrlAlloc) alloc_default =3D NULL; struct dirent *ent =3D NULL; g_autoptr(DIR) dirp =3D NULL; int rv =3D -1; @@ -1890,17 +1890,18 @@ virResctrlAllocGetUnused(virResctrlInfoPtr resctrl) if (!ret) return NULL; - alloc =3D virResctrlAllocGetDefault(resctrl); - if (!alloc) - goto error; + alloc_default =3D virResctrlAllocGetDefault(resctrl); + if (!alloc_default) + return NULL; - virResctrlAllocSubtract(ret, alloc); - virObjectUnref(alloc); + virResctrlAllocSubtract(ret, alloc_default); if (virDirOpen(&dirp, SYSFS_RESCTRL_PATH) < 0) - goto error; + return NULL; while ((rv =3D virDirRead(dirp, &ent, SYSFS_RESCTRL_PATH)) > 0) { + g_autoptr(virResctrlAlloc) alloc =3D NULL; + if (STREQ(ent->d_name, "info")) continue; @@ -1912,24 +1913,15 @@ virResctrlAllocGetUnused(virResctrlInfoPtr resctrl) virReportError(VIR_ERR_INTERNAL_ERROR, _("Could not read schemata file for group %s"), ent->d_name); - goto error; + return NULL; } virResctrlAllocSubtract(ret, alloc); - virObjectUnref(alloc); - alloc =3D NULL; } if (rv < 0) - goto error; - - cleanup: - virObjectUnref(alloc); - return ret; + return NULL; - error: - virObjectUnref(ret); - ret =3D NULL; - goto cleanup; + return g_steal_pointer(&ret); } --=20 2.29.2 From nobody Mon Feb 9 10:24:32 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1617285495; cv=none; d=zohomail.com; s=zohoarc; b=lko46mejKG8SCzimI53IENRmMSzXOpKDcXsVJv/RmWF0naqefXBwQQugnEHD1NrSsPQVrG9JfSthULifz14vjVLOaxKz2/qPdd04p6Hc+WWAQ4rgGhzlw5McNziGZpN3NfWJ4s74BjX9NfBGUjhttxMQF9MzFaNsP6cWjjMBBM8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1617285495; 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=6c2ZSYkKaLgZGVN5Sp97YWcg4Pq+IDjMFEVo0Ghpj+c=; b=X8+4NJ/VRHh/gaeqZR3zwQAV3YTu4er/hucTvCU2nLdsZJJwtCq8AevntDxLH+/17fn9ta2VRFMoAi4c264g7QlwOUsTEO0iS+jZ+5o/vUqYUHJhheympMuiTvh1mo1c/OHD/8rLXA+DJtNXIGsbazmJ6W4I9Zwmj1ovJMAxqTc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 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-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mx.zohomail.com with SMTPS id 1617285495324345.3758191193522; Thu, 1 Apr 2021 06:58:15 -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-4-Xq0WLiO2P6uQnjMhv0pUhA-1; Thu, 01 Apr 2021 09:55:22 -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 8EA628B99C0; Thu, 1 Apr 2021 13:55:03 +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 64EC2608DB; Thu, 1 Apr 2021 13:55:03 +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 191D71809C83; Thu, 1 Apr 2021 13:55:03 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 131DsGOU023601 for ; Thu, 1 Apr 2021 09:54:16 -0400 Received: by smtp.corp.redhat.com (Postfix) id 29E5F5C237; Thu, 1 Apr 2021 13:54:16 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.33]) by smtp.corp.redhat.com (Postfix) with ESMTP id 80B3C5C1A1 for ; Thu, 1 Apr 2021 13:54:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1617285494; 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=6c2ZSYkKaLgZGVN5Sp97YWcg4Pq+IDjMFEVo0Ghpj+c=; b=doTXTAVgHKzFaPSfJ5uwHtukLIFok5Pj0CRs+3fTgqeJWRG0dJm0p6U1z/WhD3v5QcCcC2 btyo6zX+XO24J4Y5gMo1oNmo4zHp0CecGp3nTXtPwwfbmTJBWSV1uSvn5/syDnN9zdpS63 lj6nnaqMTiTur/K1rJ/qo0z29leK5cA= X-MC-Unique: Xq0WLiO2P6uQnjMhv0pUhA-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 30/39] util: virresctrl: Use automatic memory freeing Date: Thu, 1 Apr 2021 15:52:29 +0200 Message-Id: <1120958a9539bf702860589bed244db384c05449.1617285119.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 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: Peter Krempa --- src/util/virresctrl.c | 53 ++++++++++++++----------------------------- 1 file changed, 17 insertions(+), 36 deletions(-) diff --git a/src/util/virresctrl.c b/src/util/virresctrl.c index 53c202f99f..6d8e669852 100644 --- a/src/util/virresctrl.c +++ b/src/util/virresctrl.c @@ -641,7 +641,7 @@ virResctrlGetMemoryBandwidthInfo(virResctrlInfoPtr resc= trl) { int ret =3D -1; int rv =3D -1; - virResctrlInfoMemBWPtr i_membw =3D NULL; + g_autofree virResctrlInfoMemBWPtr i_membw =3D NULL; /* query memory bandwidth allocation info */ i_membw =3D g_new0(virResctrlInfoMemBW, 1); @@ -684,7 +684,6 @@ virResctrlGetMemoryBandwidthInfo(virResctrlInfoPtr resc= trl) resctrl->membw_info =3D g_steal_pointer(&i_membw); ret =3D 0; cleanup: - VIR_FREE(i_membw); return ret; } @@ -705,10 +704,10 @@ virResctrlGetMonitorInfo(virResctrlInfoPtr resctrl) { int ret =3D -1; int rv =3D -1; - char *featurestr =3D NULL; - char **features =3D NULL; + g_autofree char *featurestr =3D NULL; + g_auto(GStrv) features =3D NULL; size_t nfeatures =3D 0; - virResctrlInfoMongrpPtr info_monitor =3D NULL; + g_autofree virResctrlInfoMongrpPtr info_monitor =3D NULL; info_monitor =3D g_new0(virResctrlInfoMongrp, 1); @@ -767,9 +766,6 @@ virResctrlGetMonitorInfo(virResctrlInfoPtr resctrl) ret =3D 0; cleanup: - VIR_FREE(featurestr); - g_strfreev(features); - VIR_FREE(info_monitor); return ret; } @@ -1480,7 +1476,7 @@ virResctrlAllocParseMemoryBandwidthLine(virResctrlInf= oPtr resctrl, virResctrlAllocPtr alloc, char *line) { - char **mbs =3D NULL; + g_auto(GStrv) mbs =3D NULL; char *tmp =3D NULL; size_t nmbs =3D 0; size_t i; @@ -1517,7 +1513,6 @@ virResctrlAllocParseMemoryBandwidthLine(virResctrlInf= oPtr resctrl, ret =3D 0; cleanup: - g_strfreev(mbs); return ret; } @@ -1595,7 +1590,7 @@ virResctrlAllocParseProcessCache(virResctrlInfoPtr re= sctrl, { char *tmp =3D strchr(cache, '=3D'); unsigned int cache_id =3D 0; - virBitmapPtr mask =3D NULL; + g_autoptr(virBitmap) mask =3D NULL; int ret =3D -1; if (!tmp) @@ -1632,7 +1627,6 @@ virResctrlAllocParseProcessCache(virResctrlInfoPtr re= sctrl, ret =3D 0; cleanup: - virBitmapFree(mask); return ret; } @@ -1642,7 +1636,7 @@ virResctrlAllocParseCacheLine(virResctrlInfoPtr resct= rl, virResctrlAllocPtr alloc, char *line) { - char **caches =3D NULL; + g_auto(GStrv) caches =3D NULL; char *tmp =3D NULL; unsigned int level =3D 0; int type =3D -1; @@ -1691,7 +1685,6 @@ virResctrlAllocParseCacheLine(virResctrlInfoPtr resct= rl, ret =3D 0; cleanup: - g_strfreev(caches); return ret; } @@ -1701,7 +1694,7 @@ virResctrlAllocParse(virResctrlInfoPtr resctrl, virResctrlAllocPtr alloc, const char *schemata) { - char **lines =3D NULL; + g_auto(GStrv) lines =3D NULL; size_t nlines =3D 0; size_t i =3D 0; int ret =3D -1; @@ -1717,7 +1710,6 @@ virResctrlAllocParse(virResctrlInfoPtr resctrl, ret =3D 0; cleanup: - g_strfreev(lines); return ret; } @@ -1945,7 +1937,7 @@ virResctrlAllocFindUnused(virResctrlAllocPtr alloc, { unsigned long long *size =3D alloc->levels[level]->types[type]->sizes[= cache]; virBitmapPtr a_mask =3D NULL; - virBitmapPtr f_mask =3D NULL; + g_autoptr(virBitmap) f_mask =3D NULL; unsigned long long need_bits; size_t i =3D 0; ssize_t pos =3D -1; @@ -2049,7 +2041,6 @@ virResctrlAllocFindUnused(virResctrlAllocPtr alloc, ret =3D 0; cleanup: - virBitmapFree(a_mask); return ret; } @@ -2185,8 +2176,8 @@ virResctrlAllocAssign(virResctrlInfoPtr resctrl, { int ret =3D -1; unsigned int level =3D 0; - virResctrlAllocPtr alloc_free =3D NULL; - virResctrlAllocPtr alloc_default =3D NULL; + g_autoptr(virResctrlAlloc) alloc_free =3D NULL; + g_autoptr(virResctrlAlloc) alloc_default =3D NULL; alloc_free =3D virResctrlAllocGetUnused(resctrl); if (!alloc_free) @@ -2251,8 +2242,6 @@ virResctrlAllocAssign(virResctrlInfoPtr resctrl, ret =3D 0; cleanup: - virObjectUnref(alloc_free); - virObjectUnref(alloc_default); return ret; } @@ -2328,8 +2317,8 @@ virResctrlAllocCreate(virResctrlInfoPtr resctrl, virResctrlAllocPtr alloc, const char *machinename) { - char *schemata_path =3D NULL; - char *alloc_str =3D NULL; + g_autofree char *schemata_path =3D NULL; + g_autofree char *alloc_str =3D NULL; int ret =3D -1; int lockfd =3D -1; @@ -2377,8 +2366,6 @@ virResctrlAllocCreate(virResctrlInfoPtr resctrl, ret =3D 0; cleanup: virResctrlUnlock(lockfd); - VIR_FREE(alloc_str); - VIR_FREE(schemata_path); return ret; } @@ -2387,8 +2374,8 @@ static int virResctrlAddPID(const char *path, pid_t pid) { - char *tasks =3D NULL; - char *pidstr =3D NULL; + g_autofree char *tasks =3D NULL; + g_autofree char *pidstr =3D NULL; int ret =3D 0; if (!path) { @@ -2410,8 +2397,6 @@ virResctrlAddPID(const char *path, ret =3D 0; cleanup: - VIR_FREE(tasks); - VIR_FREE(pidstr); return ret; } @@ -2631,8 +2616,7 @@ virResctrlMonitorGetStats(virResctrlMonitorPtr monito= r, size_t i =3D 0; unsigned long long val =3D 0; g_autoptr(DIR) dirp =3D NULL; - char *datapath =3D NULL; - char *filepath =3D NULL; + g_autofree char *datapath =3D NULL; struct dirent *ent =3D NULL; virResctrlMonitorStatsPtr stat =3D NULL; size_t nresources =3D g_strv_length((char **) resources); @@ -2650,10 +2634,9 @@ virResctrlMonitorGetStats(virResctrlMonitorPtr monit= or, *nstats =3D 0; while (virDirRead(dirp, &ent, datapath) > 0) { + g_autofree char *filepath =3D NULL; char *node_id =3D NULL; - VIR_FREE(filepath); - /* Looking for directory that contains resource utilization * information file. The directory name is arranged in format * "mon__". For example, "mon_L3_00" and @@ -2712,8 +2695,6 @@ virResctrlMonitorGetStats(virResctrlMonitorPtr monito= r, ret =3D 0; cleanup: - VIR_FREE(datapath); - VIR_FREE(filepath); virResctrlMonitorStatsFree(stat); return ret; } --=20 2.29.2 From nobody Mon Feb 9 10:24:32 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) client-ip=63.128.21.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1617285319; cv=none; d=zohomail.com; s=zohoarc; b=GrBUyvb+sOTfgv7P9ZAANMLCepn/ukuiRhy4qzlJtxhBao7z34KnLt/UJElAyCE7dztUiBu7WvLCf4TY0sq3eL4ZXElWS0YjmEk2kQKFmgJh0iaA6uPbhG5GX87O01Bd69zpJbHeQ7dvIbAO0/ck237qyqAMPk5Qm+NHBI4dGE0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1617285319; 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=CK/i3nsbShVKC/yMEi1T0O3Tnmco/F1Npz45uGyfiCM=; b=ar9dQKZt3RMfJcslX8ILXmsQ6xBiKxPE3As+mnqxRx3oKpAOm9yRcwRBOlrOngLGVkYoBbNMEt0hNnJddblT66bsVwgRntiadqjVAPf8g/7WIJqDoVr/wjoHJD1qE9f5i1q0q/73S+GevvBdUK2StqvPEHq1EGlQPUs7EeJa3+w= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.124 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-124.mimecast.com (us-smtp-delivery-124.mimecast.com [63.128.21.124]) by mx.zohomail.com with SMTPS id 1617285319393280.71926552412606; Thu, 1 Apr 2021 06:55: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-508-96TM_4YlMiWYAg_Ido_KyA-1; Thu, 01 Apr 2021 09:55:15 -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 F0B49107B7C9; Thu, 1 Apr 2021 13:55:07 +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 C45C65944C; Thu, 1 Apr 2021 13:55:07 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 68E0C18155DD; Thu, 1 Apr 2021 13:55:07 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 131DsHDd023610 for ; Thu, 1 Apr 2021 09:54:17 -0400 Received: by smtp.corp.redhat.com (Postfix) id 3D3D35C239; Thu, 1 Apr 2021 13:54:17 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.33]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8D98E5C1A1 for ; Thu, 1 Apr 2021 13:54:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1617285318; 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=CK/i3nsbShVKC/yMEi1T0O3Tnmco/F1Npz45uGyfiCM=; b=TzmZwBqtJez7okdKcrXK3IT8AxKFSp53GlDHykfYptp8PoiAssBp/J/FGVrYKEuBtmmIAf v9afkOMMJYydU2gcSUuQUqf/SJO11/jhm5ozxOnrJ6a2yZD1N9hohizEaUo+5WM2H8wBVN MfKuaxMknQhO3B3h+fGSss4XtQHfDZ8= X-MC-Unique: 96TM_4YlMiWYAg_Ido_KyA-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 31/39] util: virresctrl: Remove empty 'cleanup' sections Date: Thu, 1 Apr 2021 15:52:30 +0200 Message-Id: <69d420d3a2d3ff7a1f1494a6b77087400dd521cf.1617285119.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 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: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/util/virresctrl.c | 111 +++++++++++++++--------------------------- 1 file changed, 39 insertions(+), 72 deletions(-) diff --git a/src/util/virresctrl.c b/src/util/virresctrl.c index 6d8e669852..73b0061937 100644 --- a/src/util/virresctrl.c +++ b/src/util/virresctrl.c @@ -527,7 +527,6 @@ virResctrlGetCacheInfo(virResctrlInfoPtr resctrl, DIR *dirp) { int rv =3D -1; - int ret =3D -1; struct dirent *ent =3D NULL; while ((rv =3D virDirRead(dirp, &ent, SYSFS_RESCTRL_PATH "/info")) > 0= ) { @@ -568,7 +567,7 @@ virResctrlGetCacheInfo(virResctrlInfoPtr resctrl, ent->d_name); } else if (rv < 0) { /* Other failures are fatal, so just quit */ - goto cleanup; + return -1; } rv =3D virFileReadValueString(&cbm_mask_str, @@ -584,14 +583,14 @@ virResctrlGetCacheInfo(virResctrlInfoPtr resctrl, _("Cannot get cbm_mask from resctrl cache info"= )); } if (rv < 0) - goto cleanup; + return -1; virStringTrimOptionalNewline(cbm_mask_str); if (!(cbm_mask_map =3D virBitmapNewString(cbm_mask_str))) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Cannot parse cbm_mask from resctrl cache inf= o")); - goto cleanup; + return -1; } i_type->bits =3D virBitmapCountBits(cbm_mask_map); @@ -603,7 +602,7 @@ virResctrlGetCacheInfo(virResctrlInfoPtr resctrl, virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Cannot get min_cbm_bits from resctrl cache i= nfo")); if (rv < 0) - goto cleanup; + return -1; if (resctrl->nlevels <=3D level) VIR_EXPAND_N(resctrl->levels, resctrl->nlevels, @@ -624,22 +623,19 @@ virResctrlGetCacheInfo(virResctrlInfoPtr resctrl, virReportError(VIR_ERR_INTERNAL_ERROR, _("Duplicate cache type in resctrl for level %u= "), level); - goto cleanup; + return -1; } i_level->types[type] =3D g_steal_pointer(&i_type); } - ret =3D 0; - cleanup: - return ret; + return 0; } static int virResctrlGetMemoryBandwidthInfo(virResctrlInfoPtr resctrl) { - int ret =3D -1; int rv =3D -1; g_autofree virResctrlInfoMemBWPtr i_membw =3D NULL; @@ -652,11 +648,10 @@ virResctrlGetMemoryBandwidthInfo(virResctrlInfoPtr re= sctrl) * probably memory bandwidth allocation unsupported */ VIR_INFO("The path '" SYSFS_RESCTRL_PATH "/info/MB/bandwidth_gran'" "does not exist"); - ret =3D 0; - goto cleanup; + return 0; } else if (rv < 0) { /* Other failures are fatal, so just quit */ - goto cleanup; + return -1; } rv =3D virFileReadValueUint(&i_membw->min_bandwidth, @@ -669,7 +664,7 @@ virResctrlGetMemoryBandwidthInfo(virResctrlInfoPtr resc= trl) _("Cannot get min bandwidth from resctrl memory inf= o")); } if (rv < 0) - goto cleanup; + return -1; rv =3D virFileReadValueUint(&i_membw->max_allocation, SYSFS_RESCTRL_PATH "/info/MB/num_closids"); @@ -679,12 +674,10 @@ virResctrlGetMemoryBandwidthInfo(virResctrlInfoPtr re= sctrl) _("Cannot get max allocation from resctrl memory in= fo")); } if (rv < 0) - goto cleanup; + return -1; resctrl->membw_info =3D g_steal_pointer(&i_membw); - ret =3D 0; - cleanup: - return ret; + return 0; } @@ -702,7 +695,6 @@ virResctrlGetMemoryBandwidthInfo(virResctrlInfoPtr resc= trl) static int virResctrlGetMonitorInfo(virResctrlInfoPtr resctrl) { - int ret =3D -1; int rv =3D -1; g_autofree char *featurestr =3D NULL; g_auto(GStrv) features =3D NULL; @@ -721,11 +713,10 @@ virResctrlGetMonitorInfo(virResctrlInfoPtr resctrl) * monitor unsupported */ VIR_INFO("The file '" SYSFS_RESCTRL_PATH "/info/L3_MON/num_rmids' " "does not exist"); - ret =3D 0; - goto cleanup; + return 0; } else if (rv < 0) { /* Other failures are fatal, so just quit */ - goto cleanup; + return -1; } rv =3D virFileReadValueUint(&info_monitor->cache_reuse_threshold, @@ -737,7 +728,7 @@ virResctrlGetMonitorInfo(virResctrlInfoPtr resctrl) VIR_DEBUG("File '" SYSFS_RESCTRL_PATH "/info/L3_MON/max_threshold_occupancy' does not exist"); } else if (rv < 0) { - goto cleanup; + return -1; } rv =3D virFileReadValueString(&featurestr, @@ -747,14 +738,14 @@ virResctrlGetMonitorInfo(virResctrlInfoPtr resctrl) virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Cannot get mon_features from resctrl")); if (rv < 0) - goto cleanup; + return -1; if (!*featurestr) { /* If no feature found in "/info/L3_MON/mon_features", * some error happens */ virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Got empty feature list from resctrl")); - goto cleanup; + return -1; } features =3D virStringSplitCount(featurestr, "\n", 0, &nfeatures); @@ -764,9 +755,7 @@ virResctrlGetMonitorInfo(virResctrlInfoPtr resctrl) info_monitor->features =3D g_steal_pointer(&features); resctrl->monitor_info =3D g_steal_pointer(&info_monitor); - ret =3D 0; - cleanup: - return ret; + return 0; } @@ -1480,7 +1469,6 @@ virResctrlAllocParseMemoryBandwidthLine(virResctrlInf= oPtr resctrl, char *tmp =3D NULL; size_t nmbs =3D 0; size_t i; - int ret =3D -1; /* For no reason there can be spaces */ virSkipSpaces((const char **) &line); @@ -1508,12 +1496,10 @@ virResctrlAllocParseMemoryBandwidthLine(virResctrlI= nfoPtr resctrl, mbs =3D virStringSplitCount(tmp, ";", 0, &nmbs); for (i =3D 0; i < nmbs; i++) { if (virResctrlAllocParseProcessMemoryBandwidth(resctrl, alloc, mbs= [i]) < 0) - goto cleanup; + return -1; } - ret =3D 0; - cleanup: - return ret; + return 0; } @@ -1591,7 +1577,6 @@ virResctrlAllocParseProcessCache(virResctrlInfoPtr re= sctrl, char *tmp =3D strchr(cache, '=3D'); unsigned int cache_id =3D 0; g_autoptr(virBitmap) mask =3D NULL; - int ret =3D -1; if (!tmp) return 0; @@ -1617,17 +1602,15 @@ virResctrlAllocParseProcessCache(virResctrlInfoPtr = resctrl, _("Missing or inconsistent resctrl info for " "level '%u' type '%s'"), level, virCacheTypeToString(type)); - goto cleanup; + return -1; } virBitmapShrink(mask, resctrl->levels[level]->types[type]->bits); if (virResctrlAllocUpdateMask(alloc, level, type, cache_id, mask) < 0) - goto cleanup; + return -1; - ret =3D 0; - cleanup: - return ret; + return 0; } @@ -1642,7 +1625,6 @@ virResctrlAllocParseCacheLine(virResctrlInfoPtr resct= rl, int type =3D -1; size_t ncaches =3D 0; size_t i =3D 0; - int ret =3D -1; /* For no reason there can be spaces */ virSkipSpaces((const char **) &line); @@ -1680,12 +1662,10 @@ virResctrlAllocParseCacheLine(virResctrlInfoPtr res= ctrl, for (i =3D 0; i < ncaches; i++) { if (virResctrlAllocParseProcessCache(resctrl, alloc, level, type, = caches[i]) < 0) - goto cleanup; + return -1; } - ret =3D 0; - cleanup: - return ret; + return 0; } @@ -1697,20 +1677,16 @@ virResctrlAllocParse(virResctrlInfoPtr resctrl, g_auto(GStrv) lines =3D NULL; size_t nlines =3D 0; size_t i =3D 0; - int ret =3D -1; lines =3D virStringSplitCount(schemata, "\n", 0, &nlines); for (i =3D 0; i < nlines; i++) { if (virResctrlAllocParseCacheLine(resctrl, alloc, lines[i]) < 0) - goto cleanup; + return -1; if (virResctrlAllocParseMemoryBandwidthLine(resctrl, alloc, lines[= i]) < 0) - goto cleanup; - + return -1; } - ret =3D 0; - cleanup: - return ret; + return 0; } @@ -1943,7 +1919,6 @@ virResctrlAllocFindUnused(virResctrlAllocPtr alloc, ssize_t pos =3D -1; ssize_t last_bits =3D 0; ssize_t last_pos =3D -1; - int ret =3D -1; if (!size) return 0; @@ -2037,11 +2012,9 @@ virResctrlAllocFindUnused(virResctrlAllocPtr alloc, ignore_value(virBitmapSetBit(a_mask, i)); if (virResctrlAllocUpdateMask(alloc, level, type, cache, a_mask) < 0) - goto cleanup; + return -1; - ret =3D 0; - cleanup: - return ret; + return 0; } @@ -2174,7 +2147,6 @@ static int virResctrlAllocAssign(virResctrlInfoPtr resctrl, virResctrlAllocPtr alloc) { - int ret =3D -1; unsigned int level =3D 0; g_autoptr(virResctrlAlloc) alloc_free =3D NULL; g_autoptr(virResctrlAlloc) alloc_default =3D NULL; @@ -2185,16 +2157,16 @@ virResctrlAllocAssign(virResctrlInfoPtr resctrl, alloc_default =3D virResctrlAllocGetDefault(resctrl); if (!alloc_default) - goto cleanup; + return -1; if (virResctrlAllocMemoryBandwidth(resctrl, alloc) < 0) - goto cleanup; + return -1; if (virResctrlAllocCopyMasks(alloc, alloc_default) < 0) - goto cleanup; + return -1; if (virResctrlAllocCopyMemBW(alloc, alloc_default) < 0) - goto cleanup; + return -1; for (level =3D 0; level < alloc->nlevels; level++) { virResctrlAllocPerLevelPtr a_level =3D alloc->levels[level]; @@ -2211,7 +2183,7 @@ virResctrlAllocAssign(virResctrlInfoPtr resctrl, virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("Cache level %d does not support tuning"), level); - goto cleanup; + return -1; } for (type =3D 0; type < VIR_CACHE_TYPE_LAST; type++) { @@ -2227,7 +2199,7 @@ virResctrlAllocAssign(virResctrlInfoPtr resctrl, _("Cache level %d does not support tuning f= or " "scope type '%s'"), level, virCacheTypeToString(type)); - goto cleanup; + return -1; } for (cache =3D 0; cache < a_type->nsizes; cache++) { @@ -2235,14 +2207,12 @@ virResctrlAllocAssign(virResctrlInfoPtr resctrl, virResctrlInfoPerTypePtr i_type =3D i_level->types[type]; if (virResctrlAllocFindUnused(alloc, i_type, f_type, level= , type, cache) < 0) - goto cleanup; + return -1; } } } - ret =3D 0; - cleanup: - return ret; + return 0; } @@ -2376,7 +2346,6 @@ virResctrlAddPID(const char *path, { g_autofree char *tasks =3D NULL; g_autofree char *pidstr =3D NULL; - int ret =3D 0; if (!path) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", @@ -2392,12 +2361,10 @@ virResctrlAddPID(const char *path, virReportSystemError(errno, _("Cannot write pid in tasks file '%s'"), tasks); - goto cleanup; + return -1; } - ret =3D 0; - cleanup: - return ret; + return 0; } --=20 2.29.2 From nobody Mon Feb 9 10:24:32 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1617285334; cv=none; d=zohomail.com; s=zohoarc; b=Y4MOfhmklrK/fJm3yYdSuePU2e1tmCcV6RN5OEcj2xG4K1da1BegcFcSPa8uHV9m09v2JzSwZ7FyeRoAX3agsIypGnOfqrQXtF/cJlrIniyrK91Bn9IDEOxSjyRnKVJK83XjSCqSIMBlotzMShKhx6z4uALhqqkxMS0uzHJqo54= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1617285334; 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=RVTRUS55wLFoPs+KXUkj3EUE/Lsb3URIil9eG8WdvT0=; b=KXaAC+JXUEwDVL7SsLEo7or7dp+TYSY/DccxAciE+POog3Lc0ID1/cdedrvYgz2wGVS4dxqQ8ZbHOpspnVDk1KTq4nxeD7FJEWhvaav6WsFo3sS3RP48GskzJMVIeHepMVIXFeTjo9CPQZyYpids1G0nZii4jhV3+sAXO73sC3Q= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 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-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mx.zohomail.com with SMTPS id 1617285334679670.6799648309802; Thu, 1 Apr 2021 06:55: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-195-erYja64UMUeJYduiax9HwQ-1; Thu, 01 Apr 2021 09:55:31 -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 E68CEA40E6; Thu, 1 Apr 2021 13:55:19 +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 BEC7651C41; Thu, 1 Apr 2021 13:55:19 +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 787DD1809C84; Thu, 1 Apr 2021 13:55:19 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 131DsITG023632 for ; Thu, 1 Apr 2021 09:54:18 -0400 Received: by smtp.corp.redhat.com (Postfix) id 47A385C238; Thu, 1 Apr 2021 13:54:18 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.33]) by smtp.corp.redhat.com (Postfix) with ESMTP id A6DDA1DB for ; Thu, 1 Apr 2021 13:54:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1617285333; 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=RVTRUS55wLFoPs+KXUkj3EUE/Lsb3URIil9eG8WdvT0=; b=d2V4te7mLkEeIwqePHVos2pAiwceLnHssBRrHFEmnMjQjw1Eca9ags6zRTyzjMT9/NLIZA vqYpfrmdnXzIoqX6GFQA89h0jq3UQru5u3yxUD7Cw2seuHAe5SNnqCtEI8JC6zWvNmTClu P61V1ga+8mNU07I0AykbHgDcJyInuVA= X-MC-Unique: erYja64UMUeJYduiax9HwQ-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 32/39] util: virresctrl: Use g_strsplit instead of virStringSplitCount Date: Thu, 1 Apr 2021 15:52:31 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 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" In 3 of 4 instances the code didn't even need the count of the elements. Signed-off-by: Peter Krempa --- src/util/virresctrl.c | 38 ++++++++++++++++---------------------- 1 file changed, 16 insertions(+), 22 deletions(-) diff --git a/src/util/virresctrl.c b/src/util/virresctrl.c index 73b0061937..7891bc7411 100644 --- a/src/util/virresctrl.c +++ b/src/util/virresctrl.c @@ -697,8 +697,6 @@ virResctrlGetMonitorInfo(virResctrlInfoPtr resctrl) { int rv =3D -1; g_autofree char *featurestr =3D NULL; - g_auto(GStrv) features =3D NULL; - size_t nfeatures =3D 0; g_autofree virResctrlInfoMongrpPtr info_monitor =3D NULL; info_monitor =3D g_new0(virResctrlInfoMongrp, 1); @@ -748,11 +746,10 @@ virResctrlGetMonitorInfo(virResctrlInfoPtr resctrl) return -1; } - features =3D virStringSplitCount(featurestr, "\n", 0, &nfeatures); - VIR_DEBUG("Resctrl supported %zd monitoring features", nfeatures); + info_monitor->features =3D g_strsplit(featurestr, "\n", 0); + info_monitor->nfeatures =3D g_strv_length(info_monitor->features); + VIR_DEBUG("Resctrl supported %zd monitoring features", info_monitor->n= features); - info_monitor->nfeatures =3D nfeatures; - info_monitor->features =3D g_steal_pointer(&features); resctrl->monitor_info =3D g_steal_pointer(&info_monitor); return 0; @@ -1466,9 +1463,8 @@ virResctrlAllocParseMemoryBandwidthLine(virResctrlInf= oPtr resctrl, char *line) { g_auto(GStrv) mbs =3D NULL; + GStrv next; char *tmp =3D NULL; - size_t nmbs =3D 0; - size_t i; /* For no reason there can be spaces */ virSkipSpaces((const char **) &line); @@ -1493,9 +1489,9 @@ virResctrlAllocParseMemoryBandwidthLine(virResctrlInf= oPtr resctrl, return 0; tmp++; - mbs =3D virStringSplitCount(tmp, ";", 0, &nmbs); - for (i =3D 0; i < nmbs; i++) { - if (virResctrlAllocParseProcessMemoryBandwidth(resctrl, alloc, mbs= [i]) < 0) + mbs =3D g_strsplit(tmp, ";", 0); + for (next =3D mbs; *next; next++) { + if (virResctrlAllocParseProcessMemoryBandwidth(resctrl, alloc, *ne= xt) < 0) return -1; } @@ -1620,11 +1616,10 @@ virResctrlAllocParseCacheLine(virResctrlInfoPtr res= ctrl, char *line) { g_auto(GStrv) caches =3D NULL; + GStrv next; char *tmp =3D NULL; unsigned int level =3D 0; int type =3D -1; - size_t ncaches =3D 0; - size_t i =3D 0; /* For no reason there can be spaces */ virSkipSpaces((const char **) &line); @@ -1656,12 +1651,12 @@ virResctrlAllocParseCacheLine(virResctrlInfoPtr res= ctrl, return -1; } - caches =3D virStringSplitCount(tmp, ";", 0, &ncaches); + caches =3D g_strsplit(tmp, ";", 0); if (!caches) return 0; - for (i =3D 0; i < ncaches; i++) { - if (virResctrlAllocParseProcessCache(resctrl, alloc, level, type, = caches[i]) < 0) + for (next =3D caches; *next; next++) { + if (virResctrlAllocParseProcessCache(resctrl, alloc, level, type, = *next) < 0) return -1; } @@ -1675,14 +1670,13 @@ virResctrlAllocParse(virResctrlInfoPtr resctrl, const char *schemata) { g_auto(GStrv) lines =3D NULL; - size_t nlines =3D 0; - size_t i =3D 0; + GStrv next; - lines =3D virStringSplitCount(schemata, "\n", 0, &nlines); - for (i =3D 0; i < nlines; i++) { - if (virResctrlAllocParseCacheLine(resctrl, alloc, lines[i]) < 0) + lines =3D g_strsplit(schemata, "\n", 0); + for (next =3D lines; *next; next++) { + if (virResctrlAllocParseCacheLine(resctrl, alloc, *next) < 0) return -1; - if (virResctrlAllocParseMemoryBandwidthLine(resctrl, alloc, lines[= i]) < 0) + if (virResctrlAllocParseMemoryBandwidthLine(resctrl, alloc, *next)= < 0) return -1; } --=20 2.29.2 From nobody Mon Feb 9 10:24:32 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1617285372; cv=none; d=zohomail.com; s=zohoarc; b=UQsqk1DfuvWBdQjqPcbuJnLN7PICCcmQGeBwNWhr7PMnHbO5hkihYJWJg76uobPMSo0Tb6UGjgjoLcRHv+axdnWiz1Im4d3NqEXAZEucs1+qjB6iwJhYGodtxdYASqRdHSpsX1lAoXGGpwA5xwsvf8UDiECR88/u701o0CG3pvo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1617285372; 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=97Hi8wwvS9dfYW72BhZlT4S1MHA9l+WbYfQF4RPd7vY=; b=CmTpYQ4JsnM75gXGgxiZolrBjBcMNTJb0x+qcgmsSzhj1YmPQu8lhjvFqN9DZ4DzyvpAE1kGyVQXKMfufnAbk+XwDWOjhlbSG2FtN9ZbMVPRbmyCQpyS7CsegZGZBf6pq2+4Rl0MJzqZKPMjIWLDwDUGRymWskJCD2oeSvsmVvo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 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-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mx.zohomail.com with SMTPS id 1617285372796258.15947374077996; Thu, 1 Apr 2021 06:56: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-214-IinCpd4POLOH4yMbvd0l6A-1; Thu, 01 Apr 2021 09:55:28 -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 2EF2CA40ED; Thu, 1 Apr 2021 13:55:23 +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 08A185DAA5; Thu, 1 Apr 2021 13:55: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 BF1C94A707; Thu, 1 Apr 2021 13:55:22 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 131DsJfp023646 for ; Thu, 1 Apr 2021 09:54:19 -0400 Received: by smtp.corp.redhat.com (Postfix) id 64B565C237; Thu, 1 Apr 2021 13:54:19 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.33]) by smtp.corp.redhat.com (Postfix) with ESMTP id B52155C1A1 for ; Thu, 1 Apr 2021 13:54:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1617285371; 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=97Hi8wwvS9dfYW72BhZlT4S1MHA9l+WbYfQF4RPd7vY=; b=iflMXIp5U/HuOPkzznLCAPHZ79/PWYRSCZBDbFspvKuueN64hovj6/RvNhPVooQOqg/UJj b5Poya3pk7x806V1AH0Ki5ssywSEmiWasR0DDoJPI0+wZC4mipVQmGjZ9aUnfZnEeKG5iU EYcY7VtjfHEgGHhbSZ4cRjDxMkuzgto= X-MC-Unique: IinCpd4POLOH4yMbvd0l6A-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 33/39] xenParsePCI: Replace virStringSplitCount by g_strsplit Date: Thu, 1 Apr 2021 15:52:32 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 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" Count the number of elements in place just for the check. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/libxl/xen_common.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/libxl/xen_common.c b/src/libxl/xen_common.c index 835f48ec42..49a816add2 100644 --- a/src/libxl/xen_common.c +++ b/src/libxl/xen_common.c @@ -372,7 +372,6 @@ xenParsePCI(char *entry) virDomainHostdevDefPtr hostdev =3D NULL; g_auto(GStrv) tokens =3D NULL; g_auto(GStrv) options =3D NULL; - size_t ntokens =3D 0; size_t nexttoken =3D 0; char *str; char *nextstr; @@ -383,11 +382,11 @@ xenParsePCI(char *entry) virTristateBool filtered =3D VIR_TRISTATE_BOOL_ABSENT; /* pci=3D['00:1b.0','0000:00:13.0,permissive=3D1'] */ - if (!(tokens =3D virStringSplitCount(entry, ":", 3, &ntokens))) + if (!(tokens =3D g_strsplit(entry, ":", 3))) return NULL; /* domain */ - if (ntokens =3D=3D 3) { + if (g_strv_length(tokens) =3D=3D 3) { if (virStrToLong_i(tokens[nexttoken], NULL, 16, &domain) < 0) return NULL; nexttoken++; --=20 2.29.2 From nobody Mon Feb 9 10:24:32 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1617285366; cv=none; d=zohomail.com; s=zohoarc; b=RjDvKx7vYvmt65MTCPcCmvZx9wv+Ucsq7K2dex2EM7iy0WpLMem3VvXwqYjwDsxj1epA8k0zvBKVUT7OpaNVlo/4/tOG4y7DXhkGn3097oOJfrcvGUu6e1+4U/DTUJvyHH+Waqf1YvI2tUPUy6u1f1Vw3AF9AEssgOpqcYPRBI0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1617285366; 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=q0YCMYjnyRNaiEAWl36T92N5TNfxm4oFIk/d5ELTO2w=; b=HKH6CjDSqBvC67FvbXPBPeQz92tdqiHbRA/1W58HXGF8PdJF/Qup98sVZx2QMsdiZC/yh9iB9fTx8ycZA5EiBPkeVKQP5zGJx9mkOhpA03Tjds9wA+KAlzU/mOzgf3hso+JhXvagYvIznmsZgBLVZCmGETOVdZuzqrPrUo2ZYio= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 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-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mx.zohomail.com with SMTPS id 1617285366524679.4343039702364; Thu, 1 Apr 2021 06:56: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-326-uBzGLLO7PL2WzAtKGf3hlA-1; Thu, 01 Apr 2021 09:55:31 -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 76E211084D69; Thu, 1 Apr 2021 13:55:12 +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 41F611001281; Thu, 1 Apr 2021 13:55: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 DBFC2180C5A5; Thu, 1 Apr 2021 13:55:11 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 131DsKwk023656 for ; Thu, 1 Apr 2021 09:54:20 -0400 Received: by smtp.corp.redhat.com (Postfix) id 711A35C237; Thu, 1 Apr 2021 13:54:20 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.33]) by smtp.corp.redhat.com (Postfix) with ESMTP id CF4555C1A1 for ; Thu, 1 Apr 2021 13:54:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1617285365; 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=q0YCMYjnyRNaiEAWl36T92N5TNfxm4oFIk/d5ELTO2w=; b=T45BC0rW0cvH7Lnf+k2GWPCPI7gM06ajWctAm/knFpazj7cKh/EDh5OuVaJlIUI3GepcRJ qFbPD0rViLpPsvYDR/pZhS7cSgvniX1oh4VbsYJjT50rgplNHRykkL3Wq9fXrC4go8mMkV /QkKU9gv3irttyOy2UZNcy9Q3/V0gwU= X-MC-Unique: uBzGLLO7PL2WzAtKGf3hlA-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 34/39] xenParseXLVnuma: Replace virStringSplitCount by g_strsplit Date: Thu, 1 Apr 2021 15:52:33 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 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: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/libxl/xen_xl.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/libxl/xen_xl.c b/src/libxl/xen_xl.c index 65cd26bb21..e8a75979d4 100644 --- a/src/libxl/xen_xl.c +++ b/src/libxl/xen_xl.c @@ -523,9 +523,11 @@ xenParseXLVnuma(virConfPtr conf, tmp =3D g_strdup(vtoken); g_strfreev(token); - if (!(token =3D virStringSplitCount(tmp, ",", 0, &= ndistances))) + if (!(token =3D g_strsplit(tmp, ",", 0))) goto cleanup; + ndistances =3D g_strv_length(token); + if (ndistances !=3D nr_nodes) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("vnuma pnode %d configured '%s' (= count %zu) doesn't fit the number of specified vnodes %zu"), --=20 2.29.2 From nobody Mon Feb 9 10:24:32 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) client-ip=63.128.21.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1617285326; cv=none; d=zohomail.com; s=zohoarc; b=HzAAl1RLLe6Wal0YLzjVO0HzAia8Dnozv7Pb5byoozWfekZgLOp1tL8BEkVq021PdrLGbz70NgoX1qeIhTVtGQsbG32RrwOMXJZVTdQSIbSCeQhciPCMI1SYZFibw1co6oZoPn6+83Of9Oy4YSQ3ohdwD6zjr8t3sNXXA/ngbdE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1617285326; 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=bbZGAEPHNz8Hq7GKGKMk9egU4r1ig98zogpCfi08jAY=; b=I8hmctpXKmlksL1aaPVdoDhgi8NRlHjmQ/5GhStDwPPmGONHcJ0XP4rZi6OJY9HS+gO0zVgR4Hx2fAl+95nZq5JEQJYI1EhDWXA4nJcMPCwIy5Et/5qEbYCQWeuNK6dAhAMVeAnqCKm29ItKj/fOGxQhnP7MeZvwQmE1SB+54c4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.124 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-124.mimecast.com (us-smtp-delivery-124.mimecast.com [63.128.21.124]) by mx.zohomail.com with SMTPS id 1617285326435130.9007626780516; Thu, 1 Apr 2021 06:55: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-442-3d7r9HJVMMCJmG0wQLJ30w-1; Thu, 01 Apr 2021 09:55: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 52316801FD8; Thu, 1 Apr 2021 13:55:16 +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 02BC55C238; Thu, 1 Apr 2021 13:55:16 +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 B826C18045CA; Thu, 1 Apr 2021 13:55:15 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 131DsLq6023666 for ; Thu, 1 Apr 2021 09:54:21 -0400 Received: by smtp.corp.redhat.com (Postfix) id 84A6F5C237; Thu, 1 Apr 2021 13:54:21 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.33]) by smtp.corp.redhat.com (Postfix) with ESMTP id DF1245C1A1 for ; Thu, 1 Apr 2021 13:54:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1617285325; 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=bbZGAEPHNz8Hq7GKGKMk9egU4r1ig98zogpCfi08jAY=; b=KoK0ZohgkhHGFmDI3OTS5wA6a7P7DsNjvNP+fQbDAEJp9SDGvXdF2J7yAE4eKNw9s1evl9 Vulj+Uv7lJFrfYCghFl0Nf3lGINOeofc0/UFS5cM3lrPG4vtvtdGkoXF3QHGkPoLUy10jg 3wtqXjsl1xhq+tbFXwUOSXdjng3n+bQ= X-MC-Unique: 3d7r9HJVMMCJmG0wQLJ30w-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 35/39] openvzParseBarrierLimit: Rework string handling Date: Thu, 1 Apr 2021 15:52:34 +0200 Message-Id: <560a81e55b53d0c07f77bdd61dbadba145e7954f.1617285119.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 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" Use g_strsplit instead of virStringSplitCount and automatically free the temporary string list. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/openvz/openvz_conf.c | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/src/openvz/openvz_conf.c b/src/openvz/openvz_conf.c index 836885af18..cf29ce30ad 100644 --- a/src/openvz/openvz_conf.c +++ b/src/openvz/openvz_conf.c @@ -123,26 +123,21 @@ openvzParseBarrierLimit(const char* value, unsigned long long *barrier, unsigned long long *limit) { - char **tmp =3D NULL; - size_t ntmp =3D 0; - int ret =3D -1; + g_auto(GStrv) tmp =3D NULL; - if (!(tmp =3D virStringSplitCount(value, ":", 0, &ntmp))) - goto error; + if (!(tmp =3D g_strsplit(value, ":", 0))) + return -1; - if (ntmp !=3D 2) - goto error; + if (g_strv_length(tmp) !=3D 2) + return -1; if (barrier && virStrToLong_ull(tmp[0], NULL, 10, barrier) < 0) - goto error; + return -1; if (limit && virStrToLong_ull(tmp[1], NULL, 10, limit) < 0) - goto error; + return -1; - ret =3D 0; - error: - virStringListFreeCount(tmp, ntmp); - return ret; + return 0; } --=20 2.29.2 From nobody Mon Feb 9 10:24:32 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1617285424; cv=none; d=zohomail.com; s=zohoarc; b=bjlhj0CVqzHoVLFS5TqeWS+zJye3/p9v/liYcZqd9YST44UfcKK0iojQBnS6XUAZoKZ9WebGMiN/RugIOqLn5YePr2aNB5nygzV4ng03AXVo7yRLMK5w6pxlGiPgjKtkPFdv2WkVBwmxwAG3odWm1UGC6MIiIXMe4LL3m1Z5L0Y= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1617285424; 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=twsGclirYIQSM6/IJ2wYEItPD2XB2+iyenSygHrEi04=; b=gyucmZ4cCXVcBJ16dQwQxXYmV3pIn8xhs9B6TpEm0x2LEaEj8iuubd9OoRZ8IUinoOs4m//Y6UjAJksN7p86/OEmyy2t0NfR0HnypxsPf5dp8NwYSX3IjPFFEa3nQGwaTVXTDN3WA0bTHuchfl1sesE39YiywlkF+nrCKHjPw/k= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 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-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mx.zohomail.com with SMTPS id 1617285424752245.61029841797256; Thu, 1 Apr 2021 06:57: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-199-nTE0QsAeMfCmL0oTdhwD1w-1; Thu, 01 Apr 2021 09:55:33 -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 C6F7B1085985; Thu, 1 Apr 2021 13:55:19 +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 95D1019D7D; Thu, 1 Apr 2021 13:55:19 +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 272024A704; Thu, 1 Apr 2021 13:55:19 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 131DsMf8023677 for ; Thu, 1 Apr 2021 09:54:22 -0400 Received: by smtp.corp.redhat.com (Postfix) id 8D6605C237; Thu, 1 Apr 2021 13:54:22 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.33]) by smtp.corp.redhat.com (Postfix) with ESMTP id F15695C1A1 for ; Thu, 1 Apr 2021 13:54:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1617285423; 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=twsGclirYIQSM6/IJ2wYEItPD2XB2+iyenSygHrEi04=; b=G5iZBmapFg6VTuFaSAXf0H02hDlNNnt0rfq5/WK5hbtB+aiQXFXkRF+iSZ9sNKEJJpgpDx wrEj3yvPnYYqU0jd6La4N+2l8gdSEROeRAEcUhMVGSHDewcJqoj3CQfSD9n3DaLqj2LKrZ I8QsuT9lWL4yxJzUuNlI6jcbFwBp6Xo= X-MC-Unique: nTE0QsAeMfCmL0oTdhwD1w-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 36/39] virSystemdActivationInitFromNames: Replace virStringSplit by g_strsplit Date: Thu, 1 Apr 2021 15:52:35 +0200 Message-Id: <59dad78008c9c6b9420d6cbe61e2a3be0c61d110.1617285119.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 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" While the code invokes the string list length calculation twice, it happens only on error path, which by itself should never happen. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/util/virsystemd.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/util/virsystemd.c b/src/util/virsystemd.c index cf22edaa0a..718d24dfc5 100644 --- a/src/util/virsystemd.c +++ b/src/util/virsystemd.c @@ -754,19 +754,18 @@ virSystemdActivationInitFromNames(virSystemdActivatio= nPtr act, { g_auto(GStrv) fdnamelistptr =3D NULL; char **fdnamelist; - size_t nfdnames; size_t i; int nextfd =3D STDERR_FILENO + 1; VIR_DEBUG("FD names %s", fdnames); - if (!(fdnamelistptr =3D virStringSplitCount(fdnames, ":", 0, &nfdnames= ))) + if (!(fdnamelistptr =3D g_strsplit(fdnames, ":", 0))) goto error; - if (nfdnames !=3D nfds) { + if (g_strv_length(fdnamelistptr) !=3D nfds) { virReportError(VIR_ERR_INTERNAL_ERROR, - _("Expecting %d FD names but got %zu"), - nfds, nfdnames); + _("Expecting %d FD names but got %u"), + nfds, g_strv_length(fdnamelistptr)); goto error; } --=20 2.29.2 From nobody Mon Feb 9 10:24:32 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1617285293; cv=none; d=zohomail.com; s=zohoarc; b=BBXp+Ty2EdFgm33MNQuTh/Ktjsdy3HXBh/W97DtzaC4bB/iP/8cPz/z5rgBgFJXQ7NjbXWJKmbuUFVOX8p9Mbp8KKmgOSZxiAIrbhz5ZdCMGuc4S5Zsn/xCV2qVuag4UGbSu/XneJnkWUP9K6rBv32IA4G/5hQO5q1J6dXKDar0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1617285293; 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=uLOnqJMO/z3KcpzEE8cZBL/WFFuh1TRyVrxpuAkEhHU=; b=GM6+cUbLRfqsGqKz6gIfRExRo+90JbM4YIUVOg0dg/sknCkhY56TI09TI0MrkmOdP7+QgdVds6Pv5EGEHVqLmPOFTinxey7a/PjVZMt2q2UnBHvFA5lTtvWFHPl4QUK2kYUN8Si8LEddlrpqEB1btuc5LFA0Tpe95PpYn2AE+r0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 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-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1617285293901902.959441768115; Thu, 1 Apr 2021 06:54:53 -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-200-4YkY7vT_MuOQi6UXDz7OhA-1; Thu, 01 Apr 2021 09:54:50 -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 5D421101965A; Thu, 1 Apr 2021 13:54:27 +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 37ED15C1A1; Thu, 1 Apr 2021 13:54: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 E90754A701; Thu, 1 Apr 2021 13:54:26 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 131DsNRQ023687 for ; Thu, 1 Apr 2021 09:54:23 -0400 Received: by smtp.corp.redhat.com (Postfix) id 9E1B35C1A1; Thu, 1 Apr 2021 13:54:23 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.33]) by smtp.corp.redhat.com (Postfix) with ESMTP id 030515C237 for ; Thu, 1 Apr 2021 13:54:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1617285292; 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=uLOnqJMO/z3KcpzEE8cZBL/WFFuh1TRyVrxpuAkEhHU=; b=Nd779tE89vU8s3s9iU6B6tQMOewyFAfwRhHp0sF0MDCMKjjcGqeRgYX3naDyMJbuJba2Ul JHEOEUPzRg7BfwdNXlHQCa0NHY2KQQtfgInKpPTFzZtxLQXc9p8bHI3T8n58nzKLCo33lb PQVKhMF6ofcs0TGfPO7FsD9LE12lJeE= X-MC-Unique: 4YkY7vT_MuOQi6UXDz7OhA-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 37/39] virVMXParseConfig: Replace virStringSplitCount by g_strsplit Date: Thu, 1 Apr 2021 15:52:36 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 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" Remove the last usage of virStringSplitCount Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/vmx/vmx.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/vmx/vmx.c b/src/vmx/vmx.c index 0b12b5dd7d..7832fd143e 100644 --- a/src/vmx/vmx.c +++ b/src/vmx/vmx.c @@ -1574,18 +1574,17 @@ virVMXParseConfig(virVMXContext *ctx, if (sched_cpu_affinity !=3D NULL && STRCASENEQ(sched_cpu_affinity, "al= l")) { g_auto(GStrv) afflist =3D NULL; char **aff; - size_t naffs; def->cpumask =3D virBitmapNew(VIR_DOMAIN_CPUMASK_LEN); - if (!(afflist =3D virStringSplitCount(sched_cpu_affinity, ",", 0, = &naffs))) + if (!(afflist =3D g_strsplit(sched_cpu_affinity, ",", 0))) goto cleanup; - if (naffs < numvcpus) { + if (g_strv_length(afflist) < numvcpus) { virReportError(VIR_ERR_INTERNAL_ERROR, _("Expecting VMX entry 'sched.cpu.affinity' to = contain " "at least as many values as 'numvcpus' (%lld)= but " - "found only %zu value(s)"), numvcpus, naffs); + "found only %u value(s)"), numvcpus, g_strv_l= ength(afflist)); goto cleanup; } --=20 2.29.2 From nobody Mon Feb 9 10:24:32 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1617285411; cv=none; d=zohomail.com; s=zohoarc; b=YAnQ15VlEVaI1Y0BeDXQOe4JjQOd+DkgMT8pMd9dD70rpJrLOmshyY4Bk13SQ2Z9ZnWejrj3JmMIp/4JzhYUySCaDbV582un1GgAEHAA3rx44CZ4oz+6s+9js5rLB0AcidRbxEtirkZeh/zrYBsD6/aGdH0g2cXkEYcp7r+w4ik= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1617285411; 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=mynK+FEfGow++fE3hRCtchp602elUsMA1vstFfr8gmY=; b=GVNP9FI/ZqgsigwD3cwJjYBhhGzbuw0S7RDinI0WDg9jOhIFslWc9pA8eg41NJwi1wRcz612OBKbOekYA+7mHzoP+OVGkwILFam6Kr7zXM3zOOvuC/2GJCFohA3RnH/RmXxLRB4RfVF0HmM3EQHjmHNeYw+A0bLKzcA1vd1zF1M= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 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-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1617285411354146.51624720490247; Thu, 1 Apr 2021 06:56:51 -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-154-FZQEWtaLMMqIj5ZplnvXKg-1; Thu, 01 Apr 2021 09:55:31 -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 CDEDD19251A2; Thu, 1 Apr 2021 13:55: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 A7AD51B49D; Thu, 1 Apr 2021 13:55: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 6707C4A70A; Thu, 1 Apr 2021 13:55:26 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 131DsOov023696 for ; Thu, 1 Apr 2021 09:54:24 -0400 Received: by smtp.corp.redhat.com (Postfix) id B59625C1A1; Thu, 1 Apr 2021 13:54:24 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.33]) by smtp.corp.redhat.com (Postfix) with ESMTP id 215905C238 for ; Thu, 1 Apr 2021 13:54:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1617285410; 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=mynK+FEfGow++fE3hRCtchp602elUsMA1vstFfr8gmY=; b=eg9wR7Z2889mexI1TWKiD1sVaQYTmouBUD2xBviTm/N5d98eU2kmQi1tFxJbVhl5c3mxYp c6FPB7tPnv6/0702Vz15fYmjEa0ABk9HTIdEivSfYQMO+UybS6qH+A9hMCE+UuRUaIOVmW aJ0WGsxD7PCq3av3SLdR49mybsSWQjI= X-MC-Unique: FZQEWtaLMMqIj5ZplnvXKg-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 38/39] util: virstring: Remove the virStringSplitCount wrapper funcion Date: Thu, 1 Apr 2021 15:52:37 +0200 Message-Id: <76d9c2d4b2943ae4feb7c37677f5c59231831d63.1617285119.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 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" Callers which need the count of elements now count it in place. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/libvirt_private.syms | 1 - src/util/virstring.c | 20 -------------------- src/util/virstring.h | 6 ------ 3 files changed, 27 deletions(-) diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 9208db2056..68cdb92453 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -3260,7 +3260,6 @@ virStringReplace; virStringSearch; virStringSortCompare; virStringSortRevCompare; -virStringSplitCount; virStringStripControlChars; virStringStripIPv6Brackets; virStringStripSuffix; diff --git a/src/util/virstring.c b/src/util/virstring.c index 7749eb2db5..a2c07e5c17 100644 --- a/src/util/virstring.c +++ b/src/util/virstring.c @@ -35,26 +35,6 @@ VIR_LOG_INIT("util.string"); -/** - * virStringSplitCount: - * - * A wrapper for g_strsplit which provides number of elements of the split - * string. - */ -char ** -virStringSplitCount(const char *string, - const char *delim, - size_t max_tokens, - size_t *tokcount) -{ - GStrv ret =3D g_strsplit(string, delim, max_tokens); - - *tokcount =3D g_strv_length(ret); - - return ret; -} - - /** * virStringListMerge: * @dst: a NULL-terminated array of strings to expand diff --git a/src/util/virstring.h b/src/util/virstring.h index e688495574..7cc1d8c55f 100644 --- a/src/util/virstring.h +++ b/src/util/virstring.h @@ -22,12 +22,6 @@ #define VIR_INT64_STR_BUFLEN 21 -char **virStringSplitCount(const char *string, - const char *delim, - size_t max_tokens, - size_t *tokcount) - ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(4); - int virStringListMerge(char ***dst, char ***src); --=20 2.29.2 From nobody Mon Feb 9 10:24:32 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) client-ip=63.128.21.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1617285370; cv=none; d=zohomail.com; s=zohoarc; b=YLUiose1Jxeq7r1wpenDujm+gJB7hK/TSERusoj7YmodPswpviz/kNHvMpeLfpuW4NO31ts/nclXVc+VEgidFZXfPtDs+hF3l/GT86bnNyd6C0u5NVHBsT4cMcnOtBVOJDUtEd1nG+p1HkIDM2UNxgUP2TKHooC/JlfPWNej0mU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1617285370; 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=V0JbOzf0keds2nb5QyZtyEYfJ3Ur9K0YmBVf9rV29cA=; b=C+wa6VFcwIQxP3pRMOVga0rRsjvo9vjj7VFPIat2Joj6xj1ptptHb+HsZG8JjNFrED5BOQTKka4Hfu3vWfSeeEZBL2C5bLXH0j7G+85yXCdC1rFzf6FoK9Wo/DQOhy4JW+dAfbFcW+kUfScUJWYtMiOkoGGUHWvZ+x72UhN1QBM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.124 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-124.mimecast.com (us-smtp-delivery-124.mimecast.com [63.128.21.124]) by mx.zohomail.com with SMTPS id 1617285370348565.0893703622014; Thu, 1 Apr 2021 06:56: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-387-_WKldWtJNhyYI6DZwdMPkw-1; Thu, 01 Apr 2021 09:55:25 -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 EC2C6100CE96; Thu, 1 Apr 2021 13:54:30 +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 C59D95D6B1; Thu, 1 Apr 2021 13:54: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 844CC4A705; Thu, 1 Apr 2021 13:54:30 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 131DsPek023703 for ; Thu, 1 Apr 2021 09:54:25 -0400 Received: by smtp.corp.redhat.com (Postfix) id BEFB15C237; Thu, 1 Apr 2021 13:54:25 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.33]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2577D5C1A1 for ; Thu, 1 Apr 2021 13:54:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1617285369; 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=V0JbOzf0keds2nb5QyZtyEYfJ3Ur9K0YmBVf9rV29cA=; b=EI4UADZap5e/dB2WSAeC2fJLGlxZKAIWcD5wu6zrYk6Nv59d+yp5cLY9NJi71elNntRs11 iFoFl6hX/g8JV7ORB3E0rf775zQMWMGYnLye1sTnW6aYT9daQ38dKLtuzIF6BpTI9pDEEU sCXnDDlCucqzHqsfwv+CNVCAmecf1yI= X-MC-Unique: _WKldWtJNhyYI6DZwdMPkw-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 39/39] tests: string: Remove pointless test for virStringListFreeCount Date: Thu, 1 Apr 2021 15:52:38 +0200 Message-Id: <7275a662b02bd9e4c85336c005341a147bce1a75.1617285119.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 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" It's way more useful to run valgrind against the rest of the code than this test to see whether virStringListFreeCount works. Remove the test. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- tests/virstringtest.c | 23 ----------------------- 1 file changed, 23 deletions(-) diff --git a/tests/virstringtest.c b/tests/virstringtest.c index 82e8e2106f..83b883524d 100644 --- a/tests/virstringtest.c +++ b/tests/virstringtest.c @@ -392,24 +392,6 @@ testStringToDouble(const void *opaque) return ret; } -/* The point of this test is to check whether all members of the array are - * freed. The test has to be checked using valgrind. */ -static int -testVirStringListFreeCount(const void *opaque G_GNUC_UNUSED) -{ - char **list; - - list =3D g_new0(char *, 4); - - list[0] =3D g_strdup("test1"); - list[2] =3D g_strdup("test2"); - list[3] =3D g_strdup("test3"); - - virStringListFreeCount(list, 4); - - return 0; -} - struct testStripData { const char *string; @@ -718,11 +700,6 @@ mymain(void) NULL, 3.141592653589793238462643383279502884197169399375105); - /* test virStringListFreeCount */ - if (virTestRun("virStringListFreeCount", testVirStringListFreeCount, - NULL) < 0) - ret =3D -1; - #define TEST_STRIP_IPV6_BRACKETS(str, res) \ do { \ struct testStripData stripData =3D { \ --=20 2.29.2