From nobody Mon Feb 9 20:35:16 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=1632439556; cv=none; d=zohomail.com; s=zohoarc; b=Psp62kCj9d2fo2CTFd1MznQZgr5rAlZhl/3tnjkDvxhZeJKS4gyJnlCm85myahNY7g+33EJqIhhG0PSnpfTHlDwR3IsSPgisalsv0sAUBFOQTI7gdKQJ7NvbqWjbdUlYLySkYIV77meHeyP9qEOCdiayyo1S9fNNetCEG5ur0RE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1632439556; 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=PboRz9Un0s5rWbmuv9vC7TLQHzfkQplYnYnWifVLAxw=; b=lI2VjavOkwl+Z099HfozonJ9BlkvxtJlsD9kRsBElFz7vInocNr9y2IdJv2latmdXkaSgK1J6lmJFRWDFZK1SCbusinmEDrLJQJIdEVcoDrUCKqa7gDzkSHqO6pARtqq/hufYuBMLDiCg8cqsqdlN0TD+7lbu7gslJfGnm/Hp9Q= 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 163243955581892.73265444431354; Thu, 23 Sep 2021 16:25:55 -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-569-g8F_JPnaPLywFXUvyy1GBA-1; Thu, 23 Sep 2021 19:25:52 -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 EF08E362FC; Thu, 23 Sep 2021 23:25:47 +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 D506660936; Thu, 23 Sep 2021 23:25:47 +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 A8473181A1CF; Thu, 23 Sep 2021 23:25:47 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 18NNPVkA010352 for ; Thu, 23 Sep 2021 19:25:31 -0400 Received: by smtp.corp.redhat.com (Postfix) id 9736419733; Thu, 23 Sep 2021 23:25:31 +0000 (UTC) Received: from fedora.redhat.com (unknown [10.40.192.14]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8ECF819730 for ; Thu, 23 Sep 2021 23:25:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1632439554; 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=PboRz9Un0s5rWbmuv9vC7TLQHzfkQplYnYnWifVLAxw=; b=f1wT69ypMQgvV3q616Y5WDcAIsECNK236gLW4JGcezHzsXBE8jc5UPEv7Lg9XcCryEFKc9 Bmbl/uWLoYx26fQSlRZffthh3l4XYn/5Nj0RWatQNI5dOauTogN2cWBlRWszOV3cLap4xv OMWpabgrtO6GzYQky/IZHIoEIf6YwhY= X-MC-Unique: g8F_JPnaPLywFXUvyy1GBA-1 From: Kristina Hanicova To: libvir-list@redhat.com Subject: [PATCH v2 6/6] virsh: volume: refactor cmdVolInfo() Date: Fri, 24 Sep 2021 01:25:12 +0200 Message-Id: <515ff2baa062237785b3dcce391dbcca5b31b7d1.1632439268.git.khanicov@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 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 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: 1632439557888100001 Content-Type: text/plain; charset="utf-8" Signed-off-by: Kristina Hanicova --- tools/virsh-volume.c | 52 ++++++++++++++++++++------------------------ 1 file changed, 23 insertions(+), 29 deletions(-) diff --git a/tools/virsh-volume.c b/tools/virsh-volume.c index 152f5b0dbe..38bb62a48f 100644 --- a/tools/virsh-volume.c +++ b/tools/virsh-volume.c @@ -1057,7 +1057,6 @@ cmdVolInfo(vshControl *ctl, const vshCmd *cmd) virStorageVolPtr vol; bool bytes =3D vshCommandOptBool(cmd, "bytes"); bool physical =3D vshCommandOptBool(cmd, "physical"); - bool ret =3D true; int rc; unsigned int flags =3D 0; =20 @@ -1074,41 +1073,36 @@ cmdVolInfo(vshControl *ctl, const vshCmd *cmd) else rc =3D virStorageVolGetInfo(vol, &info); =20 - if (rc =3D=3D 0) { - double val; - const char *unit; + if (rc < 0) { + virStorageVolFree(vol); + return false; + } =20 - vshPrint(ctl, "%-15s %s\n", _("Type:"), - virshVolumeTypeToString(info.type)); + vshPrint(ctl, "%-15s %s\n", _("Type:"), + virshVolumeTypeToString(info.type)); =20 - if (bytes) { - vshPrint(ctl, "%-15s %llu %s\n", _("Capacity:"), - info.capacity, _("bytes")); - } else { - val =3D vshPrettyCapacity(info.capacity, &unit); - vshPrint(ctl, "%-15s %2.2lf %s\n", _("Capacity:"), val, unit); - } + if (bytes) { + vshPrint(ctl, "%-15s %llu %s\n", _("Capacity:"), info.capacity, _(= "bytes")); =20 - if (bytes) { - if (physical) - vshPrint(ctl, "%-15s %llu %s\n", _("Physical:"), - info.allocation, _("bytes")); - else - vshPrint(ctl, "%-15s %llu %s\n", _("Allocation:"), - info.allocation, _("bytes")); - } else { - val =3D vshPrettyCapacity(info.allocation, &unit); - if (physical) - vshPrint(ctl, "%-15s %2.2lf %s\n", _("Physical:"), val, un= it); - else - vshPrint(ctl, "%-15s %2.2lf %s\n", _("Allocation:"), val, = unit); - } + if (physical) + vshPrint(ctl, "%-15s %llu %s\n", _("Physical:"), info.allocati= on, _("bytes")); + else + vshPrint(ctl, "%-15s %llu %s\n", _("Allocation:"), info.alloca= tion, _("bytes")); } else { - ret =3D false; + const char *unit; + double val =3D vshPrettyCapacity(info.capacity, &unit); + + vshPrint(ctl, "%-15s %2.2lf %s\n", _("Capacity:"), val, unit); + val =3D vshPrettyCapacity(info.allocation, &unit); + + if (physical) + vshPrint(ctl, "%-15s %2.2lf %s\n", _("Physical:"), val, unit); + else + vshPrint(ctl, "%-15s %2.2lf %s\n", _("Allocation:"), val, unit= ); } =20 virStorageVolFree(vol); - return ret; + return true; } =20 /* --=20 2.31.1