all lists on lists.proxmox.com
 help / color / mirror / Atom feed
From: Stefan Reiter <s.reiter@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [pve-devel] [PATCH common] format: fix render_bytes with CLIFormatter
Date: Wed, 17 Feb 2021 14:32:16 +0100	[thread overview]
Message-ID: <20210217133216.2470-1-s.reiter@proxmox.com> (raw)

CLIFormatter passes in an options hash as a second paramter, which so
far was ignored. Now that we treat it as a precision parameter, check if
it is a hash and extract the option from it before using it.

Otherwise perl puts HASH(0x...) into the format and sprintf chokes.

Signed-off-by: Stefan Reiter <s.reiter@proxmox.com>
---

Reported here: https://forum.proxmox.com/threads/bug-found-where-to-post.84407/

I'm getting too used to Rust...

 src/PVE/Format.pm | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/src/PVE/Format.pm b/src/PVE/Format.pm
index ed86029..366bc16 100644
--- a/src/PVE/Format.pm
+++ b/src/PVE/Format.pm
@@ -64,6 +64,8 @@ sub render_fraction_as_percentage {
 sub render_bytes {
     my ($value, $precision) = @_;
 
+    $precision = $precision->{precision} if ref($precision) eq 'HASH';
+
     my @units = qw(B KiB MiB GiB TiB PiB);
 
     my $max_unit = 0;
-- 
2.20.1





             reply	other threads:[~2021-02-17 13:32 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-02-17 13:32 Stefan Reiter [this message]
2021-02-25 20:22 ` [pve-devel] applied: " Thomas Lamprecht

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210217133216.2470-1-s.reiter@proxmox.com \
    --to=s.reiter@proxmox.com \
    --cc=pve-devel@lists.proxmox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal