public inbox for pve-devel@lists.proxmox.com
 help / color / mirror / Atom feed
* [pve-devel] [PATCH common] format: fix render_bytes with CLIFormatter
@ 2021-02-17 13:32 Stefan Reiter
  2021-02-25 20:22 ` [pve-devel] applied: " Thomas Lamprecht
  0 siblings, 1 reply; 2+ messages in thread
From: Stefan Reiter @ 2021-02-17 13:32 UTC (permalink / raw)
  To: pve-devel

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





^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-02-25 20:22 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-02-17 13:32 [pve-devel] [PATCH common] format: fix render_bytes with CLIFormatter Stefan Reiter
2021-02-25 20:22 ` [pve-devel] applied: " Thomas Lamprecht

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal