Received: from eggs.gnu.org ([2001:4830:134:3::10]:35019) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WQCUG-0008KC-Q8 for qemu-devel@nongnu.org; Wed, 19 Mar 2014 05:08:42 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WQCUA-0005e8-Pp for qemu-devel@nongnu.org; Wed, 19 Mar 2014 05:08:36 -0400 From: Markus Armbruster References: <1395162223-28733-1-git-send-email-pbonzini@redhat.com> <874n2vcpu9.fsf@blackfin.pond.sub.org> <53294155.8040403@redhat.com> Date: Wed, 19 Mar 2014 10:08:24 +0100 In-Reply-To: <53294155.8040403@redhat.com> (Paolo Bonzini's message of "Wed, 19 Mar 2014 08:03:49 +0100") Message-ID: <87d2hi4ktz.fsf@blackfin.pond.sub.org> MIME-Version: 1.0 Content-Type: text/plain 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: Paolo Bonzini Cc: qemu-trivial@nongnu.org, qemu-devel@nongnu.org Paolo Bonzini writes: > 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). I can't see how lying to the analyzer could make it more powerful :) It can, however, suppress false positives. Scan and find out how many?