[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH 02/16] cutils: Support 'P' and 'E' suffixes in s
From: |
Eric Blake |
Subject: |
Re: [Qemu-devel] [PATCH 02/16] cutils: Support 'P' and 'E' suffixes in strtosz() |
Date: |
Tue, 28 May 2013 10:29:55 -0600 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130514 Thunderbird/17.0.6 |
On 05/28/2013 09:27 AM, Kevin Wolf wrote:
> Signed-off-by: Kevin Wolf <address@hidden>
> ---
> include/qemu-common.h | 2 ++
> monitor.c | 8 ++++----
> qemu-img.c | 10 ++++++----
> tests/qemu-iotests/049.out | 8 ++++----
> util/cutils.c | 4 ++++
> 5 files changed, 20 insertions(+), 12 deletions(-)
>
Reviewed-by: Eric Blake <address@hidden>
> +++ b/qemu-img.c
> @@ -84,8 +84,9 @@ static void help(void)
> " options are: 'none', 'writeback' (default, except for
> convert), 'writethrough',\n"
> " 'directsync' and 'unsafe' (default for convert)\n"
> " 'size' is the disk image size in bytes. Optional suffixes\n"
> - " 'k' or 'K' (kilobyte, 1024), 'M' (megabyte, 1024k), 'G'
> (gigabyte, 1024M)\n"
> - " and T (terabyte, 1024G) are supported. 'b' is ignored.\n"
> + " 'k' or 'K' (kilobyte, 1024), 'M' (megabyte, 1024k), 'G'
> (gigabyte, 1024M),\n"
> + " 'T' (terabyte, 1024G), 'P' (petabyte, 1024T) and 'E'
> (exabyte, 1024P) are\n"
Pre-existing, but should we be favoring the technically correct
kibibyte, mebibyte, gibibyte, ... terms, since we are treating it as
powers of 1024, rather than the potentially confusing kilobyte term
(since disk vendors favor powers of 1000)?
> +++ b/util/cutils.c
> @@ -267,6 +267,10 @@ static int64_t suffix_mul(char suffix, int64_t unit)
> return unit * unit * unit;
> case STRTOSZ_DEFSUFFIX_TB:
> return unit * unit * unit * unit;
> + case STRTOSZ_DEFSUFFIX_PB:
> + return unit * unit * unit * unit * unit;
> + case STRTOSZ_DEFSUFFIX_EB:
> + return unit * unit * unit * unit * unit * unit;
Pre-existing, but this code is not robust against overflow. And now
that you are adding E, it's 6 fewer decimal characters that I have to
type to pass in a value that will exceed even int64_t.
--
Eric Blake eblake redhat com +1-919-301-3266
Libvirt virtualization library http://libvirt.org
signature.asc
Description: OpenPGP digital signature
- [Qemu-devel] [PATCH 00/16] Make qemu-io commands available in the monitor, Kevin Wolf, 2013/05/28
- [Qemu-devel] [PATCH 01/16] qemu-io: Remove unused args_command, Kevin Wolf, 2013/05/28
- [Qemu-devel] [PATCH 02/16] cutils: Support 'P' and 'E' suffixes in strtosz(), Kevin Wolf, 2013/05/28
- Re: [Qemu-devel] [PATCH 02/16] cutils: Support 'P' and 'E' suffixes in strtosz(),
Eric Blake <=
- [Qemu-devel] [PATCH 03/16] qemu-io: Make cvtnum() a wrapper around strtosz_suffix(), Kevin Wolf, 2013/05/28
- [Qemu-devel] [PATCH 04/16] qemu-io: Handle cvtnum() errors in 'alloc', Kevin Wolf, 2013/05/28
- [Qemu-devel] [PATCH 05/16] qemu-io: Don't use global bs in command implementations, Kevin Wolf, 2013/05/28
- [Qemu-devel] [PATCH 08/16] qemu-io: Move 'help' function, Kevin Wolf, 2013/05/28
- [Qemu-devel] [PATCH 07/16] qemu-io: Factor out qemuio_command, Kevin Wolf, 2013/05/28