Received: from eggs.gnu.org ([208.118.235.92]:48949) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Sei70-0006I0-2s for qemu-devel@nongnu.org; Wed, 13 Jun 2012 03:35:34 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Sei6y-0008Tk-9B for qemu-devel@nongnu.org; Wed, 13 Jun 2012 03:35:29 -0400 Received: from mx1.redhat.com ([209.132.183.28]:28434) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Sei6y-0008TS-0x for qemu-devel@nongnu.org; Wed, 13 Jun 2012 03:35:28 -0400 From: Markus Armbruster References: <1338900668-6093-1-git-send-email-armbru@redhat.com> <1338900668-6093-3-git-send-email-armbru@redhat.com> Date: Wed, 13 Jun 2012 09:35:17 +0200 In-Reply-To: (Peter Maydell's message of "Thu, 7 Jun 2012 13:49:43 +0100") Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Subject: Re: [Qemu-devel] [PATCH 2/2] xen: Don't peek behind the BlockDriverState abstraction List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Peter Maydell Cc: kwolf@redhat.com, qemu-devel@nongnu.org, stefano.stabellini@eu.citrix.com Peter Maydell writes: > On 7 June 2012 09:13, Markus Armbruster wrote: >> Peter Maydell writes: >>> I think it matters in the general case, yours is just the first >>> usage of this API which has caught my attention. We should fix >>> the API before adding more uses of it (at the moment it seems to >>> be only used in two places). >> >> What kind of fix do you have in mind? > > Option 1: the function should guarantee that it won't ever > use more than X bytes of buffer, and provide a #define that > corresponds to that maximum length. > > Option 2: this: vv > >>> Alternatively, we could have the function return a const char* rather >>> than taking a buffer to be filled in. >> >> Trades the theoretical string truncation problem for a theoretical >> dangling pointer problem. > > Yes, you'd need to come up with some reasonable lifecycle > management if you took this option. Actually, the lifecycle is trivial, because it's a *driver* name, and drivers never go away. Taking option 2.