Mao Zhongyi <maozy.f...@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.f...@cn.fujitsu.com> Reviewed-by: Markus Armbruster <arm...@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. [...]