From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from [140.186.70.92] (port=40695 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PfDPx-0003J5-1l for qemu-devel@nongnu.org; Tue, 18 Jan 2011 10:24:22 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PfDPv-0003ln-Ty for qemu-devel@nongnu.org; Tue, 18 Jan 2011 10:24:20 -0500 Received: from mx1.redhat.com ([209.132.183.28]:1027) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PfDPv-0003lb-Jb for qemu-devel@nongnu.org; Tue, 18 Jan 2011 10:24:19 -0500 Received: from int-mx12.intmail.prod.int.phx2.redhat.com (int-mx12.intmail.prod.int.phx2.redhat.com [10.5.11.25]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id p0IFOInn028527 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Tue, 18 Jan 2011 10:24:18 -0500 Subject: Re: [Qemu-devel] [PATCH 2/2] strtosz(): Use suffix macros in switch() statement From: Alex Williamson In-Reply-To: References: <1295284345-24524-1-git-send-email-Jes.Sorensen@redhat.com> <1295284345-24524-3-git-send-email-Jes.Sorensen@redhat.com> Content-Type: text/plain; charset="UTF-8" Date: Tue, 18 Jan 2011 08:24:16 -0700 Message-ID: <1295364256.30628.6.camel@x201> Mime-Version: 1.0 Content-Transfer-Encoding: quoted-printable List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Markus Armbruster Cc: kwolf@redhat.com, Jes.Sorensen@redhat.com, eblake@redhat.com, qemu-devel@nongnu.org On Tue, 2011-01-18 at 10:20 +0100, Markus Armbruster wrote: > Jes.Sorensen@redhat.com writes: >=20 > > From: Jes Sorensen > > > > Signed-off-by: Jes Sorensen > > --- > > cutils.c | 10 +++++----- > > 1 files changed, 5 insertions(+), 5 deletions(-) > > > > diff --git a/cutils.c b/cutils.c > > index 328738c..f2c8bbd 100644 > > --- a/cutils.c > > +++ b/cutils.c > > @@ -324,26 +324,26 @@ ssize_t strtosz_suffix(const char *nptr, char *= *end, const char default_suffix) > > } > > } > > switch (toupper(d)) { > > - case 'B': > > + case STRTOSZ_DEFSUFFIX_B: > > mul =3D 1; > > if (mul_required) { > > goto fail; > > } > > break; > > - case 'K': > > + case STRTOSZ_DEFSUFFIX_KB: > > mul =3D 1 << 10; > > break; > > case 0: > > if (mul_required) { > > goto fail; > > } > > - case 'M': > > + case STRTOSZ_DEFSUFFIX_MB: > > mul =3D 1ULL << 20; > > break; > > - case 'G': > > + case STRTOSZ_DEFSUFFIX_GB: > > mul =3D 1ULL << 30; > > break; > > - case 'T': > > + case STRTOSZ_DEFSUFFIX_TB: > > mul =3D 1ULL << 40; > > break; > > default: >=20 > And this improves what? Certainly not clarity. >=20 > In my opinion, the STRTOSZ_DEFSUFFIX_TB are useless chaff. Chacun =C3=A0= son > go=C3=BBt. I prefer it. Better than having 'B'/'K'/'M'/'G'/'T' sprinkled throughout the code. Easier to search for, easier to update, more consistent. Alex