[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH] use qemu_malloc and friends consistently
From: |
Julian Seward |
Subject: |
Re: [Qemu-devel] [PATCH] use qemu_malloc and friends consistently |
Date: |
Fri, 29 May 2009 19:17:10 +0200 |
User-agent: |
KMail/1.9.9 |
On Friday 29 May 2009, Paul Brook wrote:
> >(e) return malloc(0), without wrapping it into oom_check().
>
> This is the worst of both worlds.
>
> > For the purpose of finding broken code returning NULL is IMHO the best
> > option. Although dereferencing NULL is undefined, in practice it will
> > segfault in most cases so the bugs shouldn't stay unnoticed for long.
>
> The best way to find broken code is to have qemu_malloc(0) abort, and avoid
> ever trying to allocate a zero size block.
+1 for that. Code that relies on malloc(0) doing any specific thing
is basically bad news when it comes to portability, robustness
and understandability. Better to have qemu_malloc(0) abort, put up with
a couple of days of the trunk aborting, until these uses are fixed.
I'd be surprised if there were many cases anyway.
J
- Re: [Qemu-devel] [PATCH] use qemu_malloc and friends consistently, (continued)
- Re: [Qemu-devel] [PATCH] use qemu_malloc and friends consistently, Anthony Liguori, 2009/05/29
- Re: [Qemu-devel] [PATCH] use qemu_malloc and friends consistently, malc, 2009/05/29
- Re: [Qemu-devel] [PATCH] use qemu_malloc and friends consistently, Gerd Hoffmann, 2009/05/29
- Re: [Qemu-devel] [PATCH] use qemu_malloc and friends consistently, Paul Brook, 2009/05/29
- Re: [Qemu-devel] [PATCH] use qemu_malloc and friends consistently, Gerd Hoffmann, 2009/05/29
- Re: [Qemu-devel] [PATCH] use qemu_malloc and friends consistently, Glauber Costa, 2009/05/29
- Re: [Qemu-devel] [PATCH] use qemu_malloc and friends consistently, Anthony Liguori, 2009/05/29
- Re: [Qemu-devel] [PATCH] use qemu_malloc and friends consistently, malc, 2009/05/29
- Re: [Qemu-devel] [PATCH] use qemu_malloc and friends consistently,
Julian Seward <=
- Re: [Qemu-devel] [PATCH] use qemu_malloc and friends consistently, Gerd Hoffmann, 2009/05/29
- Re: [Qemu-devel] [PATCH] use qemu_malloc and friends consistently, David Turner, 2009/05/29
- Re: [Qemu-devel] [PATCH] use qemu_malloc and friends consistently, David Turner, 2009/05/29
- Re: [Qemu-devel] [PATCH] use qemu_malloc and friends consistently, Markus Armbruster, 2009/05/29
- Re: [Qemu-devel] [PATCH] use qemu_malloc and friends consistently, Gerd Hoffmann, 2009/05/29
- Re: [Qemu-devel] [PATCH] use qemu_malloc and friends consistently, malc, 2009/05/29
Re: [Qemu-devel] [PATCH] use qemu_malloc and friends consistently, jcd, 2009/05/29
Re: [Qemu-devel] [PATCH] use qemu_malloc and friends consistently, jcd, 2009/05/29