All of lore.kernel.org
 help / color / mirror / Atom feed
From: Markus Armbruster <armbru@redhat.com>
To: bibo mao <maobibo@loongson.cn>
Cc: Song Gao <gaosong@loongson.cn>,
	 Jiaxun Yang <jiaxun.yang@flygoat.com>,
	qemu-devel@nongnu.org,  Paolo Bonzini <pbonzini@redhat.com>
Subject: Re: [PATCH v4 2/4] hw/loongarch/virt: Remove unnecessary NULL pointer
Date: Wed, 19 Mar 2025 09:43:34 +0100	[thread overview]
Message-ID: <87bjtx1kcp.fsf@pond.sub.org> (raw)
In-Reply-To: <6b6b0792-04af-220d-8375-cef4b09b3ea9@loongson.cn> (bibo mao's message of "Wed, 19 Mar 2025 16:14:50 +0800")

bibo mao <maobibo@loongson.cn> writes:

On 2025/3/19 下午2:50, Markus Armbruster wrote:
>> Bibo Mao <maobibo@loongson.cn> writes:
>> 
>>> There is NULL pointer checking function error_propagate() already,
>>> it is not necessary to add checking for function parameter. Here remove
>>> NULL pointer checking with function parameter.
>> 
>> I believe the title "Remove unnecessary NULL pointer" and this paragraph
>> are remnants of your initial version, which transformed
>> 
>>      if (err) {
>>          error_propagate(errp, err);
>>      }
>> 
>> to just
>> 
>>      error_propagate(errp, err);
>> 
>> However, the patch doesn't do that anymore.
>> 
>> I think you should drop the paragraph, and replace the title.
>
> yes, the title is misleading. Originally the problem is found with 
> script scripts/coccinelle/remove_local_err.cocci, so here is the title.
>
> How about "Remove local error object" or something else. Could you 
> please provide some suggestions since English is your mother language?

My first language is German, but I've practiced writing English commit
messages for a while :)

Here's what I've used for similar patches before, adapted to this one:

    hw/loongarch/virt: Eliminate error_propagate()
    
    When all we do with an Error we receive into a local variable is
    propagating to somewhere else, we can just as well receive it there
    right away.


>> I apologize for not noticing this earlier.
>
> It is not necessary for the apologize. I appreciate your review 
> comments. With effective communication, the quality of code is better.

Thank you!

>>> Since function will return directly when there is error report, this
>>> patch removes combination about error_setg() and error_propagate(),
>>> error_setg() with dest error object is used directly such as:
>>>
>>>    error_setg(err);                 -------->      error_setg(errp);
>>>    error_propagate(errp, err);                     return;
>>>    return;
>> 
>> Yes, much of the patch does this or equivalent transformations.
>> However, there's more; see [*] below.
>> 
>>> Signed-off-by: Bibo Mao <maobibo@loongson.cn>
>>> ---
>>>   hw/loongarch/virt.c | 33 ++++++++++++---------------------
>>>   1 file changed, 12 insertions(+), 21 deletions(-)
>>>
>>> diff --git a/hw/loongarch/virt.c b/hw/loongarch/virt.c
>>> index a5840ff968..a9fab39dd8 100644
>>> --- a/hw/loongarch/virt.c
>>> +++ b/hw/loongarch/virt.c

[...]

>>> @@ -1003,6 +993,7 @@ static void virt_cpu_plug(HotplugHandler *hotplug_dev,
>>>          hotplug_handler_plug(HOTPLUG_HANDLER(lvms->acpi_ged), dev, &err);
>>>          if (err) {
>>>              error_propagate(errp, err);
>>> +            return;
>>>          }
>>>      }
>> 
>>       cpu_slot = virt_find_cpu_slot(MACHINE(lvms), cpu->phy_id);
>>       cpu_slot->cpu = NULL;
>>       return;
>>   }
>> 
>> [*] This is something else.  Before the patch, we clear cpu_slot->cpu
>> evem when the last hotplug_handler() fails.  Afterwards, we don't.
>> Looks like a bug fix to me.  Either mention the fix in the commit
>> message, or split it off into a separate patch.  I'd do the latter.
>> 
> yes, will split it into two patches. The latter is bugfix, when cpu 
> fails to unplug and it should return immediately, so that system can 
> continue to run , and cpu_slot->cpu should not be cleared.

Thanks again!



  reply	other threads:[~2025-03-19  8:44 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-03-19  2:08 [PATCH v4 0/4] target/loongarch: Solve some issues reported from coccinelle Bibo Mao
2025-03-19  2:08 ` [PATCH v4 1/4] target/loongarch: Fix error handling of KVM feature checks Bibo Mao
2025-03-19  2:08 ` [PATCH v4 2/4] hw/loongarch/virt: Remove unnecessary NULL pointer Bibo Mao
2025-03-19  6:50   ` Markus Armbruster
2025-03-19  8:14     ` bibo mao
2025-03-19  8:43       ` Markus Armbruster [this message]
2025-03-19  2:08 ` [PATCH v4 3/4] target/loongarch: Remove unnecessary temporary variable assignment Bibo Mao
2025-03-19  2:08 ` [PATCH v4 4/4] target/loongarch: Set dest error with error_abort in virt_cpu_irq_init Bibo Mao
2025-03-19  6:09   ` Markus Armbruster
2025-03-19  7:58     ` bibo mao
2025-03-19  8:52       ` Markus Armbruster

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=87bjtx1kcp.fsf@pond.sub.org \
    --to=armbru@redhat.com \
    --cc=gaosong@loongson.cn \
    --cc=jiaxun.yang@flygoat.com \
    --cc=maobibo@loongson.cn \
    --cc=pbonzini@redhat.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.