|
From: | Paolo Bonzini |
Subject: | Re: [Qemu-trivial] [PATCH] scripts: add sample model file for Coverity Scan |
Date: | Wed, 19 Mar 2014 08:03:49 +0100 |
User-agent: | Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.2.0 |
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
[Prev in Thread] | Current Thread | [Next in Thread] |