[Qemu-devel] [PATCH 88/88] scripts/coverity-model: use g_new() family of functions

Philippe Mathieu-Daudé posted 88 patches 8 years, 4 months ago
[Qemu-devel] [PATCH 88/88] scripts/coverity-model: use g_new() family of functions
Posted by Philippe Mathieu-Daudé 8 years, 4 months ago
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
 scripts/coverity-model.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/scripts/coverity-model.c b/scripts/coverity-model.c
index c702804f41..de07bffb57 100644
--- a/scripts/coverity-model.c
+++ b/scripts/coverity-model.c
@@ -363,7 +363,7 @@ int g_poll (GPollFD *fds, unsigned nfds, int timeout)
 typedef struct _GIOChannel GIOChannel;
 GIOChannel *g_io_channel_unix_new(int fd)
 {
-    GIOChannel *c = g_malloc0(sizeof(GIOChannel));
+    GIOChannel *c = g_new0(GIOChannel, 1);
     __coverity_escape__(fd);
     return c;
 }
-- 
2.14.2


Re: [Qemu-devel] [PATCH 88/88] scripts/coverity-model: use g_new() family of functions
Posted by Markus Armbruster 8 years, 4 months ago
Please cc me on changes to stuff I maintain, as scripts/get_maintainer
tells you :)

Philippe Mathieu-Daudé <f4bug@amsat.org> writes:

> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
> ---
>  scripts/coverity-model.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/scripts/coverity-model.c b/scripts/coverity-model.c
> index c702804f41..de07bffb57 100644
> --- a/scripts/coverity-model.c
> +++ b/scripts/coverity-model.c
> @@ -363,7 +363,7 @@ int g_poll (GPollFD *fds, unsigned nfds, int timeout)
>  typedef struct _GIOChannel GIOChannel;
>  GIOChannel *g_io_channel_unix_new(int fd)
>  {
> -    GIOChannel *c = g_malloc0(sizeof(GIOChannel));
> +    GIOChannel *c = g_new0(GIOChannel, 1);
>      __coverity_escape__(fd);
>      return c;
>  }

Hmm.

The Coverity model carefully explains g_malloc0().  It doesn't explain
g_new0().  With any luck, Coverity can see through g_new0() --- it's a
macro in my <gmem.h>.  But why complicate matters?  The normal reason
for changing g_malloc0() to g_new0() doesn't apply here.  Let's leave
the model alone.

Re: [Qemu-devel] [PATCH 88/88] scripts/coverity-model: use g_new() family of functions
Posted by Philippe Mathieu-Daudé 8 years, 3 months ago
Hi Markus,

On 10/09/2017 03:46 AM, Markus Armbruster wrote:
> Please cc me on changes to stuff I maintain, as scripts/get_maintainer
> tells you :)

Oops I might have been a copy/paste error.

> Philippe Mathieu-Daudé <f4bug@amsat.org> writes:
> 
>> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
>> ---
>>  scripts/coverity-model.c | 2 +-
[...]
>>  GIOChannel *g_io_channel_unix_new(int fd)
>>  {
>> -    GIOChannel *c = g_malloc0(sizeof(GIOChannel));
>> +    GIOChannel *c = g_new0(GIOChannel, 1);
>>      __coverity_escape__(fd);
>>      return c;
>>  }
> 
> Hmm.
> 
> The Coverity model carefully explains g_malloc0().  It doesn't explain
> g_new0().  With any luck, Coverity can see through g_new0() --- it's a
> macro in my <gmem.h>.  But why complicate matters?  The normal reason
> for changing g_malloc0() to g_new0() doesn't apply here.  Let's leave
> the model alone.

Yes you are right.