* [Qemu-devel] [PATCH] coverity: Fix g_malloc_n-like models
@ 2015-03-12 11:24 Jan Kiszka
2015-03-17 8:34 ` Markus Armbruster
0 siblings, 1 reply; 4+ messages in thread
From: Jan Kiszka @ 2015-03-12 11:24 UTC (permalink / raw)
Cc: Paolo Bonzini, qemu-devel, Markus Armbruster
Allocate the calculated overall size, not only the size of a single
element.
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
---
scripts/coverity-model.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/scripts/coverity-model.c b/scripts/coverity-model.c
index 58356af..cdda259 100644
--- a/scripts/coverity-model.c
+++ b/scripts/coverity-model.c
@@ -123,7 +123,7 @@ void *g_malloc_n(size_t nmemb, size_t size)
__coverity_negative_sink__(nmemb);
__coverity_negative_sink__(size);
sz = nmemb * size;
- ptr = __coverity_alloc__(size);
+ ptr = __coverity_alloc__(sz);
__coverity_mark_as_uninitialized_buffer__(ptr);
__coverity_mark_as_afm_allocated__(ptr, "g_free");
return ptr;
@@ -137,7 +137,7 @@ void *g_malloc0_n(size_t nmemb, size_t size)
__coverity_negative_sink__(nmemb);
__coverity_negative_sink__(size);
sz = nmemb * size;
- ptr = __coverity_alloc__(size);
+ ptr = __coverity_alloc__(sz);
__coverity_writeall0__(ptr);
__coverity_mark_as_afm_allocated__(ptr, "g_free");
return ptr;
@@ -151,7 +151,7 @@ void *g_realloc_n(void *ptr, size_t nmemb, size_t size)
__coverity_negative_sink__(size);
sz = nmemb * size;
__coverity_escape__(ptr);
- ptr = __coverity_alloc__(size);
+ ptr = __coverity_alloc__(sz);
/*
* Memory beyond the old size isn't actually initialized. Can't
* model that. See Coverity's realloc() model
--
2.1.4
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [Qemu-devel] [PATCH] coverity: Fix g_malloc_n-like models
2015-03-12 11:24 [Qemu-devel] [PATCH] coverity: Fix g_malloc_n-like models Jan Kiszka
@ 2015-03-17 8:34 ` Markus Armbruster
2015-03-17 8:48 ` Paolo Bonzini
0 siblings, 1 reply; 4+ messages in thread
From: Markus Armbruster @ 2015-03-17 8:34 UTC (permalink / raw)
To: qemu-trivial; +Cc: Paolo Bonzini, qemu-devel
Jan Kiszka <jan.kiszka@siemens.com> writes:
> Allocate the calculated overall size, not only the size of a single
> element.
>
> Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
I'm feeding this to Coverity locally to gauge its impact.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [Qemu-devel] [PATCH] coverity: Fix g_malloc_n-like models
2015-03-17 8:34 ` Markus Armbruster
@ 2015-03-17 8:48 ` Paolo Bonzini
2015-03-17 10:27 ` Markus Armbruster
0 siblings, 1 reply; 4+ messages in thread
From: Paolo Bonzini @ 2015-03-17 8:48 UTC (permalink / raw)
To: Markus Armbruster, qemu-trivial; +Cc: qemu-devel
On 17/03/2015 09:34, Markus Armbruster wrote:
> Jan Kiszka <jan.kiszka@siemens.com> writes:
>
>> Allocate the calculated overall size, not only the size of a single
>> element.
>>
>> Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
>
> I'm feeding this to Coverity locally to gauge its impact.
I got no changes.
Paolo
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [Qemu-devel] [PATCH] coverity: Fix g_malloc_n-like models
2015-03-17 8:48 ` Paolo Bonzini
@ 2015-03-17 10:27 ` Markus Armbruster
0 siblings, 0 replies; 4+ messages in thread
From: Markus Armbruster @ 2015-03-17 10:27 UTC (permalink / raw)
To: Paolo Bonzini; +Cc: qemu-trivial, qemu-devel
Paolo Bonzini <pbonzini@redhat.com> writes:
> On 17/03/2015 09:34, Markus Armbruster wrote:
>> Jan Kiszka <jan.kiszka@siemens.com> writes:
>>
>>> Allocate the calculated overall size, not only the size of a single
>>> element.
>>>
>>> Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
>>
>> I'm feeding this to Coverity locally to gauge its impact.
>
> I got no changes.
Yep, same here. Applied, thanks!
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2015-03-17 10:28 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-03-12 11:24 [Qemu-devel] [PATCH] coverity: Fix g_malloc_n-like models Jan Kiszka
2015-03-17 8:34 ` Markus Armbruster
2015-03-17 8:48 ` Paolo Bonzini
2015-03-17 10:27 ` Markus Armbruster
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.