From nobody Sun Feb 8 23:25:58 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=1623766627; cv=none; d=zohomail.com; s=zohoarc; b=CpCQgZ7F37v47g2vunhzVx56GAtDgwGnuEa+64tMBjUFhjHDEqXYwA3TijceMf4qQlXI1ITEhWVG/ttYBz/d4jBPI9jjbdyvpY5JAijE6SbLaGrC7aGAZscfxLeJp+uvWVFGxO3s9Q1Mjn4lVQlpVHQtsiQlTYtZe11OTAZAomg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1623766627; 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=6vxU8GMgiL2u/eZKDe57PUAlVmU9m7VYd7mjFHrr9rM=; b=Xg4AMFjvbkMhXDTuV0y1zoc2U0MNRH0arhrEdSUvt4RXJSLZys/ZjBJLtnGps+1TOmfRRNbuigEnOi/TYlCjrbrUNo6hE824ThHNmL+a/C9W/k42t6NifskLfeP+h5TnHJUqD0lumNgCgafYuCgs1zGy/bG3DndgSJHKpcc0zfQ= 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) 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 162376662702612.509656806899898; Tue, 15 Jun 2021 07:17: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-567-6XhFnkjiMqakxPY4TPWeNA-1; Tue, 15 Jun 2021 10:17:03 -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 5166F57229; Tue, 15 Jun 2021 14:16:57 +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 22513100238C; Tue, 15 Jun 2021 14:16:57 +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 9346E46F58; Tue, 15 Jun 2021 14:16: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 15FEGs0I008886 for ; Tue, 15 Jun 2021 10:16:54 -0400 Received: by smtp.corp.redhat.com (Postfix) id BB4A45C1C2; Tue, 15 Jun 2021 14:16:54 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.13]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2EB595C22A for ; Tue, 15 Jun 2021 14:16:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1623766626; 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=6vxU8GMgiL2u/eZKDe57PUAlVmU9m7VYd7mjFHrr9rM=; b=hXCcbAvXBr9GaJ1EVaRg4j6Xyx4NVaL72DCABafuO5jY6wrJgC0GAPk/KegGzYWTnjJPDc /MbUcedwB2nnv36+t2cmu8lX8dL6JO5twJxD7JozgXIidXMFqnDN+F3bhFOJQZ6TOnunS9 N1u+JLA3ppi7L0tM+MOY/INTpitp+yY= X-MC-Unique: 6XhFnkjiMqakxPY4TPWeNA-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 2/2] virStorageBackendRBDGetVolNames: Refactor cleanup in 'rbd_list' version Date: Tue, 15 Jun 2021 16:16:43 +0200 Message-Id: <9a297292ad2f4e88b54c96e53f1e8fae8b57cf9e.1623766567.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" Use automatic memory freeing for the string list so that we can remove the cleanup section. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/storage/storage_backend_rbd.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/src/storage/storage_backend_rbd.c b/src/storage/storage_backen= d_rbd.c index 371ebfaf1b..a4e8115dc4 100644 --- a/src/storage/storage_backend_rbd.c +++ b/src/storage/storage_backend_rbd.c @@ -611,7 +611,7 @@ virStorageBackendRBDGetVolNames(virStorageBackendRBDSta= te *ptr) static char ** virStorageBackendRBDGetVolNames(virStorageBackendRBDState *ptr) { - char **names =3D NULL; + g_auto(GStrv) names =3D NULL; size_t nnames =3D 0; int rc; size_t max_size =3D 1024; @@ -626,7 +626,7 @@ virStorageBackendRBDGetVolNames(virStorageBackendRBDSta= te *ptr) break; if (rc !=3D -ERANGE) { virReportSystemError(errno, "%s", _("Unable to list RBD images= ")); - goto error; + return NULL; } VIR_FREE(namebuf); } @@ -640,18 +640,14 @@ virStorageBackendRBDGetVolNames(virStorageBackendRBDS= tate *ptr) namedup =3D g_strdup(name); if (VIR_APPEND_ELEMENT(names, nnames, namedup) < 0) - goto error; + return NULL; name +=3D strlen(name) + 1; } VIR_EXPAND_N(names, nnames, 1); - return names; - - error: - virStringListFreeCount(names, nnames); - return NULL; + return g_steal_pointer(&names); } #endif /* ! WITH_RBD_LIST2 */ --=20 2.31.1