From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NeUzT-0005Q7-Ls for qemu-devel@nongnu.org; Mon, 08 Feb 2010 09:53:31 -0500 Received: from [199.232.76.173] (port=60986 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NeUzT-0005Pz-D9 for qemu-devel@nongnu.org; Mon, 08 Feb 2010 09:53:31 -0500 Received: from Debian-exim by monty-python.gnu.org with spam-scanned (Exim 4.60) (envelope-from ) id 1NeUzR-0002ee-N1 for qemu-devel@nongnu.org; Mon, 08 Feb 2010 09:53:31 -0500 Received: from mail-iw0-f194.google.com ([209.85.223.194]:64570) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1NeUzR-0002eS-CC for qemu-devel@nongnu.org; Mon, 08 Feb 2010 09:53:29 -0500 Received: by iwn34 with SMTP id 34so2138601iwn.21 for ; Mon, 08 Feb 2010 06:53:28 -0800 (PST) Message-ID: <4B702566.30605@codemonkey.ws> Date: Mon, 08 Feb 2010 08:53:26 -0600 From: Anthony Liguori MIME-Version: 1.0 Subject: Re: [Qemu-devel] [PATCH 1/4] qjson: Improve debugging 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> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Markus Armbruster Cc: qemu-devel@nongnu.org, Luiz Capitulino 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. Regards, Anthony Liguori