[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH 2/6] rtl8139: g_malloc() can't fail, bury dead e
From: |
Thomas Huth |
Subject: |
Re: [Qemu-devel] [PATCH 2/6] rtl8139: g_malloc() can't fail, bury dead error handling |
Date: |
Tue, 27 Jan 2015 18:15:16 +0100 |
On Tue, 27 Jan 2015 17:38:27 +0100
Markus Armbruster <address@hidden> wrote:
> Signed-off-by: Markus Armbruster <address@hidden>
> ---
> hw/net/rtl8139.c | 14 --------------
> 1 file changed, 14 deletions(-)
>
> diff --git a/hw/net/rtl8139.c b/hw/net/rtl8139.c
> index 6fa9e0a..b55e438 100644
> --- a/hw/net/rtl8139.c
> +++ b/hw/net/rtl8139.c
> @@ -2075,20 +2075,6 @@ static int rtl8139_cplus_transmit_one(RTL8139State *s)
> "length to %d\n", txsize);
> }
>
> - if (!s->cplus_txbuffer)
> - {
> - /* out of memory */
> -
> - DPRINTF("+++ C+ mode transmiter failed to reallocate %d bytes\n",
> - s->cplus_txbuffer_len);
> -
> - /* update tally counter */
> - ++s->tally_counters.TxERR;
> - ++s->tally_counters.TxAbt;
> -
> - return 0;
> - }
> -
> /* append more data to the packet */
>
> DPRINTF("+++ C+ mode transmit reading %d bytes from host memory at "
Wouldn't it be better to use g_try_malloc() here instead? If the code
can handle OOM conditions, I think it's better to continue with a lost
packet here than to shut down QEMU the hard way.
(Also looking at the history of that file, the code originally used
qemu_malloc() which could fail - but instead of being replaced by
g_try_malloc(), it got replaced with g_malloc() instead which was
maybe the wrong decision).
Thomas
- [Qemu-devel] [PATCH 0/6] Trivial cleanups around g_malloc(), Markus Armbruster, 2015/01/27
- [Qemu-devel] [PATCH 6/6] translate-all: Use g_try_malloc() for dynamic translator buffer, Markus Armbruster, 2015/01/27
- [Qemu-devel] [PATCH 2/6] rtl8139: g_malloc() can't fail, bury dead error handling, Markus Armbruster, 2015/01/27
- Re: [Qemu-devel] [PATCH 2/6] rtl8139: g_malloc() can't fail, bury dead error handling,
Thomas Huth <=
- [Qemu-devel] [PATCH 3/6] kvm: g_malloc() can't fail, bury dead error handling, Markus Armbruster, 2015/01/27
- [Qemu-devel] [PATCH 1/6] onenand: g_malloc() can't fail, bury dead error handling, Markus Armbruster, 2015/01/27
- [Qemu-devel] [PATCH 5/6] vnc: g_realloc() can't fail, bury dead error handling, Markus Armbruster, 2015/01/27
- [Qemu-devel] [PATCH 4/6] rdma: g_malloc0() can't fail, bury dead error handling, Markus Armbruster, 2015/01/27
- Re: [Qemu-devel] [PATCH 0/6] Trivial cleanups around g_malloc(), Eric Blake, 2015/01/27
- Re: [Qemu-devel] [PATCH 0/6] Trivial cleanups around g_malloc(), Markus Armbruster, 2015/01/28