public inbox for pve-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: Mira Limbeck <m.limbeck@proxmox.com>
To: Fabian Ebner <f.ebner@proxmox.com>, pve-devel@lists.proxmox.com
Subject: Re: [pve-devel] [PATCH storage] fix #3894: file 'size' and 'used' are not integers
Date: Thu, 17 Feb 2022 15:19:22 +0100	[thread overview]
Message-ID: <fdc75c9c-8579-5985-3d12-edadafa35bc0@proxmox.com> (raw)
In-Reply-To: <28836632-339c-3c81-e7ae-9c1b2fdeaadd@proxmox.com>

On 2/17/22 15:10, Fabian Ebner wrote:
> Am 17.02.22 um 14:33 schrieb Mira Limbeck:
>> On 2/17/22 14:24, Fabian Ebner wrote:
>>> Am 17.02.22 um 13:55 schrieb Mira Limbeck:
>>>> 'qemu-img info' with output format 'json' returns the size and used
>>>> values as
>>>> integers, but the regex match converts them to strings.
>>>> As we know they only contain digits, we can simply cast them back to
>>>> integers
>>>> after the regex.
>>>>
>>>> The API requires them to be integers.
>>>>
>>> Any reason for not doing it in the API call itself? That would cover all
>>> plugins and future changes.
>> The main reason is that we call volume_size_info (which forwards to
>> file_size_info in most cases) and file_size_info in other parts of our
>> code as well. Wouldn't it be more consistent for `size` and `used` to be
>> integers in every context, rather than just in that specific API call?
> It doesn't hurt to do it, but it's not persistent, because Perl has no
> real types. If it's used as a string some time later (e.g. printed),
> it'll be a "string" again.
>
> When converting to JSON, the result depends on how the variable was last
> used, so IMHO it should happen as close to that point as possible.
>
Yes, that's what lead to this situation in the first place.

I'll send a v2 then with both this change and the cast in the API call.





      reply	other threads:[~2022-02-17 14:19 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-02-17 12:55 Mira Limbeck
2022-02-17 13:24 ` Fabian Ebner
2022-02-17 13:33   ` Mira Limbeck
2022-02-17 14:10     ` Fabian Ebner
2022-02-17 14:19       ` Mira Limbeck [this message]

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=fdc75c9c-8579-5985-3d12-edadafa35bc0@proxmox.com \
    --to=m.limbeck@proxmox.com \
    --cc=f.ebner@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 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