From nobody Sun Feb 8 11:06:35 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=1628757501; cv=none; d=zohomail.com; s=zohoarc; b=GrUxb4sKRt4WAgmqREvicEnOKf1bKMph9kEIn246iRIKaEUfdF4NwHiEQNIBcV6efpVFET6BV4Z1M5n0NohJIxvVgalH8olKDz0Yt6FA7qArhrsU/CwcGFB9/uWlFub4OPz2R45YaqC3qrKmz2ia0NCFLg59eR3PdQzfq1pFjDM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1628757501; 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=y0mC0iVaMyCAqGcMTxNoEvFDEbI6M/R94QLL0i1YN9Q=; b=FyxOLF1J16gl39oF5W6t1PhJHfh1QRrn6tAY/+s0giDBOZAcEEWp1qvZyGCp/F/SDQtrsdEOkPrUZVZiceTy5/Dss/XOngcbgCQwtzM499a7N2yec7cQ3FZgbD1xANuNtvhPexp4g9wLToAkAyBlxBxJVqhSZyjtv8P5fG8MhtU= 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 162875750170331.380467079793902; Thu, 12 Aug 2021 01:38: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-127-9TlRgPZZME6HReqa4vm-Tg-1; Thu, 12 Aug 2021 04:38:17 -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 F1347190A7A2; Thu, 12 Aug 2021 08:38:10 +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 416A710016FB; Thu, 12 Aug 2021 08:38: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 413B34BB7B; Thu, 12 Aug 2021 08:38:03 +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 17C8XGnC003720 for ; Thu, 12 Aug 2021 04:33:16 -0400 Received: by smtp.corp.redhat.com (Postfix) id 5E23C10013C1; Thu, 12 Aug 2021 08:33:16 +0000 (UTC) Received: from hjs.redhat.com (unknown [10.43.2.53]) by smtp.corp.redhat.com (Postfix) with ESMTP id DAAAB10016FF for ; Thu, 12 Aug 2021 08:33:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1628757500; 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=y0mC0iVaMyCAqGcMTxNoEvFDEbI6M/R94QLL0i1YN9Q=; b=WRNYE9dSGdF8jl4GtbtmyDGR9vQUqjQU/Wny1FaewDM/G/x+hDcT3//jSK//NFrns6ZJWe nYuPmr1sbbFXMxibzW3x0aRh0149rpRt5Fc5Xww7dRfFbfz0nUbtdsHDJRume3EPIJ7o1V /cfoWkzrA5PJiIdvjv/1v7ctkuBW7Ig= X-MC-Unique: 9TlRgPZZME6HReqa4vm-Tg-1 From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Subject: [libvirt PATCH 10/12] tools: virsh: use automatic cleanup for char ** Date: Thu, 12 Aug 2021 10:32:48 +0200 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.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-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1628757502726100001 Signed-off-by: J=C3=A1n Tomko --- tools/virsh-domain.c | 11 +++-------- tools/virsh-host.c | 3 +-- tools/virsh-nodedev.c | 6 ++---- tools/virsh-pool.c | 4 +--- 4 files changed, 7 insertions(+), 17 deletions(-) diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c index 542e2a1736..0636bbfa31 100644 --- a/tools/virsh-domain.c +++ b/tools/virsh-domain.c @@ -4002,7 +4002,7 @@ cmdStartGetFDs(vshControl *ctl, int **fdsret) { const char *fdopt; - char **fdlist =3D NULL; + g_auto(GStrv) fdlist =3D NULL; int *fds =3D NULL; size_t nfds =3D 0; size_t i; @@ -4028,14 +4028,11 @@ cmdStartGetFDs(vshControl *ctl, fds[nfds - 1] =3D fd; } =20 - g_strfreev(fdlist); - *fdsret =3D fds; *nfdsret =3D nfds; return 0; =20 error: - g_strfreev(fdlist); VIR_FREE(fds); return -1; } @@ -5859,7 +5856,7 @@ cmdShutdown(vshControl *ctl, const vshCmd *cmd) const char *mode =3D NULL; int flags =3D 0; int rv; - char **modes =3D NULL; + g_auto(GStrv) modes =3D NULL; char **tmp; =20 if (vshCommandOptStringReq(ctl, cmd, "mode", &mode) < 0) @@ -5908,7 +5905,6 @@ cmdShutdown(vshControl *ctl, const vshCmd *cmd) =20 ret =3D true; cleanup: - g_strfreev(modes); return ret; } =20 @@ -5943,7 +5939,7 @@ cmdReboot(vshControl *ctl, const vshCmd *cmd) const char *name; const char *mode =3D NULL; int flags =3D 0; - char **modes =3D NULL; + g_auto(GStrv) modes =3D NULL; char **tmp; =20 if (vshCommandOptStringReq(ctl, cmd, "mode", &mode) < 0) @@ -5988,7 +5984,6 @@ cmdReboot(vshControl *ctl, const vshCmd *cmd) =20 ret =3D true; cleanup: - g_strfreev(modes); return ret; } =20 diff --git a/tools/virsh-host.c b/tools/virsh-host.c index a07f5adbfa..df1fe49e09 100644 --- a/tools/virsh-host.c +++ b/tools/virsh-host.c @@ -1301,7 +1301,7 @@ cmdCPUBaseline(vshControl *ctl, const vshCmd *cmd) const char *from =3D NULL; bool ret =3D false; char *result =3D NULL; - char **list =3D NULL; + g_auto(GStrv) list =3D NULL; unsigned int flags =3D 0; virshControl *priv =3D ctl->privData; =20 @@ -1326,7 +1326,6 @@ cmdCPUBaseline(vshControl *ctl, const vshCmd *cmd) } =20 VIR_FREE(result); - g_strfreev(list); return ret; } =20 diff --git a/tools/virsh-nodedev.c b/tools/virsh-nodedev.c index 5b1afe4601..c6c7d97d50 100644 --- a/tools/virsh-nodedev.c +++ b/tools/virsh-nodedev.c @@ -115,7 +115,7 @@ static virNodeDevice* vshFindNodeDevice(vshControl *ctl, const char *value) { virNodeDevicePtr dev =3D NULL; - char **arr =3D NULL; + g_auto(GStrv) arr =3D NULL; int narr; virshControl *priv =3D ctl->privData; =20 @@ -140,7 +140,6 @@ vshFindNodeDevice(vshControl *ctl, const char *value) } =20 cleanup: - g_strfreev(arr); return dev; } =20 @@ -409,7 +408,7 @@ cmdNodeListDevices(vshControl *ctl, const vshCmd *cmd G= _GNUC_UNUSED) bool tree =3D vshCommandOptBool(cmd, "tree"); bool ret =3D true; unsigned int flags =3D 0; - char **caps =3D NULL; + g_auto(GStrv) caps =3D NULL; int ncaps =3D 0; struct virshNodeDeviceList *list =3D NULL; int cap_type =3D -1; @@ -555,7 +554,6 @@ cmdNodeListDevices(vshControl *ctl, const vshCmd *cmd G= _GNUC_UNUSED) } =20 cleanup: - g_strfreev(caps); virshNodeDeviceListFree(list); return ret; } diff --git a/tools/virsh-pool.c b/tools/virsh-pool.c index 5bce5cf06c..03987770f6 100644 --- a/tools/virsh-pool.c +++ b/tools/virsh-pool.c @@ -1175,7 +1175,7 @@ cmdPoolList(vshControl *ctl, const vshCmd *cmd G_GNUC= _UNUSED) =20 if (type) { int poolType =3D -1; - char **poolTypes =3D NULL; + g_auto(GStrv) poolTypes =3D NULL; int npoolTypes =3D 0; =20 if ((npoolTypes =3D vshStringToArray(type, &poolTypes)) < 0) @@ -1184,7 +1184,6 @@ cmdPoolList(vshControl *ctl, const vshCmd *cmd G_GNUC= _UNUSED) for (i =3D 0; i < npoolTypes; i++) { if ((poolType =3D virStoragePoolTypeFromString(poolTypes[i])) = < 0) { vshError(ctl, _("Invalid pool type '%s'"), poolTypes[i]); - g_strfreev(poolTypes); return false; } =20 @@ -1235,7 +1234,6 @@ cmdPoolList(vshControl *ctl, const vshCmd *cmd G_GNUC= _UNUSED) break; } } - g_strfreev(poolTypes); } =20 if (!(list =3D virshStoragePoolListCollect(ctl, flags))) --=20 2.31.1