From nobody Mon May 20 23:07:28 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1697443689; cv=none; d=zohomail.com; s=zohoarc; b=fmLFoD1sJqMaq8XqrCmMoiTVNHWgdnNmAf+8G/h/Q+Xy9zUfGxL+tMB+oQS9d8odzOaHfidcDPx94umWSQk3HlUF+GNsE0f54zgO2tZjajV4d3DVmMOk3sXVLa9ArUwcpW0hrXaI7rT2qMzEqE5hnWt5J7uUZ1TSJ5+0xsneRcE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1697443689; h=Content-Type:Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To:Cc; bh=V5D4wDoaKqKCvbLZ+QlxViiqiXnE7uNtvA10zn+3PFA=; b=bRq8vvFTz8s1DHkohOM/rdun++MuqHjOEj/p+JAiImAXrT3etZe7S9r+kUTCKPkcphilGpBzt9+A049Ebv0rEMPi197dfVd7KWa7SustLoFCunn/sjTIyf0o7rVCuY3IESYCKFVNGknPCVWmpFuoppunOIRVoEFq9VtxQ+3mR04= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mx.zohomail.com with SMTPS id 1697443689147148.28292792519903; Mon, 16 Oct 2023 01:08:09 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-519-uqHuy4CmNhSRqREmAW56JA-1; Mon, 16 Oct 2023 04:08:00 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 97E9F946DE8; Mon, 16 Oct 2023 08:07:57 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 82ADD1C060B1; Mon, 16 Oct 2023 08:07:56 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id B654E19465B2; Mon, 16 Oct 2023 08:07:54 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id DAD271946587 for ; Mon, 16 Oct 2023 08:07:53 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id CF3EA40C6F7F; Mon, 16 Oct 2023 08:07:53 +0000 (UTC) Received: from maggie.brq.redhat.com (unknown [10.43.2.56]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7713C40C6F79 for ; Mon, 16 Oct 2023 08:07:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1697443688; 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=V5D4wDoaKqKCvbLZ+QlxViiqiXnE7uNtvA10zn+3PFA=; b=J+4DsnxsbgpSV0Ci1BlwtUmUjusRg3B4U9pfXvvbYFez+Diw3bHBSMiZzw6qPAKFl9/jpd fmRuKKdNJD2js44PERQt/G6jeEg2kM1DJpO9g5CfAvN38+dETmDgjzpGJgyOX99ZyCp1eg QOxMiRkm1zB2OPKsMbTxgjW1DG+7ino= X-MC-Unique: uqHuy4CmNhSRqREmAW56JA-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH 1/4] lib: Replace virBuildPath() with g_build_filename() Date: Mon, 16 Oct 2023 10:07:48 +0200 Message-ID: <09f7c60acf633a9364d16f83bbfa3156c2ba0a28.1697443656.git.mprivozn@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.2 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.7 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1697443691038100001 Content-Type: text/plain; charset="utf-8"; x-default="true" Our virBuildPath() constructs a path from given arguments. Exactly like g_build_filename(), except the latter is more generic as it uses backslashes on Windows. Therefore, replace the former with the latter. Signed-off-by: Michal Privoznik Reviewed-by: J=C3=A1n Tomko Reviewed-by: Peter Krempa --- docs/kbase/internals/command.rst | 2 +- src/util/virfcp.c | 2 +- src/util/virhook.c | 4 ++-- src/util/virpci.c | 4 ++-- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/docs/kbase/internals/command.rst b/docs/kbase/internals/comman= d.rst index 738fb5930a..d958c9d16a 100644 --- a/docs/kbase/internals/command.rst +++ b/docs/kbase/internals/command.rst @@ -444,7 +444,7 @@ src/util/hooks.c g_autofree char *path =3D NULL; g_autoptr(virCommand) cmd =3D NULL; =20 - virBuildPath(&path, LIBVIRT_HOOK_DIR, drvstr); + path =3D g_build_filename(LIBVIRT_HOOK_DIR, drvstr); =20 cmd =3D virCommandNew(path); =20 diff --git a/src/util/virfcp.c b/src/util/virfcp.c index bb62fa9025..052a6c99e1 100644 --- a/src/util/virfcp.c +++ b/src/util/virfcp.c @@ -38,7 +38,7 @@ virFCIsCapableRport(const char *rport) { g_autofree char *path =3D NULL; =20 - virBuildPath(&path, SYSFS_FC_RPORT_PATH, rport); + path =3D g_build_filename(SYSFS_FC_RPORT_PATH, rport, NULL); =20 return virFileExists(path); } diff --git a/src/util/virhook.c b/src/util/virhook.c index 50e178723f..d012bb1825 100644 --- a/src/util/virhook.c +++ b/src/util/virhook.c @@ -153,7 +153,7 @@ virHookCheck(int no, const char *driver) return -1; } =20 - virBuildPath(&path, LIBVIRT_HOOK_DIR, driver); + path =3D g_build_filename(LIBVIRT_HOOK_DIR, driver, NULL); =20 if (!virFileExists(path)) { VIR_DEBUG("No hook script %s", path); @@ -398,7 +398,7 @@ virHookCall(int driver, if (extra =3D=3D NULL) extra =3D "-"; =20 - virBuildPath(&path, LIBVIRT_HOOK_DIR, drvstr); + path =3D g_build_filename(LIBVIRT_HOOK_DIR, drvstr, NULL); =20 script_ret =3D 1; =20 diff --git a/src/util/virpci.c b/src/util/virpci.c index 08b82708b1..baacde4c14 100644 --- a/src/util/virpci.c +++ b/src/util/virpci.c @@ -2396,7 +2396,7 @@ virPCIGetPhysicalFunction(const char *vf_sysfs_path, =20 *pf =3D NULL; =20 - virBuildPath(&device_link, vf_sysfs_path, "physfn"); + device_link =3D g_build_filename(vf_sysfs_path, "physfn", NULL); =20 if ((*pf =3D virPCIGetDeviceAddressFromSysfsLink(device_link))) { VIR_DEBUG("PF for VF device '%s': " VIR_PCI_DEVICE_ADDRESS_FMT, @@ -2580,7 +2580,7 @@ virPCIGetNetName(const char *device_link_sysfs_path, return -1; } =20 - virBuildPath(&pcidev_sysfs_net_path, device_link_sysfs_path, "net"); + pcidev_sysfs_net_path =3D g_build_filename(device_link_sysfs_path, "ne= t", NULL); =20 if (virDirOpenQuiet(&dir, pcidev_sysfs_net_path) < 0) { /* this *isn't* an error - caller needs to check for netname =3D= =3D NULL */ --=20 2.41.0 From nobody Mon May 20 23:07:28 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1697443764; cv=none; d=zohomail.com; s=zohoarc; b=bXdhqa+V2wQA0cDo+INiahxlS+xQ6Vtlo/UHY7d2AIs93bx2VELYj5PEsjZ9JQ7rgY3DSakFKNh2Rk8/54oTc7WjSNkiSUjEpKcQTj6GvZAwl7YI4BqriY/90+jj35iTp5g2II0oi6rQYvjBzM4X/5I4sZTjVkWv0r+FFgHdlaI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1697443764; h=Content-Type:Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To:Cc; bh=F62Jc21qoGR0WkM6e55InFkKF0v9zR8WV0RsxNrv8Bc=; b=h5RdpJIZjqAapmrklZcd4PcjSnApaURAHsc1A7z8TIk1Chotaf8ZiFCxfvQ6e4UPRdpicoZtC2C7ZbEOYn0dsZ/ZICbYsq2TVRRTM1aXMDkEF1TzrHZUCxrVTdFQkRG7ELK+GZfycob2jO9kxKHKxHEPMu7t7Z1sDw63M00xa1c= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mx.zohomail.com with SMTPS id 1697443764769244.63758361733016; Mon, 16 Oct 2023 01:09:24 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-16-bZehb_AgNxGsQXzfCggP3w-1; Mon, 16 Oct 2023 04:08:00 -0400 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 99F3E185A797; Mon, 16 Oct 2023 08:07:57 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 57C7E492BEE; Mon, 16 Oct 2023 08:07:57 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 088E919466EA; Mon, 16 Oct 2023 08:07:56 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 84259194658D for ; Mon, 16 Oct 2023 08:07:54 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 7242F40C6CA0; Mon, 16 Oct 2023 08:07:54 +0000 (UTC) Received: from maggie.brq.redhat.com (unknown [10.43.2.56]) by smtp.corp.redhat.com (Postfix) with ESMTP id 12B4640C6CA3 for ; Mon, 16 Oct 2023 08:07:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1697443763; 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=F62Jc21qoGR0WkM6e55InFkKF0v9zR8WV0RsxNrv8Bc=; b=NWrSZOSaukJxOxpvRTjhDIHOhB6CPzxbShWnRrxkFXn33QkHdFFOdNna1SQcUZstRi8CKh fGwabf+yZMhQNc3O8OScB6YAEW8t6DzIj5pJzX7mpjUBPUzPlNudnFfsAct5xrIdTlKR/B rXZr19NhF4h1rsKuh9UGDDXjTd1Tx8M= X-MC-Unique: bZehb_AgNxGsQXzfCggP3w-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH 2/4] virfile: Drop virBuildPathInternal() Date: Mon, 16 Oct 2023 10:07:49 +0200 Message-ID: <45b0ff0696ec4b129d7f27eb391013c633991178.1697443656.git.mprivozn@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.2 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.9 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1697443765258100001 Content-Type: text/plain; charset="utf-8"; x-default="true" After previous cleanup the virBuildPathInternal() function is no longer used. Drop it. Signed-off-by: Michal Privoznik Reviewed-by: J=C3=A1n Tomko Reviewed-by: Peter Krempa --- src/libvirt_private.syms | 1 - src/util/virfile.c | 22 ---------------------- src/util/virfile.h | 5 ----- 3 files changed, 28 deletions(-) diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 4e475d5b1a..553b01b8c0 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -2280,7 +2280,6 @@ virFDStreamSetInternalCloseCb; saferead; safewrite; safezero; -virBuildPathInternal; virCloseFrom; virCloseRange; virCloseRangeInit; diff --git a/src/util/virfile.c b/src/util/virfile.c index bd36a9a31a..54708652fb 100644 --- a/src/util/virfile.c +++ b/src/util/virfile.c @@ -1490,28 +1490,6 @@ virFileFindMountPoint(const char *type G_GNUC_UNUSED) =20 #endif /* defined WITH_MNTENT_H && defined WITH_GETMNTENT_R */ =20 -void -virBuildPathInternal(char **path, ...) -{ - char *path_component =3D NULL; - g_auto(virBuffer) buf =3D VIR_BUFFER_INITIALIZER; - va_list ap; - - va_start(ap, path); - - path_component =3D va_arg(ap, char *); - virBufferAdd(&buf, path_component, -1); - - while ((path_component =3D va_arg(ap, char *)) !=3D NULL) { - virBufferAddChar(&buf, '/'); - virBufferAdd(&buf, path_component, -1); - } - - va_end(ap); - - *path =3D virBufferContentAndReset(&buf); -} - /* Read no more than the specified maximum number of bytes. */ static char * saferead_lim(int fd, size_t max_len, size_t *length) diff --git a/src/util/virfile.h b/src/util/virfile.h index adc032ba33..286401e0f5 100644 --- a/src/util/virfile.h +++ b/src/util/virfile.h @@ -307,11 +307,6 @@ int virFileOpenTty(int *ttymaster, =20 char *virFileFindMountPoint(const char *type); =20 -/* NB: this should be combined with virFileBuildPath */ -#define virBuildPath(path, ...) \ - virBuildPathInternal(path, __VA_ARGS__, NULL) -void virBuildPathInternal(char **path, ...) G_GNUC_NULL_TERMINATED; - typedef struct _virHugeTLBFS virHugeTLBFS; struct _virHugeTLBFS { char *mnt_dir; /* Where the FS is mount to */ --=20 2.41.0 From nobody Mon May 20 23:07:28 2024 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=1697443767; cv=none; d=zohomail.com; s=zohoarc; b=AOMNCVGUykkcuBezIBU4J4HHvcy4wsAOLor8dRoJl5/c71sv/LQNVo7GPMbUOc/y5FEeED9rRIzeThfPTFTERt4XN8T32+fwStlu0dn2O0YtNre2b55UEYAW5wBq0/ipRKExNaTlC57BbmhYTEXaCGKdyVQDQ2b6N/lCBEJKycA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1697443767; h=Content-Type:Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To:Cc; bh=th2jsGuUOmeUzodeAUNBX1ndRmnGLxf5RzDeutYa56E=; b=ZvIoJkxbr/ZUU1HXEJau+HTjdKyM28cQLrv6RPyvpp0HmkRjV+f4AJF2InC35Hn5uauRBfHTzYkoVj2wdrjp20IRCtikdbX/o7eXa6281rOZOxIg4UqwpIx4QRW0nlw8yX9fDrxWbSbJw+v5kZ8yaCrKl6UUwT+gjp19WqidBDc= 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) 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 1697443767604451.86654688013357; Mon, 16 Oct 2023 01:09:27 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-48-6l2LwTE-MTqyfmTnO14ovg-1; Mon, 16 Oct 2023 04:08:00 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id EAAEE1029F48; Mon, 16 Oct 2023 08:07:57 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id D1A0825CE; Mon, 16 Oct 2023 08:07:57 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 40BAE19466F5; Mon, 16 Oct 2023 08:07:56 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 3C4531946587 for ; Mon, 16 Oct 2023 08:07:55 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 0F1C540C6CA3; Mon, 16 Oct 2023 08:07:55 +0000 (UTC) Received: from maggie.brq.redhat.com (unknown [10.43.2.56]) by smtp.corp.redhat.com (Postfix) with ESMTP id A9B2C40C6F79 for ; Mon, 16 Oct 2023 08:07:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1697443766; 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=th2jsGuUOmeUzodeAUNBX1ndRmnGLxf5RzDeutYa56E=; b=FGXjSbPtVRiN2ayG7M0UOryBqFWAvMCvgMMivekGqZNfhf3OgJOOu/+ctaVbd6lafWVw1z cMP4jOYFPTtAGw6aLn5ydjtocO8HjblJf96vGHLigSoJw0Tf6GSVqal5kR1plgJ6fmkgox +tESXm0Rc/7qAqR0pPyKQ9mPgnOd4SQ= X-MC-Unique: 6l2LwTE-MTqyfmTnO14ovg-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH 3/4] virSecretLoadAllConfigs: Use g_autofree for @path Date: Mon, 16 Oct 2023 10:07:50 +0200 Message-ID: <4d50b37e60f33ff74b75eaba018bd722bc7117ab.1697443656.git.mprivozn@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.2 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1697443769400100001 Content-Type: text/plain; charset="utf-8"; x-default="true" When loading virSecret configs, the @path variable holds path to individual config files. In each iteration it is freed explicitly using VIR_FREE(). Switch it to g_autofree and remove those explicit calls. Signed-off-by: Michal Privoznik Reviewed-by: J=C3=A1n Tomko Reviewed-by: Peter Krempa --- src/conf/virsecretobj.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/conf/virsecretobj.c b/src/conf/virsecretobj.c index e0393e6cec..2585b2c972 100644 --- a/src/conf/virsecretobj.c +++ b/src/conf/virsecretobj.c @@ -902,7 +902,7 @@ virSecretLoadAllConfigs(virSecretObjList *secrets, /* Ignore errors reported by readdir or other calls within the * loop (if any). It's better to keep the secrets we managed to find.= */ while (virDirRead(dir, &de, NULL) > 0) { - char *path; + g_autofree char *path =3D NULL; virSecretObj *obj; =20 if (!virStringHasSuffix(de->d_name, ".xml")) @@ -914,11 +914,9 @@ virSecretLoadAllConfigs(virSecretObjList *secrets, if (!(obj =3D virSecretLoad(secrets, de->d_name, path, configDir))= ) { VIR_ERROR(_("Error reading secret: %1$s"), virGetLastErrorMessage()); - VIR_FREE(path); continue; } =20 - VIR_FREE(path); virSecretObjEndAPI(&obj); } =20 --=20 2.41.0 From nobody Mon May 20 23:07:28 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1697443685; cv=none; d=zohomail.com; s=zohoarc; b=LZ2qrpZHXDRGY7vDwrdj/tSzAQ6/dl07ZKNpQLcyEHbmyUgkxal6ee6QoMbv08SUzdl0aHGtysLVll1MUYrbonyIn5Ewkcj78FJNpffB/w8SDzWmcn+LnbQkUl1JbYf9wZt6HlskRb72oKMvaGRR4AdGf84adqSTFv9UG5F/rvg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1697443685; h=Content-Type:Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To:Cc; bh=ccaxZqHcyKpsj1nMZMRfPODpJNXtDgGquvJ8McOKCO4=; b=nZPjZkIY9DaSXSqdF1MrE7szXeQm87+cTnflRjBUepst96uPm8rgSQ6HXSwqw5lmaBW8lMbIxp9Tq1JRyC95MpxdsH8wzFgUU21OHp4iyQyzCCqu01Hg6B1+cmDtokZXImhSl23/TR/3L74otEssGS7Qw9RkmOq78vc93+HHMIs= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mx.zohomail.com with SMTPS id 1697443685952228.18000083942002; Mon, 16 Oct 2023 01:08:05 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-645-d1xv9JoWM-awiDCGnMtGAA-1; Mon, 16 Oct 2023 04:08:01 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 7FBD33C1E9E7; Mon, 16 Oct 2023 08:07:58 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6997E118DF44; Mon, 16 Oct 2023 08:07:58 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id EC84D1946597; Mon, 16 Oct 2023 08:07:56 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id AC8BD1946587 for ; Mon, 16 Oct 2023 08:07:55 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 9DDAE40C6CA3; Mon, 16 Oct 2023 08:07:55 +0000 (UTC) Received: from maggie.brq.redhat.com (unknown [10.43.2.56]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4637540C6CA0 for ; Mon, 16 Oct 2023 08:07:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1697443684; 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=ccaxZqHcyKpsj1nMZMRfPODpJNXtDgGquvJ8McOKCO4=; b=GZev4Yimw76krCZhb339yvSzYnJR9YbzqsT2eb2FyXtS5isPpH12U74JYwk3J0nvlb99WX ffQZv+PawDLb1oF9CiSDX0HsuVPphZQhMLaX4DCFwpz4neCUVpUEoquKf9l7ffpidECiIY 2lUSx015k6fjQ+Ufoo7WVW9GF9wwLzU= X-MC-Unique: d1xv9JoWM-awiDCGnMtGAA-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH 4/4] virSecretLoad: Simplify cleanup path Date: Mon, 16 Oct 2023 10:07:51 +0200 Message-ID: <7ccbb992d1b989f94cfeb6be21e9ca1c32e9850f.1697443656.git.mprivozn@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.2 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 3.1 on 10.11.54.3 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1697443686961100001 Content-Type: text/plain; charset="utf-8"; x-default="true" When loading a secret value fails, the control jumps over to the 'cleanup' label where explicit call to virSecretDefFree() happens. This is unnecessary as the corresponding variable can be declared with g_autoptr() after which all error paths can just return NULL instantly. Signed-off-by: Michal Privoznik Reviewed-by: J=C3=A1n Tomko Reviewed-by: Peter Krempa --- src/conf/virsecretobj.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/conf/virsecretobj.c b/src/conf/virsecretobj.c index 2585b2c972..455798d414 100644 --- a/src/conf/virsecretobj.c +++ b/src/conf/virsecretobj.c @@ -865,25 +865,24 @@ virSecretLoad(virSecretObjList *secrets, const char *path, const char *configDir) { - virSecretDef *def =3D NULL; + g_autoptr(virSecretDef) def =3D NULL; virSecretObj *obj =3D NULL; =20 if (!(def =3D virSecretDefParse(NULL, path, 0))) - goto cleanup; + return NULL; =20 if (virSecretLoadValidateUUID(def, file) < 0) - goto cleanup; + return NULL; =20 if (!(obj =3D virSecretObjListAdd(secrets, &def, configDir, NULL))) - goto cleanup; + return NULL; =20 if (virSecretLoadValue(obj) < 0) { virSecretObjListRemove(secrets, obj); g_clear_pointer(&obj, virObjectUnref); + return NULL; } =20 - cleanup: - virSecretDefFree(def); return obj; } =20 --=20 2.41.0