From nobody Mon Feb 9 07:39:37 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=1642679195; cv=none; d=zohomail.com; s=zohoarc; b=b+Mz0qeqYUo9aC3BiaE8Ymblc1lC2uYiNiWWLOjYOwB/IhHAxPUI9CuOEQ+5GTU3UZVW3ewjBv9yuORLxZQ66Y2SfkGWBG4W+0jyXmTPj3oQz8gYVcifELeqd4aha3blDu0Aqao4VH1hnsEGTc2PnZw6xXQa0FU2eLCw37pzOLg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1642679195; 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=63z8IL860SpZu15cm5hpvPI16WBsrQUluwrMQlDaHdA=; b=KCKwSqiv7I8fnxFxw39LDhOo4iTEJGyivgC6Tov5nHB8/LAlWJuKY3Ir9DWTY8HIqP4quIJ/YBRJgnAvP3DpebEmA12BrqI1GCObzcvD9Dm5KuqI+tDUZ0jsdbz3LgH6AdvShQGVltoRvxpm9lppmlBORngQ0k7WNFsL7SJgPoA= 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 1642679195691847.8868919514935; Thu, 20 Jan 2022 03:46:35 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-104-y16v299wNT-0Mr12eXlTIQ-1; Thu, 20 Jan 2022 06:46:33 -0500 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 2A0871091DB8; Thu, 20 Jan 2022 11:46:28 +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 E93097D4A3; Thu, 20 Jan 2022 11:46: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 AB2D41809CB9; Thu, 20 Jan 2022 11:46:27 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 20KBkExF030283 for ; Thu, 20 Jan 2022 06:46:14 -0500 Received: by smtp.corp.redhat.com (Postfix) id 2CD1B108F831; Thu, 20 Jan 2022 11:46:14 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.7]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8617B108BEF4 for ; Thu, 20 Jan 2022 11:46:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1642679194; 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=63z8IL860SpZu15cm5hpvPI16WBsrQUluwrMQlDaHdA=; b=BipQeMcqMrPTM4sAogxOfk1wyhhVexDymZuzb9ttstOAD84SuWHAYmR/GNz+as/uYE4n7P DS/OUNSOcyrKGa2xt+XCA8vbc83DFs3jGAbwA1hdtzjbEW1a0gx2frBcs3T1RQHEe/pfs2 FvxA7vuLXDLjo6FFuz+ez0apeuuU2kg= X-MC-Unique: y16v299wNT-0Mr12eXlTIQ-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 2/5] virStoragePoolObjLoadAllConfigs: Use automatic memory clearing Date: Thu, 20 Jan 2022 12:45:55 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 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) X-ZM-MESSAGEID: 1642679196587100003 Content-Type: text/plain; charset="utf-8" Refactor the inner loop to automatically free temporary variables and remove unreachable error paths. Signed-off-by: Peter Krempa --- src/conf/virstorageobj.c | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-) diff --git a/src/conf/virstorageobj.c b/src/conf/virstorageobj.c index 815ada8584..4081e12823 100644 --- a/src/conf/virstorageobj.c +++ b/src/conf/virstorageobj.c @@ -1736,27 +1736,15 @@ virStoragePoolObjLoadAllConfigs(virStoragePoolObjLi= st *pools, return rc; while ((ret =3D virDirRead(dir, &entry, configDir)) > 0) { - char *path; - char *autostartLink; + g_autofree char *path =3D virFileBuildPath(configDir, entry->d_nam= e, NULL); + g_autofree char *autostartLink =3D virFileBuildPath(autostartDir, = entry->d_name, NULL); virStoragePoolObj *obj; if (!virStringHasSuffix(entry->d_name, ".xml")) continue; - if (!(path =3D virFileBuildPath(configDir, entry->d_name, NULL))) - continue; - - if (!(autostartLink =3D virFileBuildPath(autostartDir, entry->d_na= me, - NULL))) { - VIR_FREE(path); - continue; - } - obj =3D virStoragePoolObjLoad(pools, entry->d_name, path, autostar= tLink); virStoragePoolObjEndAPI(&obj); - - VIR_FREE(path); - VIR_FREE(autostartLink); } return ret; --=20 2.34.1