From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33780) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WQAXz-0006Ry-Ny for qemu-devel@nongnu.org; Wed, 19 Mar 2014 03:04:28 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WQAXr-0007nG-9k for qemu-devel@nongnu.org; Wed, 19 Mar 2014 03:04:19 -0400 Sender: Paolo Bonzini Message-ID: <53294155.8040403@redhat.com> Date: Wed, 19 Mar 2014 08:03:49 +0100 From: Paolo Bonzini MIME-Version: 1.0 References: <1395162223-28733-1-git-send-email-pbonzini@redhat.com> <874n2vcpu9.fsf@blackfin.pond.sub.org> In-Reply-To: <874n2vcpu9.fsf@blackfin.pond.sub.org> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH] scripts: add sample model file for Coverity Scan List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Markus Armbruster Cc: qemu-trivial@nongnu.org, qemu-devel@nongnu.org Il 18/03/2014 19:40, Markus Armbruster ha scritto: > > +void * > > +g_malloc (size_t n_bytes) > > +{ > > + void *mem; > > + __coverity_negative_sink__((ssize_t) n_bytes); > > + mem = malloc(n_bytes == 0 ? 1 : n_bytes); > > + if (!mem) __coverity_panic__ (); > > + return mem; > > +} > > This isn't quite honest: g_malloc(0) yields NULL. Same for the other > allocation functions. Oh, I didn't know that. It probably would make static analysis a bit less powerful or will return more false positives. The NULL return for realloc (in the "free" case) already causes some. So I'm undecided between a more correct model and a more selective one (with a fat comment). Paolo