From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from [140.186.70.92] (port=40897 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OvxhN-0005I0-Hp for qemu-devel@nongnu.org; Wed, 15 Sep 2010 15:31:18 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OvxhM-0005cI-I8 for qemu-devel@nongnu.org; Wed, 15 Sep 2010 15:31:17 -0400 Received: from mx1.redhat.com ([209.132.183.28]:25123) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OvxhM-0005c6-7p for qemu-devel@nongnu.org; Wed, 15 Sep 2010 15:31:16 -0400 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o8FJVFAa016782 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Wed, 15 Sep 2010 15:31:15 -0400 Message-ID: <4C911EFE.2020504@redhat.com> Date: Wed, 15 Sep 2010 21:31:10 +0200 From: Jes Sorensen MIME-Version: 1.0 References: <1284553440-17985-1-git-send-email-Jes.Sorensen@redhat.com> <1284553440-17985-3-git-send-email-Jes.Sorensen@redhat.com> <4C90EA14.7040801@redhat.com> In-Reply-To: <4C90EA14.7040801@redhat.com> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Subject: [Qemu-devel] Re: [PATCH 2/5] Support human unit formats in strtobytes, eg. 1.0G List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Paolo Bonzini Cc: quintela@redhat.com, qemu-devel@nongnu.org, armbru@redhat.com On 09/15/10 17:45, Paolo Bonzini wrote: > On 09/15/2010 02:23 PM, Jes.Sorensen@redhat.com wrote: >> switch (*endptr++) { >> case 'K': >> case 'k': >> value<<= 10; >> break; >> case 0: >> + if (divider) { >> + value = 0; >> + break; >> + } >> case 'M': >> case 'm': >> value<<= 20; >> @@ -284,9 +306,12 @@ uint64_t strtobytes(const char *nptr, char **end) >> default: >> value = 0; >> } >> + if (divider) >> + value /= divider; >> > > This risks overflow if you do 1.00000000000000G or something similarly > braindead. Do we loathe floating point so much that you cannot use > strtod, like Floating point is just plain wrong. If someone wants to do something like in your example they really ask for an error. Jes