From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NeVBR-000129-VI for qemu-devel@nongnu.org; Mon, 08 Feb 2010 10:05:53 -0500 Received: from [199.232.76.173] (port=53683 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NeVBR-00011x-IU for qemu-devel@nongnu.org; Mon, 08 Feb 2010 10:05:53 -0500 Received: from Debian-exim by monty-python.gnu.org with spam-scanned (Exim 4.60) (envelope-from ) id 1NeVBP-0006e5-UI for qemu-devel@nongnu.org; Mon, 08 Feb 2010 10:05:53 -0500 Received: from mx1.redhat.com ([209.132.183.28]:53816) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1NeVBP-0006dz-GU for qemu-devel@nongnu.org; Mon, 08 Feb 2010 10:05:51 -0500 Date: Mon, 8 Feb 2010 13:05:37 -0200 From: Luiz Capitulino Subject: Re: [Qemu-devel] [PATCH 1/4] qjson: Improve debugging Message-ID: <20100208130537.4cce7f17@doriath> In-Reply-To: <4B702566.30605@codemonkey.ws> References: <1265314396-6583-1-git-send-email-lcapitulino@redhat.com> <1265314396-6583-2-git-send-email-lcapitulino@redhat.com> <4B6B4AD2.3060704@codemonkey.ws> <20100205101217.7ec97899@doriath> <4B6C3F3F.7010701@codemonkey.ws> <4B702566.30605@codemonkey.ws> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Anthony Liguori Cc: Markus Armbruster , qemu-devel@nongnu.org On Mon, 08 Feb 2010 08:53:26 -0600 Anthony Liguori wrote: > On 02/05/2010 11:14 AM, Markus Armbruster wrote: > >> Run time asserts are a terrible way to deal with reasonably expected errors. > >> > > Yes. But what's reasonably expected entirely depends on the contract > > between the function and its callers. > > > > I think we need a function that cannot fail and shouldn't used with > > untrusted arguments (for what it's worth, that's how we use > > qobject_from_jsonf() now). Having related functions with different > > contracts is fine with me. > > > > I think the key point is that if we're going to establish these > contracts, it must be obvious. > > A reasonable programmer is going to assume that if a function can return > a NULL, it can possibly return an error. If you want to deviate from > those semantics, you either have to name the function appropriately or > put a big comment above the declaration explaining the semantics. Given that qobject_from_jsonf() is already a good and long name, I prefer to add the comment. I will do that and re-submit.