All of lore.kernel.org
 help / color / mirror / Atom feed
From: Markus Armbruster <armbru@redhat.com>
To: Mao Zhongyi <maozy.fnst@cn.fujitsu.com>
Cc: qemu-devel@nongnu.org, jasowang@redhat.com, jiri@resnulli.us,
	f4bug@amsat.org
Subject: Re: [Qemu-devel] [PATCH v5 1/4] net/rocker: Remove the dead error handling
Date: Tue, 23 May 2017 11:27:47 +0200	[thread overview]
Message-ID: <87wp97hqi4.fsf@dusky.pond.sub.org> (raw)
In-Reply-To: <29c33313efd2ee4f7bf3abb71a4809582891f408.1495508197.git.maozy.fnst@cn.fujitsu.com> (Mao Zhongyi's message of "Tue, 23 May 2017 12:04:37 +0800")

Mao Zhongyi <maozy.fnst@cn.fujitsu.com> writes:

> Memory allocation functions like world_alloc, desc_ring_alloc etc,
> they are all wrappers around g_malloc, g_new etc. But g_malloc and 
> similar functions doesn't return null. Because they ignore the fact 

don't

> that g_malloc() of 0 bytes returns null. So error checks for these
> allocation failure are superfluous. Now, remove them entirely.
>
> Signed-off-by: Mao Zhongyi <maozy.fnst@cn.fujitsu.com>

Reviewed-by: Markus Armbruster <armbru@redhat.com>

There's one more cleanup opportunity:

> diff --git a/hw/net/rocker/rocker_desc.c b/hw/net/rocker/rocker_desc.c
> index ac02797..d0df89a 100644
> --- a/hw/net/rocker/rocker_desc.c
> +++ b/hw/net/rocker/rocker_desc.c
> @@ -65,10 +65,6 @@ char *desc_get_buf(DescInfo *info, bool read_only)
>          info->buf_size = size;
>      }
>  
> -    if (!info->buf) {
> -        return NULL;
> -    }
> -
>      if (pci_dma_read(dev, le64_to_cpu(info->desc.buf_addr), info->buf, size)) {
>          return NULL;
>      }

None of the pci_dma_read() calls outside rocker check the return value.
Just as well, because it always returns 0.  Please clean this up in a
separate followup patch.

[...]

  reply	other threads:[~2017-05-23  9:27 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-05-23  4:04 [Qemu-devel] [PATCH v5 0/4] Convert to realize and fix error handling Mao Zhongyi
2017-05-23  4:04 ` [Qemu-devel] [PATCH v5 1/4] net/rocker: Remove the dead " Mao Zhongyi
2017-05-23  9:27   ` Markus Armbruster [this message]
2017-05-23 10:09     ` Mao Zhongyi
2017-05-23 10:52       ` Markus Armbruster
2017-05-24  4:43     ` Philippe Mathieu-Daudé
2017-05-24  5:35       ` Markus Armbruster
2017-05-24 12:01         ` Marcel Apfelbaum
2017-05-25  1:02           ` David Gibson
2017-05-23  4:04 ` [Qemu-devel] [PATCH v5 2/4] net/rocker: Plug memory leak in pci_rocker_init() Mao Zhongyi
2017-05-24  4:48   ` Philippe Mathieu-Daudé
2017-05-23  4:04 ` [Qemu-devel] [PATCH v5 3/4] net/rocker: Convert to realize() Mao Zhongyi
2017-05-24  4:48   ` Philippe Mathieu-Daudé
2017-05-23  4:04 ` [Qemu-devel] [PATCH v5 4/4] net/rocker: Fix the unusual macro name Mao Zhongyi
2017-05-23  9:16   ` Markus Armbruster
2017-05-24  4:48   ` Philippe Mathieu-Daudé
2017-07-26  3:45 ` [Qemu-devel] [PATCH v5 0/4] Convert to realize and fix error handling Mao Zhongyi
2017-07-26  4:09   ` Jason Wang
2017-07-26  5:11     ` Mao Zhongyi

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=87wp97hqi4.fsf@dusky.pond.sub.org \
    --to=armbru@redhat.com \
    --cc=f4bug@amsat.org \
    --cc=jasowang@redhat.com \
    --cc=jiri@resnulli.us \
    --cc=maozy.fnst@cn.fujitsu.com \
    --cc=qemu-devel@nongnu.org \
    /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 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.