From nobody Thu Apr 25 14:03:37 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 205.139.110.120 as permitted sender) client-ip=205.139.110.120; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1595838739; cv=none; d=zohomail.com; s=zohoarc; b=PbSgPZAVvkIehy4pdQAoZTCf7zgoE0lfTLtCv4eAfVzVQVvgqr0+zIOGYZjmL5PV8IlP1xaIpeFaMZW9hgG8YeLn69Dfn+W12g/dtR1BAbjCJhaVgjoR8JH/f7FAdhGLU/XbDuoIs3dkggvRx6g+dFyXGrXhQVXr/dd3eON5zVg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1595838739; 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=3H55hGDuEBw5eJjrB5AWybpoi0yEvxI58t+gC9uhS6c=; b=Ok6brdSAh36EeuglKiyJEo76lU45jJ/DDSqrhvwA1fNVOQV/uj6tucnJuL/mBsnmljxPUpPHssKZrs3IDLOh0vdbOOqEKnrFECg9hOiKFz7dM0YEvYmFYZJrtHjhPSQmJYdNcvxfMsYzM8WVzed9Zz6N8VxXfmf4vIRx9vX2O9c= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) by mx.zohomail.com with SMTPS id 1595838739103357.3134626161145; Mon, 27 Jul 2020 01:32: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-307-N7QNeMKwNumUdrXbnYX3cw-1; Mon, 27 Jul 2020 04:31:39 -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 03BB88015CE; Mon, 27 Jul 2020 08:31:34 +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 D5BF68FA5A; Mon, 27 Jul 2020 08:31:33 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id A12431800FDE; Mon, 27 Jul 2020 08:31:33 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 06R8VTNl013606 for ; Mon, 27 Jul 2020 04:31:29 -0400 Received: by smtp.corp.redhat.com (Postfix) id 18F8C6842F; Mon, 27 Jul 2020 08:31:29 +0000 (UTC) Received: from localhost.localdomain (unknown [10.40.193.218]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8C05D60F96 for ; Mon, 27 Jul 2020 08:31:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1595838737; 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=3H55hGDuEBw5eJjrB5AWybpoi0yEvxI58t+gC9uhS6c=; b=dTKYCv8NBw/eJox1NSMtLtKWZPUqyhFUs2RS9L3eppXadMk6+rOWy2nxRR3PfsIf22EzEF kyp/ksMrplxFuhiYy4u18TVdXqpVVA9eQnw8KSMNnTnZFvoa3pyYb/R+odkcRK4PxWphFX Uv+4BlHkho7c5pNDqxZZl3GfxaArMhU= X-MC-Unique: N7QNeMKwNumUdrXbnYX3cw-1 From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH 2/4] virDevMapperGetTargetsImpl: Use VIR_AUTOSTRINGLIST Date: Mon, 27 Jul 2020 10:31:10 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 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 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Since we have VIR_AUTOSTRINGLIST we can use it to free string lists used in the function automatically. Signed-off-by: Michal Privoznik Reviewed-by: Daniel P. Berrang=C3=A9 --- src/util/virdevmapper.c | 16 +++------------- 1 file changed, 3 insertions(+), 13 deletions(-) diff --git a/src/util/virdevmapper.c b/src/util/virdevmapper.c index 118dc82e94..44c4731fb4 100644 --- a/src/util/virdevmapper.c +++ b/src/util/virdevmapper.c @@ -67,8 +67,7 @@ virDevMapperGetTargetsImpl(const char *path, struct dm_task *dmt =3D NULL; struct dm_deps *deps; struct dm_info info; - char **devPaths =3D NULL; - char **recursiveDevPaths =3D NULL; + VIR_AUTOSTRINGLIST devPaths =3D NULL; size_t i; int ret =3D -1; =20 @@ -133,28 +132,19 @@ virDevMapperGetTargetsImpl(const char *path, minor(deps->device[i])); } =20 - recursiveDevPaths =3D NULL; for (i =3D 0; i < deps->count; i++) { - char **tmpPaths; + VIR_AUTOSTRINGLIST tmpPaths =3D NULL; =20 if (virDevMapperGetTargetsImpl(devPaths[i], &tmpPaths, ttl - 1) < = 0) goto cleanup; =20 - if (tmpPaths && - virStringListMerge(&recursiveDevPaths, &tmpPaths) < 0) { - virStringListFree(tmpPaths); + if (virStringListMerge(&devPaths, &tmpPaths) < 0) goto cleanup; - } } =20 - if (virStringListMerge(&devPaths, &recursiveDevPaths) < 0) - goto cleanup; - *devPaths_ret =3D g_steal_pointer(&devPaths); ret =3D 0; cleanup: - virStringListFree(recursiveDevPaths); - virStringListFree(devPaths); dm_task_destroy(dmt); return ret; } --=20 2.26.2