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: Eduardo Habkost <ehabkost@redhat.com>,
	mst@redhat.com, jasowang@redhat.com, qemu-devel@nongnu.org,
	marcel@redhat.com, alex.williamson@redhat.com, dmitry@daynix.com,
	pbonzini@redhat.com, rth@twiddle.net
Subject: Re: [Qemu-devel] [PATCH v3 5/7] pci: Make errp the last parameter of pci_add_capability()
Date: Wed, 07 Jun 2017 09:05:08 +0200	[thread overview]
Message-ID: <87a85k46sb.fsf@dusky.pond.sub.org> (raw)
In-Reply-To: <a6e6a698-ab28-b956-b13d-d75c9c203838@cn.fujitsu.com> (Mao Zhongyi's message of "Wed, 7 Jun 2017 13:33:51 +0800")

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

> Hi, Eduardo
>
> On 06/06/2017 10:52 PM, Eduardo Habkost wrote:
>> On Tue, Jun 06, 2017 at 07:26:30PM +0800, Mao Zhongyi wrote:
>>> Add Error argument for pci_add_capability() to leverage the errp
>>> to pass info on errors. This way is helpful for its callers to
>>> make a better error handling when moving to 'realize'.
[...]
>>> diff --git a/hw/pci/pci.c b/hw/pci/pci.c
>>> index b73bfea..2bba37a 100644
>>> --- a/hw/pci/pci.c
>>> +++ b/hw/pci/pci.c
>>> @@ -2264,15 +2264,13 @@ static void pci_del_option_rom(PCIDevice *pdev)
>>>   * in pci config space
>>>   */
>>>  int pci_add_capability(PCIDevice *pdev, uint8_t cap_id,
>>> -                       uint8_t offset, uint8_t size)
>>> +                       uint8_t offset, uint8_t size,
>>> +                       Error **errp)
>>>  {
>>>      int ret;
>>> -    Error *local_err = NULL;
>>>
>>> -    ret = pci_add_capability2(pdev, cap_id, offset, size, &local_err);
>>> -    if (ret < 0) {
>>> -        error_report_err(local_err);
>>> -    }
>>> +    ret = pci_add_capability2(pdev, cap_id, offset, size, errp);
>>> +
>>>      return ret;
>>>  }
>>
>> pci_add_capability() and pci_add_capability2() now do exactly the
>> same, why are both being kept?  I suggest replacing
>> pci_add_capability2() with pci_add_capability() everywhere (on a
>> separate patch).
>>
>
> Completely remove pci_add_capability and direct use pci_add_capability2()
> everywhere is it a more thorough way?

You're converting pci_add_capability() to Error because you need the
Error for your conversions to realize().

I recommend to change the calls where you need the Error (and only
these) to call pci_add_capability2() instead.

When no calls to pci_add_capability() remain, we remove it.  If that
becomes the case in your series, you remove it.

Okay?

  reply	other threads:[~2017-06-07  7:05 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-06-06 11:26 [Qemu-devel] [PATCH v3 0/7] Convert to realize and cleanup Mao Zhongyi
2017-06-06 11:26 ` [Qemu-devel] [PATCH v3 1/7] pci: Clean up error checking in pci_add_capability() Mao Zhongyi
2017-06-06 11:26 ` [Qemu-devel] [PATCH v3 2/7] pci: Add comment for pci_add_capability2() Mao Zhongyi
2017-06-06 11:26 ` [Qemu-devel] [PATCH v3 3/7] pci: Fix the return value checking Mao Zhongyi
2017-06-06 11:26 ` [Qemu-devel] [PATCH v3 4/7] net/eepro100: Fix code style Mao Zhongyi
2017-06-06 15:31   ` Michael S. Tsirkin
2017-06-07  2:43     ` Mao Zhongyi
2017-06-06 11:26 ` [Qemu-devel] [PATCH v3 5/7] pci: Make errp the last parameter of pci_add_capability() Mao Zhongyi
2017-06-06 14:52   ` Eduardo Habkost
2017-06-06 16:24     ` Markus Armbruster
2017-06-07  5:33     ` Mao Zhongyi
2017-06-07  7:05       ` Markus Armbruster [this message]
2017-06-07  9:33         ` Mao Zhongyi
2017-06-06 11:26 ` [Qemu-devel] [PATCH v3 6/7] pci: Convert to realize Mao Zhongyi
2017-06-06 11:26 ` [Qemu-devel] [PATCH v3 7/7] pci: Convert shpc_init() to Error 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=87a85k46sb.fsf@dusky.pond.sub.org \
    --to=armbru@redhat.com \
    --cc=alex.williamson@redhat.com \
    --cc=dmitry@daynix.com \
    --cc=ehabkost@redhat.com \
    --cc=jasowang@redhat.com \
    --cc=maozy.fnst@cn.fujitsu.com \
    --cc=marcel@redhat.com \
    --cc=mst@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=rth@twiddle.net \
    /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.