From nobody Sun May 5 06:12:08 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1549963303071832.7995314525141; Tue, 12 Feb 2019 01:21:43 -0800 (PST) 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 mx1.redhat.com (Postfix) with ESMTPS id 61E7C36807; Tue, 12 Feb 2019 09:21:40 +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 1AA0710021B1; Tue, 12 Feb 2019 09:21:39 +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 1885C1819AF9; Tue, 12 Feb 2019 09:21:36 +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 x1C9LYHr023906 for ; Tue, 12 Feb 2019 04:21:34 -0500 Received: by smtp.corp.redhat.com (Postfix) id C6C0C5C229; Tue, 12 Feb 2019 09:21:34 +0000 (UTC) Received: from icr.brq.redhat.com (unknown [10.43.2.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4DBBC5C21A for ; Tue, 12 Feb 2019 09:21:34 +0000 (UTC) From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Date: Tue, 12 Feb 2019 10:21:19 +0100 Message-Id: <865b201479d5094d3bc7c342317f095ec763490f.1549963201.git.jtomko@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 Subject: [libvirt] [PATCH 1/9] vshtabletest: indent strings with expected output 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: , Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Tue, 12 Feb 2019 09:21:41 +0000 (UTC) Indent them by four spaces from the previous line, instead of starting at columnn zero. Signed-off-by: J=C3=A1n Tomko --- tests/vshtabletest.c | 76 ++++++++++++++++++++++---------------------- 1 file changed, 38 insertions(+), 38 deletions(-) diff --git a/tests/vshtabletest.c b/tests/vshtabletest.c index e795c5afc0..79285b14a9 100644 --- a/tests/vshtabletest.c +++ b/tests/vshtabletest.c @@ -43,13 +43,13 @@ testVshTableHeader(const void *opaque ATTRIBUTE_UNUSED) int ret =3D 0; char *act =3D NULL; const char *exp =3D -" 1 fedora28 running\n" -" 2 rhel7.5 running\n"; + " 1 fedora28 running\n" + " 2 rhel7.5 running\n"; const char *exp2 =3D -" Id Name State\n" -"--------------------------\n" -" 1 fedora28 running\n" -" 2 rhel7.5 running\n"; + " Id Name State\n" + "--------------------------\n" + " 1 fedora28 running\n" + " 2 rhel7.5 running\n"; =20 vshTablePtr table =3D vshTableNew("Id", "Name", "State", NULL); //to ask about return @@ -118,10 +118,10 @@ testUnicode(const void *opaque ATTRIBUTE_UNUSED) char *act =3D NULL; =20 const char *exp =3D -" Id =E5=90=8D=E7=A8=B1 =D0=B3=D0=BE=D1=81=D1=83=D0=B4= =D0=B0=D1=80=D1=81=D1=82=D0=B2=D0=BE\n" -"-----------------------------------------\n" -" 1 fedora28 running\n" -" 2 =E3=81=A4=E3=81=B8=E3=82=BDrhel7.5=E3=81=A4=E3=81=B8=E3=82=BD run= ning\n"; + " Id =E5=90=8D=E7=A8=B1 =D0=B3=D0=BE=D1=81=D1= =83=D0=B4=D0=B0=D1=80=D1=81=D1=82=D0=B2=D0=BE\n" + "-----------------------------------------\n" + " 1 fedora28 running\n" + " 2 =E3=81=A4=E3=81=B8=E3=82=BDrhel7.5=E3=81=A4=E3=81=B8=E3=82= =BD running\n"; vshTablePtr table; =20 table =3D vshTableNew("Id", "=E5=90=8D=E7=A8=B1", "=D0=B3=D0=BE=D1=81= =D1=83=D0=B4=D0=B0=D1=80=D1=81=D1=82=D0=B2=D0=BE", NULL); @@ -150,10 +150,10 @@ testUnicodeArabic(const void *opaque ATTRIBUTE_UNUSED) char *act =3D NULL; =20 const char *exp =3D -" =EF=BB=A1=EF=BA=8D =EF=BB=A2=EF=BB=A3=EF=BA=8D =EF=BB=95=EF=BA=8E=EF=BA= =8C=EF=BB=A3=EF=BA=93 =EF=BA=93 =EF=BA=8E=EF=BB=A0=EF=BA=BC=EF=BB=8B = =EF=BA=8D=EF=BB=B8=EF=BA=9C=EF= =BB=A7=EF=BA=8E=EF=BB=A7\n" -"-------------------------------------------------------------------------= ------------------\n" -" 1 =EF=BB=89=EF=BA=AA=EF=BB=B4=EF=BB=9F =EF=BA=8E=EF=BB=A0= =EF=BA=9C=EF=BB=98=EF=BB=B4=EF=BB=9F =EF=BB=95=EF=BA=8E=EF=BB=A3 =EF=BB=8A= =EF=BB=A7, =D9=A3=D9=A0 =EF=BB=8E=EF=BB=B4=EF=BB=A8=EF=BB=B3=EF=BA=8D =EF= =BB=AE=EF=BA=98=EF=BB=A7=EF=BA=8E=EF=BB=A4=EF=BA=97 =EF=BA=8E=EF=BB=A0=EF= =BA=9B=EF=BA=8E=EF=BB=A0=EF=BA=9B=D8=8C =EF=BA=84=EF=BA=B3=EF=BA=AD, =EF=BA= =A9=EF=BB=AE=EF=BB=9F =EF=BA=A9=EF=BB=AE=EF=BB=9F. =EF=BA=84=EF=BB=A3=EF= =BA=8E=EF=BB=A3 =EF=BA=8D =EF=BA=8E=EF=BB=A7 =EF=BB=B2=EF=BB=9C=EF=BB=A7\n" -" =EF=BA=BA=EF=BB=94=EF=BA=A3=EF=BA=93 =EF=BA=96=EF=BB=9C=EF=BA= =98=EF=BB=B4=EF=BB=9B=EF=BA=8D=D9=8B =EF=BB=8A=EF=BB=9F, =EF=BA=8E=EF=BB=A0= =EF=BA=A0=EF=BB=A7=EF=BB=AD=EF=BA=A9 =EF=BB=AD=EF=BA=8E=EF=BB=A0=EF=BB=8C= =EF=BA=97=EF=BA=8D=EF=BA=A9 =EF=BA=B5=EF=BA=AD= \n"; + " =EF=BB=A1=EF=BA=8D =EF=BB=A2=EF=BB=A3=EF=BA=8D =EF=BB=95=EF=BA= =8E=EF=BA=8C=EF=BB=A3=EF=BA=93 =EF=BA=93 =EF=BA=8E=EF=BB=A0=EF=BA=BC=EF= =BB=8B =EF=BA=8D=EF=BB=B8= =EF=BA=9C=EF=BB=A7=EF=BA=8E=EF=BB=A7\n" + "-----------------------------------------------------------------= --------------------------\n" + " 1 =EF=BB=89=EF=BA=AA=EF=BB=B4=EF=BB=9F =EF=BA=8E=EF= =BB=A0=EF=BA=9C=EF=BB=98=EF=BB=B4=EF=BB=9F =EF=BB=95=EF=BA=8E=EF=BB=A3 =EF= =BB=8A=EF=BB=A7, =D9=A3=D9=A0 =EF=BB=8E=EF=BB=B4=EF=BB=A8=EF=BB=B3=EF=BA=8D= =EF=BB=AE=EF=BA=98=EF=BB=A7=EF=BA=8E=EF=BB=A4=EF=BA=97 =EF=BA=8E=EF=BB=A0= =EF=BA=9B=EF=BA=8E=EF=BB=A0=EF=BA=9B=D8=8C =EF=BA=84=EF=BA=B3=EF=BA=AD, =EF= =BA=A9=EF=BB=AE=EF=BB=9F =EF=BA=A9=EF=BB=AE=EF=BB=9F. =EF=BA=84=EF=BB=A3= =EF=BA=8E=EF=BB=A3 =EF=BA=8D =EF=BA=8E=EF=BB=A7 =EF=BB=B2=EF=BB=9C=EF=BB=A7= \n" + " =EF=BA=BA=EF=BB=94=EF=BA=A3=EF=BA=93 =EF=BA=96=EF=BB= =9C=EF=BA=98=EF=BB=B4=EF=BB=9B=EF=BA=8D=D9=8B =EF=BB=8A=EF=BB=9F, =EF=BA=8E= =EF=BB=A0=EF=BA=A0=EF=BB=A7=EF=BB=AD=EF=BA=A9 =EF=BB=AD=EF=BA=8E=EF=BB=A0= =EF=BB=8C=EF=BA=97=EF=BA=8D=EF=BA=A9 =EF=BA=B5= =EF=BA=AD\n"; vshTablePtr table; wchar_t wc; =20 @@ -192,10 +192,10 @@ testUnicodeZeroWidthChar(const void *opaque ATTRIBUTE= _UNUSED) int ret =3D 0; vshTablePtr table =3D NULL; const char *exp =3D -" I\u200Bd Name \u200BStatus\n" -"--------------------------\n" -" 1\u200B fedora28 run\u200Bning\n" -" 2 rhel7.5 running\n"; + " I\u200Bd Name \u200BStatus\n" + "--------------------------\n" + " 1\u200B fedora28 run\u200Bning\n" + " 2 rhel7.5 running\n"; char *act =3D NULL; wchar_t wc; =20 @@ -229,10 +229,10 @@ testUnicodeCombiningChar(const void *opaque ATTRIBUTE= _UNUSED) int ret =3D 0; vshTablePtr table =3D NULL; const char *exp =3D -" Id N=C3=A1me =E2=93=88tatus\n" -"--------------------------\n" -" 1 f=C4=9Bdora28 running\n" -" 2 rhel running\n"; + " Id N=C3=A1me =E2=93=88tatus\n" + "--------------------------\n" + " 1 f=C4=9Bdora28 running\n" + " 2 rhel running\n"; char *act =3D NULL; =20 table =3D vshTableNew("Id", "N=C3=A1me", "=E2=93=88tatus", NULL); @@ -258,10 +258,10 @@ testUnicodeNonPrintableChar(const void *opaque ATTRIB= UTE_UNUSED) int ret =3D 0; vshTablePtr table =3D NULL; const char *exp =3D -" I\\x09d Name Status\n" -"----------------------------------\n" -" 1 f\\x07edora28 running\n" -" 2 rhel7.5 running\n"; + " I\\x09d Name Status\n" + "----------------------------------\n" + " 1 f\\x07edora28 running\n" + " 2 rhel7.5 running\n"; char *act =3D NULL; =20 table =3D vshTableNew("I\td", "Name", "Status", NULL); @@ -288,20 +288,20 @@ testNTables(const void *opaque ATTRIBUTE_UNUSED) vshTablePtr table2 =3D NULL; vshTablePtr table3 =3D NULL; const char *exp1 =3D -" Id Name Status\n" -"--------------------------\n" -" 1 fedora28 running\n" -" 2 rhel7.5 running\n"; + " Id Name Status\n" + "--------------------------\n" + " 1 fedora28 running\n" + " 2 rhel7.5 running\n"; const char *exp2 =3D -" Id Name Status\n" -"---------------------\n"; + " Id Name Status\n" + "---------------------\n"; const char *exp3 =3D -" Id\n" -"-----\n" -" 1\n" -" 2\n" -" 3\n" -" 4\n"; + " Id\n" + "-----\n" + " 1\n" + " 2\n" + " 3\n" + " 4\n"; char *act1 =3D NULL; char *act2 =3D NULL; char *act3 =3D NULL; --=20 2.19.2 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sun May 5 06:12:08 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1549963320233753.7713906333488; Tue, 12 Feb 2019 01:22:00 -0800 (PST) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 95EADB655; Tue, 12 Feb 2019 09:21:57 +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 6001E5C23F; Tue, 12 Feb 2019 09:21: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 0678A1819AFF; Tue, 12 Feb 2019 09:21:57 +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 x1C9LZiZ023911 for ; Tue, 12 Feb 2019 04:21:35 -0500 Received: by smtp.corp.redhat.com (Postfix) id 9A98C5C229; Tue, 12 Feb 2019 09:21:35 +0000 (UTC) Received: from icr.brq.redhat.com (unknown [10.43.2.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1FFEE5C21A for ; Tue, 12 Feb 2019 09:21:34 +0000 (UTC) From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Date: Tue, 12 Feb 2019 10:21:20 +0100 Message-Id: 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 Subject: [libvirt] [PATCH 2/9] vsh-table: allow empty columns 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: , Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Tue, 12 Feb 2019 09:21:58 +0000 (UTC) Trivially implement this by deleting the bogus check in vshTableSafeEncode. Now it returns an empty string for an empty string instead of returning NULL without setting an error. Signed-off-by: J=C3=A1n Tomko --- tests/vshtabletest.c | 4 +++- tools/vsh-table.c | 3 --- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/tests/vshtabletest.c b/tests/vshtabletest.c index 79285b14a9..b07db3cf23 100644 --- a/tests/vshtabletest.c +++ b/tests/vshtabletest.c @@ -291,7 +291,8 @@ testNTables(const void *opaque ATTRIBUTE_UNUSED) " Id Name Status\n" "--------------------------\n" " 1 fedora28 running\n" - " 2 rhel7.5 running\n"; + " 2 rhel7.5 running\n" + " 3 gazpacho \n"; const char *exp2 =3D " Id Name Status\n" "---------------------\n"; @@ -311,6 +312,7 @@ testNTables(const void *opaque ATTRIBUTE_UNUSED) goto cleanup; vshTableRowAppend(table1, "1", "fedora28", "running", NULL); vshTableRowAppend(table1, "2", "rhel7.5", "running", NULL); + vshTableRowAppend(table1, "3", "gazpacho", "", NULL); act1 =3D vshTablePrintToString(table1, true); =20 table2 =3D vshTableNew("Id", "Name", "Status", NULL); diff --git a/tools/vsh-table.c b/tools/vsh-table.c index fda8f15879..8bd6d99778 100644 --- a/tools/vsh-table.c +++ b/tools/vsh-table.c @@ -219,9 +219,6 @@ vshTableSafeEncode(const char *s, size_t *width) =20 memset(&st, 0, sizeof(st)); =20 - if (!sz) - return NULL; - if (VIR_ALLOC_N(buf, (sz * HEX_ENCODE_LENGTH) + 1) < 0) return NULL; =20 --=20 2.19.2 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sun May 5 06:12:08 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1549963325920796.7185997790106; Tue, 12 Feb 2019 01:22:05 -0800 (PST) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id C678A6696F; Tue, 12 Feb 2019 09:22:02 +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 6DABC61556; Tue, 12 Feb 2019 09:22:02 +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 E162F181A009; Tue, 12 Feb 2019 09:22:01 +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 x1C9LcJj023931 for ; Tue, 12 Feb 2019 04:21:38 -0500 Received: by smtp.corp.redhat.com (Postfix) id 7D22D5C21A; Tue, 12 Feb 2019 09:21:38 +0000 (UTC) Received: from icr.brq.redhat.com (unknown [10.43.2.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id F3B715C229 for ; Tue, 12 Feb 2019 09:21:35 +0000 (UTC) From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Date: Tue, 12 Feb 2019 10:21:21 +0100 Message-Id: <443fc056a057b6d653986b454c8b1514b6f0299e.1549963201.git.jtomko@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 Subject: [libvirt] [PATCH 3/9] virsh: introduce ninfos variable in cmdDomFSInfo 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: , Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Tue, 12 Feb 2019 09:22:04 +0000 (UTC) Do not use 'ret' throughout the whole function to avoid confusion and comparison of unsigned 'i' against signed 'ret'. Signed-off-by: J=C3=A1n Tomko --- tools/virsh-domain.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c index 8b20059335..630761e40e 100644 --- a/tools/virsh-domain.c +++ b/tools/virsh-domain.c @@ -13940,6 +13940,7 @@ cmdDomFSInfo(vshControl *ctl, const vshCmd *cmd) size_t i, j; virDomainFSInfoPtr *info; vshTablePtr table =3D NULL; + size_t ninfos =3D 0; =20 if (!(dom =3D virshCommandOptDomain(ctl, cmd, NULL))) return false; @@ -13949,7 +13950,9 @@ cmdDomFSInfo(vshControl *ctl, const vshCmd *cmd) vshError(ctl, _("Unable to get filesystem information")); goto cleanup; } - if (ret =3D=3D 0) { + ninfos =3D ret; + + if (ninfos =3D=3D 0) { vshError(ctl, _("No filesystems are mounted in the domain")); goto cleanup; } @@ -13959,7 +13962,7 @@ cmdDomFSInfo(vshControl *ctl, const vshCmd *cmd) if (!table) goto cleanup; =20 - for (i =3D 0; i < ret; i++) { + for (i =3D 0; i < ninfos; i++) { virBuffer targetsBuff =3D VIR_BUFFER_INITIALIZER; VIR_AUTOFREE(char *) targets =3D NULL; =20 @@ -13985,7 +13988,7 @@ cmdDomFSInfo(vshControl *ctl, const vshCmd *cmd) =20 cleanup: if (info) { - for (i =3D 0; i < ret; i++) + for (i =3D 0; i < ninfos; i++) virDomainFSInfoFree(info[i]); VIR_FREE(info); } --=20 2.19.2 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sun May 5 06:12:08 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1549963304530659.2402103485806; Tue, 12 Feb 2019 01:21:44 -0800 (PST) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 18E307F3E8; Tue, 12 Feb 2019 09:21:42 +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 D30A361556; Tue, 12 Feb 2019 09:21:41 +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 6389A3F605; Tue, 12 Feb 2019 09:21:41 +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 x1C9LdVb023942 for ; Tue, 12 Feb 2019 04:21:39 -0500 Received: by smtp.corp.redhat.com (Postfix) id 4ECFC5C229; Tue, 12 Feb 2019 09:21:39 +0000 (UTC) Received: from icr.brq.redhat.com (unknown [10.43.2.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id C7DB85C21A for ; Tue, 12 Feb 2019 09:21:38 +0000 (UTC) From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Date: Tue, 12 Feb 2019 10:21:22 +0100 Message-Id: <44993d312dfaa13b4502307a7157d6605d00d5fc.1549963201.git.jtomko@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 Subject: [libvirt] [PATCH 4/9] virsh: rename ret to rc in cmdDomFSInfo 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: , Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Tue, 12 Feb 2019 09:21:42 +0000 (UTC) Leave the 'ret' variable for the current function's return value. Signed-off-by: J=C3=A1n Tomko --- tools/virsh-domain.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c index 630761e40e..651766cd84 100644 --- a/tools/virsh-domain.c +++ b/tools/virsh-domain.c @@ -13936,7 +13936,7 @@ static bool cmdDomFSInfo(vshControl *ctl, const vshCmd *cmd) { virDomainPtr dom =3D NULL; - int ret =3D -1; + int rc =3D -1; size_t i, j; virDomainFSInfoPtr *info; vshTablePtr table =3D NULL; @@ -13945,12 +13945,12 @@ cmdDomFSInfo(vshControl *ctl, const vshCmd *cmd) if (!(dom =3D virshCommandOptDomain(ctl, cmd, NULL))) return false; =20 - ret =3D virDomainGetFSInfo(dom, &info, 0); - if (ret < 0) { + rc =3D virDomainGetFSInfo(dom, &info, 0); + if (rc < 0) { vshError(ctl, _("Unable to get filesystem information")); goto cleanup; } - ninfos =3D ret; + ninfos =3D rc; =20 if (ninfos =3D=3D 0) { vshError(ctl, _("No filesystems are mounted in the domain")); @@ -13994,7 +13994,7 @@ cmdDomFSInfo(vshControl *ctl, const vshCmd *cmd) } vshTableFree(table); virshDomainFree(dom); - return ret >=3D 0; + return rc >=3D 0; } =20 const vshCmdDef domManagementCmds[] =3D { --=20 2.19.2 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sun May 5 06:12:08 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 154996331980117.625077917672684; Tue, 12 Feb 2019 01:21:59 -0800 (PST) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id B56AAC057E22; Tue, 12 Feb 2019 09:21:57 +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 7874416BE6; Tue, 12 Feb 2019 09:21: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 17B79181A000; Tue, 12 Feb 2019 09:21:57 +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 x1C9Lev1023957 for ; Tue, 12 Feb 2019 04:21:40 -0500 Received: by smtp.corp.redhat.com (Postfix) id 231695C229; Tue, 12 Feb 2019 09:21:40 +0000 (UTC) Received: from icr.brq.redhat.com (unknown [10.43.2.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9CA9B5C21A for ; Tue, 12 Feb 2019 09:21:39 +0000 (UTC) From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Date: Tue, 12 Feb 2019 10:21:23 +0100 Message-Id: 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 Subject: [libvirt] [PATCH 5/9] virsh: do not access uninitialized memory in cmdDomFSInfo 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: , Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Tue, 12 Feb 2019 09:21:58 +0000 (UTC) Initialize 'info' to prevent accessing random access memory. Introduced by commit 3072ded released in 4.8.0. https://bugzilla.redhat.com/show_bug.cgi?id=3D1676354 Signed-off-by: J=C3=A1n Tomko --- tools/virsh-domain.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c index 651766cd84..d5026286c9 100644 --- a/tools/virsh-domain.c +++ b/tools/virsh-domain.c @@ -13938,7 +13938,7 @@ cmdDomFSInfo(vshControl *ctl, const vshCmd *cmd) virDomainPtr dom =3D NULL; int rc =3D -1; size_t i, j; - virDomainFSInfoPtr *info; + virDomainFSInfoPtr *info =3D NULL; vshTablePtr table =3D NULL; size_t ninfos =3D 0; =20 --=20 2.19.2 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sun May 5 06:12:08 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 15499633305581002.6758790066554; Tue, 12 Feb 2019 01:22:10 -0800 (PST) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 5AEEA1F56A; Tue, 12 Feb 2019 09:22:08 +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 0F3AD62948; Tue, 12 Feb 2019 09:22:08 +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 AC2F73F607; Tue, 12 Feb 2019 09:22:07 +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 x1C9Lel9023962 for ; Tue, 12 Feb 2019 04:21:40 -0500 Received: by smtp.corp.redhat.com (Postfix) id E83A75C229; Tue, 12 Feb 2019 09:21:40 +0000 (UTC) Received: from icr.brq.redhat.com (unknown [10.43.2.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6F3935C21A for ; Tue, 12 Feb 2019 09:21:40 +0000 (UTC) From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Date: Tue, 12 Feb 2019 10:21:24 +0100 Message-Id: <023f0672d4154a31919e74a02c5e77cfab9d67ca.1549963201.git.jtomko@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 Subject: [libvirt] [PATCH 6/9] virsh: introduce 'ret' in cmdDomFSInfo 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: , Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Tue, 12 Feb 2019 09:22:09 +0000 (UTC) Failing to print the table is also a reason to return failure and print the reported error. Switch to the usual pattern where we fall through the cleanup label right after setting ret to true instead of infering the return value from the number of filesystems returned. Signed-off-by: J=C3=A1n Tomko --- tools/virsh-domain.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c index d5026286c9..cb2da8eb5b 100644 --- a/tools/virsh-domain.c +++ b/tools/virsh-domain.c @@ -13941,6 +13941,7 @@ cmdDomFSInfo(vshControl *ctl, const vshCmd *cmd) virDomainFSInfoPtr *info =3D NULL; vshTablePtr table =3D NULL; size_t ninfos =3D 0; + bool ret =3D false; =20 if (!(dom =3D virshCommandOptDomain(ctl, cmd, NULL))) return false; @@ -13953,6 +13954,7 @@ cmdDomFSInfo(vshControl *ctl, const vshCmd *cmd) ninfos =3D rc; =20 if (ninfos =3D=3D 0) { + ret =3D true; vshError(ctl, _("No filesystems are mounted in the domain")); goto cleanup; } @@ -13986,6 +13988,8 @@ cmdDomFSInfo(vshControl *ctl, const vshCmd *cmd) vshTablePrintToStdout(table, ctl); } =20 + ret =3D true; + cleanup: if (info) { for (i =3D 0; i < ninfos; i++) @@ -13994,7 +13998,7 @@ cmdDomFSInfo(vshControl *ctl, const vshCmd *cmd) } vshTableFree(table); virshDomainFree(dom); - return rc >=3D 0; + return ret; } =20 const vshCmdDef domManagementCmds[] =3D { --=20 2.19.2 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sun May 5 06:12:08 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1549963335693591.3077550568304; Tue, 12 Feb 2019 01:22:15 -0800 (PST) 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 mx1.redhat.com (Postfix) with ESMTPS id B3C142D4B72; Tue, 12 Feb 2019 09:22:12 +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 808DE62F8B; Tue, 12 Feb 2019 09:22:12 +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 32BDD3F60A; Tue, 12 Feb 2019 09:22:12 +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 x1C9LiP2024143 for ; Tue, 12 Feb 2019 04:21:44 -0500 Received: by smtp.corp.redhat.com (Postfix) id 31FCC5C23A; Tue, 12 Feb 2019 09:21:44 +0000 (UTC) Received: from icr.brq.redhat.com (unknown [10.43.2.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id A53A25C229 for ; Tue, 12 Feb 2019 09:21:41 +0000 (UTC) From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Date: Tue, 12 Feb 2019 10:21:25 +0100 Message-Id: <066d91ec796994f7d382c59434d1557d87e8d6ba.1549963201.git.jtomko@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 Subject: [libvirt] [PATCH 7/9] virsh: do not report error on zero filesystems in cmdDomFSInfo 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: , Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Tue, 12 Feb 2019 09:22:14 +0000 (UTC) Use vshPrintExtra to report this message. It is a human-readable explanation rather than an error. Also, it is a very special system that runs with no filesystems. Signed-off-by: J=C3=A1n Tomko --- tools/virsh-domain.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c index cb2da8eb5b..d21e77ce75 100644 --- a/tools/virsh-domain.c +++ b/tools/virsh-domain.c @@ -13955,7 +13955,7 @@ cmdDomFSInfo(vshControl *ctl, const vshCmd *cmd) =20 if (ninfos =3D=3D 0) { ret =3D true; - vshError(ctl, _("No filesystems are mounted in the domain")); + vshPrintExtra(ctl, _("No filesystems are mounted in the domain")); goto cleanup; } =20 --=20 2.19.2 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sun May 5 06:12:08 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1549963319634449.6029930409193; Tue, 12 Feb 2019 01:21:59 -0800 (PST) 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 mx1.redhat.com (Postfix) with ESMTPS id B87C29B309; Tue, 12 Feb 2019 09:21:57 +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 7605117A73; Tue, 12 Feb 2019 09:21: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 12D3F1819AFB; Tue, 12 Feb 2019 09:21:57 +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 x1C9LkPv024311 for ; Tue, 12 Feb 2019 04:21:46 -0500 Received: by smtp.corp.redhat.com (Postfix) id A736E5C229; Tue, 12 Feb 2019 09:21:46 +0000 (UTC) Received: from icr.brq.redhat.com (unknown [10.43.2.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2C6515C25D for ; Tue, 12 Feb 2019 09:21:44 +0000 (UTC) From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Date: Tue, 12 Feb 2019 10:21:26 +0100 Message-Id: <0e7707d830d4b78b4e3764339bed05518852b005.1549963201.git.jtomko@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 Subject: [libvirt] [PATCH 8/9] virsh: use virBufferTrim in cmdDomFSInfo 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: , Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Tue, 12 Feb 2019 09:21:58 +0000 (UTC) Add comma after every string and trim the final one. Signed-off-by: J=C3=A1n Tomko --- tools/virsh-domain.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c index d21e77ce75..6124126576 100644 --- a/tools/virsh-domain.c +++ b/tools/virsh-domain.c @@ -13968,11 +13968,9 @@ cmdDomFSInfo(vshControl *ctl, const vshCmd *cmd) virBuffer targetsBuff =3D VIR_BUFFER_INITIALIZER; VIR_AUTOFREE(char *) targets =3D NULL; =20 - for (j =3D 0; j < info[i]->ndevAlias; j++) { - virBufferAdd(&targetsBuff, info[i]->devAlias[j], -1); - if (j !=3D info[i]->ndevAlias - 1) - virBufferAddChar(&targetsBuff, ','); - } + for (j =3D 0; j < info[i]->ndevAlias; j++) + virBufferAsprintf(&targetsBuff, "%s,", info[i]->devAlias[j= ]); + virBufferTrim(&targetsBuff, ",", -1); =20 targets =3D virBufferContentAndReset(&targetsBuff); =20 --=20 2.19.2 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sun May 5 06:12:08 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1549963325921502.05906662782843; Tue, 12 Feb 2019 01:22:05 -0800 (PST) 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 mx1.redhat.com (Postfix) with ESMTPS id 27B17C0C6C18; Tue, 12 Feb 2019 09:22:03 +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 839B817967; Tue, 12 Feb 2019 09:22:02 +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 F09153F603; Tue, 12 Feb 2019 09:22:01 +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 x1C9Lq03024340 for ; Tue, 12 Feb 2019 04:21:52 -0500 Received: by smtp.corp.redhat.com (Postfix) id 360785C23A; Tue, 12 Feb 2019 09:21:52 +0000 (UTC) Received: from icr.brq.redhat.com (unknown [10.43.2.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id AFE9A5C229 for ; Tue, 12 Feb 2019 09:21:46 +0000 (UTC) From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Date: Tue, 12 Feb 2019 10:21:27 +0100 Message-Id: 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 Subject: [libvirt] [PATCH 9/9] virsh: allow empty targets in cmdDomFSInfo 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: , Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Tue, 12 Feb 2019 09:22:04 +0000 (UTC) Ever since the introduction of the guest-get-fsinfo command in QEMU commit 46d4c572 qga/qapi-schema.json says that the 'disks' array can possibly be empty. For example when getting the target list is unsupported: https://bugzilla.redhat.com/show_bug.cgi?id=3D1567041 Pass an empty string instead of NULL to vshTableRowAppend to prevent a mismatched column number. Signed-off-by: J=C3=A1n Tomko --- tools/virsh-domain.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c index 6124126576..686fea8dd1 100644 --- a/tools/virsh-domain.c +++ b/tools/virsh-domain.c @@ -13978,7 +13978,7 @@ cmdDomFSInfo(vshControl *ctl, const vshCmd *cmd) info[i]->mountpoint, info[i]->name, info[i]->fstype, - targets, + targets ? : "", NULL) < 0) goto cleanup; } --=20 2.19.2 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list