From: Thomas Huth <thuth@linux.vnet.ibm.com>
To: Markus Armbruster <armbru@redhat.com>
Cc: qemu-trivial@redhat.com, qemu-devel@nongnu.org
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 [thread overview]
Message-ID: <20150127181516.27ab8e9d@oc7435384737.ibm.com> (raw)
In-Reply-To: <1422376711-31648-3-git-send-email-armbru@redhat.com>
On Tue, 27 Jan 2015 17:38:27 +0100
Markus Armbruster <armbru@redhat.com> wrote:
> Signed-off-by: Markus Armbruster <armbru@redhat.com>
> ---
> 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
next prev parent reply other threads:[~2015-01-27 17:15 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-01-27 16:38 [Qemu-devel] [PATCH 0/6] Trivial cleanups around g_malloc() Markus Armbruster
2015-01-27 16:38 ` [Qemu-devel] [PATCH 1/6] onenand: g_malloc() can't fail, bury dead error handling Markus Armbruster
2015-01-27 16:38 ` [Qemu-devel] [PATCH 2/6] rtl8139: " Markus Armbruster
2015-01-27 17:15 ` Thomas Huth [this message]
2015-01-28 10:58 ` Markus Armbruster
2015-01-27 16:38 ` [Qemu-devel] [PATCH 3/6] kvm: " Markus Armbruster
2015-01-27 17:22 ` Thomas Huth
2015-01-28 10:59 ` Markus Armbruster
2015-01-27 16:38 ` [Qemu-devel] [PATCH 4/6] rdma: g_malloc0() " Markus Armbruster
2015-01-27 16:38 ` [Qemu-devel] [PATCH 5/6] vnc: g_realloc() " Markus Armbruster
2015-01-27 17:17 ` Thomas Huth
2015-01-27 16:38 ` [Qemu-devel] [PATCH 6/6] translate-all: Use g_try_malloc() for dynamic translator buffer Markus Armbruster
2015-01-27 17:21 ` [Qemu-devel] [PATCH 0/6] Trivial cleanups around g_malloc() Eric Blake
2015-01-28 11:16 ` Markus Armbruster
2015-01-29 0:31 ` Gonglei
2015-01-29 2:21 ` Eric Blake
2015-01-29 2:51 ` Gonglei
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20150127181516.27ab8e9d@oc7435384737.ibm.com \
--to=thuth@linux.vnet.ibm.com \
--cc=armbru@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=qemu-trivial@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).