From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:46066) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SrUOx-00050p-OA for qemu-devel@nongnu.org; Wed, 18 Jul 2012 09:34:59 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SrUOq-0003pd-AX for qemu-devel@nongnu.org; Wed, 18 Jul 2012 09:34:51 -0400 Received: from mx1.redhat.com ([209.132.183.28]:8406) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SrUOq-0003pR-2E for qemu-devel@nongnu.org; Wed, 18 Jul 2012 09:34:44 -0400 Message-ID: <5006BB6D.4040103@redhat.com> Date: Wed, 18 Jul 2012 07:34:37 -0600 From: Eric Blake MIME-Version: 1.0 References: <1342617786-22107-1-git-send-email-wdongxu@linux.vnet.ibm.com> In-Reply-To: <1342617786-22107-1-git-send-email-wdongxu@linux.vnet.ibm.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="------------enig486C91FB83233BF1D270B9F0" Subject: Re: [Qemu-devel] [PATCH v3] qemu-img: correct size parsers and help message List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Dong Xu Wang Cc: kwolf@redhat.com, qemu-devel@nongnu.org, riegamaths@gmail.com This is an OpenPGP/MIME signed message (RFC 2440 and 3156) --------------enig486C91FB83233BF1D270B9F0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable 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 co= rrect > it in help message. >=20 > +++ 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 suffixe= s\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, 102= 4k),\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 =3D strtosz_suffix(argv[optind++], &end, STRTOSZ_DEFSUFFI= X_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 siz= e"); > - 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 capitalizatio= n. --=20 Eric Blake eblake@redhat.com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --------------enig486C91FB83233BF1D270B9F0 Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.12 (GNU/Linux) Comment: Public key at http://people.redhat.com/eblake/eblake.gpg Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iQEcBAEBCAAGBQJQBrttAAoJEKeha0olJ0NqyPwH/AgANAvxezzjF1Y+hzp4dWdY YY+fuLVolq/Lq806U/VDloeAFBd4H0xmjawYM7lhDX+iDJzISq6ITtLHTuDdi8mF cWgyoCSsO69XCg9r7aQEVcBtOOerFYCMSBuApfYlW+VVaVEpEVAMY8vNjthDkBf9 EZqkQ5Rcc3qPbBHEZlkyOpIdywvZBnVuwsVd4v1d+YLkpLS9/kxqh5PMGjGcJm8x wPx7vViqDVvV/H4P/TnRsRRop+b932hlZOw4mCoWs7qE15covVrWAie8q6SuRTCF /ecAvuXE16rfCkM4p67sJIS3OzDVmKDZ7y9ckXGmnmMzUdBb3RjpwNnki7Pa1sw= =BPVu -----END PGP SIGNATURE----- --------------enig486C91FB83233BF1D270B9F0--