From: Eric Blake <eblake@redhat.com>
To: Dong Xu Wang <wdongxu@linux.vnet.ibm.com>
Cc: kwolf@redhat.com, qemu-devel@nongnu.org, riegamaths@gmail.com
Subject: Re: [Qemu-devel] [PATCH v3] qemu-img: correct size parsers and help message
Date: Wed, 18 Jul 2012 07:34:37 -0600 [thread overview]
Message-ID: <5006BB6D.4040103@redhat.com> (raw)
In-Reply-To: <1342617786-22107-1-git-send-email-wdongxu@linux.vnet.ibm.com>
[-- Attachment #1: Type: text/plain, Size: 2868 bytes --]
On 07/18/2012 07:23 AM, Dong Xu Wang wrote:
> qemu-img not only suports k/K/M/G/T/b, but also supports m/g/t/B. So correct
> it in help message.
>
> +++ b/qemu-img.c
> @@ -69,8 +69,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' or 'M' (megabyte, 1024k),\n"
> + " 'g' or 'G' (gigabyte, 1024M) and 't' or 'T' (terabyte, 1024G) are supported.\n"
> + " 'b' or 'B' is ignored.\n"
Technically, 'kilobyte' is only 1000 bytes; the correct term for 1024
bytes is 'kibibyte'. Likewise for 'megabyte' (1000000) vs. 'mebibyte'
(1024k, or 1,048,576 bytes); and so on for gibibytes and tebibytes.
Since disk manufacturers have already forced the rest of the world to
ask whether the number of bytes they are looking at is a power of 10 or
a power of 2 suffix, we might as well be precise in our naming to
document that we really are using powers of 2.
Furthermore, I think you can compress this by mentioning that the parse
is case-insensitive, instead of spelling out all the options:
'size' is the disk image size in bytes, scaled by an optional
case-insensitive suffix: 'k' (kibibyte, 1024), 'M' (mebibyte, 1024k),
'G' (gibibyte, 1024M), 'T' (tebibyte, 1024G), or 'b' (no scaling).
> @@ -341,8 +342,8 @@ static int img_create(int argc, char **argv)
> char *end;
> sval = strtosz_suffix(argv[optind++], &end, STRTOSZ_DEFSUFFIX_B);
> if (sval < 0 || *end) {
> - error_report("Invalid image size specified! You may use k, M, G or "
> - "T suffixes for ");
> + error_report("Invalid image size specified! You may use k/K, m/M, "
> + "g/G or t/T suffixes for ");
I personally dislike this change. Just because we're lenient in what we
accept does not mean we have to document all of the possibilities that
we parse when correcting a user error; rather, we need only document the
preferred possibilities.
> default:
> error_set(errp, QERR_INVALID_PARAMETER_VALUE, name, "a size");
> - error_printf_unless_qmp("You may use k, M, G or T suffixes for "
> + error_printf_unless_qmp("You may use K/k, M/m, G/g or T/t suffixes for "
Again, in an error message, I'd only document the preferred capitalization.
--
Eric Blake eblake@redhat.com +1-919-301-3266
Libvirt virtualization library http://libvirt.org
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 620 bytes --]
prev parent reply other threads:[~2012-07-18 13:34 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-07-18 13:23 [Qemu-devel] [PATCH v3] qemu-img: correct size parsers and help message Dong Xu Wang
2012-07-18 13:32 ` Kevin Wolf
2012-07-18 13:34 ` Eric Blake [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=5006BB6D.4040103@redhat.com \
--to=eblake@redhat.com \
--cc=kwolf@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=riegamaths@gmail.com \
--cc=wdongxu@linux.vnet.ibm.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;
as well as URLs for NNTP newsgroup(s).