From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42449) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YG5pK-00071g-D3 for qemu-devel@nongnu.org; Tue, 27 Jan 2015 08:05:11 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YG5lp-0002bp-8m for qemu-devel@nongnu.org; Tue, 27 Jan 2015 08:01:37 -0500 Received: from mail-we0-x230.google.com ([2a00:1450:400c:c03::230]:42505) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YG5lp-0002bV-23 for qemu-devel@nongnu.org; Tue, 27 Jan 2015 08:01:29 -0500 Received: by mail-we0-f176.google.com with SMTP id w62so14748583wes.7 for ; Tue, 27 Jan 2015 05:01:27 -0800 (PST) Sender: Paolo Bonzini Message-ID: <54C78C24.2030304@redhat.com> Date: Tue, 27 Jan 2015 14:01:24 +0100 From: Paolo Bonzini MIME-Version: 1.0 References: <1422361514-25226-1-git-send-email-armbru@redhat.com> In-Reply-To: <1422361514-25226-1-git-send-email-armbru@redhat.com> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH] block: Simplify a few g_try_malloc() error checks List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Markus Armbruster , qemu-devel@nongnu.org Cc: kwolf@redhat.com, stefanha@redhat.com On 27/01/2015 13:25, Markus Armbruster wrote: > Unlike malloc(), g_try_malloc() & friends return a null pointer only > on failure, never for a zero size. Simplify tests for failure > accordingly. This helps Coverity see returned null pointers can't be > dereferenced. Also makes the code easier to read. Unfortunately that's not what I see from the source: gpointer g_try_malloc (gsize n_bytes) { gpointer mem; if (G_LIKELY (n_bytes)) mem = glib_mem_vtable.try_malloc (n_bytes); else mem = NULL; TRACE (GLIB_MEM_ALLOC((void*) mem, (unsigned int) n_bytes, 0, 1)); return mem; } Paolo