Re: [Libguestfs] [PATCH nbdinfo 1/2] common/utils: Add function to convert sizes to human-readable

2021-09-20 Thread Richard W.M. Jones
On Mon, Sep 20, 2021 at 12:50:47PM +0200, Martin Kletzander wrote: > And just set here: > > *human = i == 6; > > Even better make it more future-proof and use (sizeof(ext) / sizeof(*ext)) > instead of just "6". Disclaimer: Written by hand, not tested. In my v2 I will change it to: + /* Set

Re: [Libguestfs] [PATCH nbdinfo 1/2] common/utils: Add function to convert sizes to human-readable

2021-09-20 Thread Martin Kletzander
On Sat, Sep 18, 2021 at 03:38:52PM +0100, Richard W.M. Jones wrote: For example 1024 is returned as "1K". This does not attempt to handle decimals or SI units. If the number isn't some multiple of a power of 1024 then it is returned as bytes (a flag is available to indicate this). I looked at

[Libguestfs] [PATCH nbdinfo 1/2] common/utils: Add function to convert sizes to human-readable

2021-09-18 Thread Richard W.M. Jones
For example 1024 is returned as "1K". This does not attempt to handle decimals or SI units. If the number isn't some multiple of a power of 1024 then it is returned as bytes (a flag is available to indicate this). I looked at both the gnulib and qemu versions of this function. The gnulib