Received: from [140.186.70.92] (port=39767 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PhQVn-0003Hh-V5 for qemu-devel@nongnu.org; Mon, 24 Jan 2011 12:47:32 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PhQVm-0006Vs-AN for qemu-devel@nongnu.org; Mon, 24 Jan 2011 12:47:31 -0500 Received: from mx1.redhat.com ([209.132.183.28]:29362) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PhQVm-0006Vo-3i for qemu-devel@nongnu.org; Mon, 24 Jan 2011 12:47:30 -0500 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 p0OHlTgg008724 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Mon, 24 Jan 2011 12:47:29 -0500 From: Markus Armbruster Subject: Re: [Qemu-devel] [PATCH 4/4] strtosz(): Use suffix macros in switch() statement References: <1295883211-18288-1-git-send-email-Jes.Sorensen@redhat.com> <1295883211-18288-5-git-send-email-Jes.Sorensen@redhat.com> <4D3DA473.1070704@redhat.com> <4D3DABBD.5020706@redhat.com> Date: Mon, 24 Jan 2011 18:47:17 +0100 In-Reply-To: <4D3DABBD.5020706@redhat.com> (Jes Sorensen's message of "Mon, 24 Jan 2011 17:41:33 +0100") Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Jes Sorensen Cc: kwolf@redhat.com, qemu-devel@nongnu.org Jes Sorensen writes: > On 01/24/11 17:39, Markus Armbruster wrote: >>>>> + case STRTOSZ_DEFSUFFIX_TB: >>>>> >>> mul = 1ULL << 40; >>>>> >>> break; >>>>> >>> default: >>>> >> >>>> >> Phony abstraction. And it leaks: code here assumes the >>>> >> STRTOSZ_DEFSUFFIX_T* are all upper case. >>> > >>> > qemu_toupper() - whats the problem? >> If a STRTOSZ_DEFSUFFIX_T? expands to a lower case character, its case >> will not match any input. > > Right, so one has to be careful when adding new suffix constants. Calls for a comment right next to the definition of the STRTOSZ_DEFSUFFIX_T*. I hate unstated restrictions that are hidden far away from the place where you can break them. > However given that we already have all the likely to be used ones for > the near future, that isn't exactly a big issue. > > On the other hand forcing the use of the macros makes it less likely > that someone specifies an unsupported constant by hitting 'y' instead of > 't' or similar. Takes a combination of butterfingers, cross-eyedness, and near-total incompetence at basic smoke-testing.