qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH v5 1/4] net/rocker: Remove the dead error handli


From: Markus Armbruster
Subject: Re: [Qemu-devel] [PATCH v5 1/4] net/rocker: Remove the dead error handling
Date: Tue, 23 May 2017 12:52:45 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/25.2 (gnu/linux)

Mao Zhongyi <address@hidden> writes:

> Hi, Markus
>
>
> On 05/23/2017 05:27 PM, Markus Armbruster wrote:
>> Mao Zhongyi <address@hidden> 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
>
> Will I need to make a separated patch to fix it? or when you merge to
> help me repair?

Perhaps Jason can touch it up on commit.

> Thanks a lot.
>
>>
>>> 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 <address@hidden>
>>
>> Reviewed-by: Markus Armbruster <address@hidden>
>
> Thanks for your quick review:)

You're welcome.

>> 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.
>
> Thanks for the reminder. I just read the code, it's true.
> Will fix it right away.

Thanks!



reply via email to

[Prev in Thread] Current Thread [Next in Thread]