QEMU-Devel Archive on lore.kernel.org
 help / color / Atom feed
From: "Zeng, Star" <star.zeng@intel.com>
To: Wei Yang <richardw.yang@linux.intel.com>,
	David Hildenbrand <david@redhat.com>
Cc: "imammedo@redhat.com" <imammedo@redhat.com>,
	"qemu-devel@nongnu.org" <qemu-devel@nongnu.org>,
	"Zeng, Star" <star.zeng@intel.com>,
	"mst@redhat.com" <mst@redhat.com>
Subject: Re: [Qemu-devel] [PATCH v2 1/2] memory-device: not necessary to use goto for the last check
Date: Mon, 19 Aug 2019 05:32:14 +0000
Message-ID: <0C09AFA07DD0434D9E2A0C6AEB0483104039E3A1@shsmsx102.ccr.corp.intel.com> (raw)
In-Reply-To: <20190819023855.GC6368@richard>



> -----Original Message-----
> From: Wei Yang [mailto:richardw.yang@linux.intel.com]
> Sent: Monday, August 19, 2019 10:39 AM
> To: David Hildenbrand <david@redhat.com>
> Cc: Wei Yang <richardw.yang@linux.intel.com>; Zeng, Star
> <star.zeng@intel.com>; imammedo@redhat.com; qemu-devel@nongnu.org;
> mst@redhat.com
> Subject: Re: [Qemu-devel] [PATCH v2 1/2] memory-device: not necessary to
> use goto for the last check
> 
> On Thu, Aug 08, 2019 at 09:06:21AM +0200, David Hildenbrand wrote:
> >On 08.08.19 04:38, Wei Yang wrote:
> >> On Thu, Aug 08, 2019 at 02:30:02AM +0000, Zeng, Star wrote:
> >>>> -----Original Message-----
> >>>> From: Wei Yang [mailto:richardw.yang@linux.intel.com]
> >>>> Sent: Thursday, August 8, 2019 10:13 AM
> >>>> To: Zeng, Star <star.zeng@intel.com>
> >>>> Cc: Wei Yang <richardw.yang@linux.intel.com>;
> >>>> qemu-devel@nongnu.org; imammedo@redhat.com;
> david@redhat.com;
> >>>> mst@redhat.com
> >>>> Subject: Re: [Qemu-devel] [PATCH v2 1/2] memory-device: not
> >>>> necessary to use goto for the last check
> >>>>
> >>>> On Thu, Aug 08, 2019 at 01:42:14AM +0000, Zeng, Star wrote:
> >>>>>> -----Original Message-----
> >>>>>> From: Qemu-devel [mailto:qemu-devel-
> >>>>>> bounces+star.zeng=intel.com@nongnu.org] On Behalf Of Wei Yang
> >>>>>> Sent: Tuesday, July 30, 2019 8:38 AM
> >>>>>> To: qemu-devel@nongnu.org
> >>>>>> Cc: imammedo@redhat.com; david@redhat.com; Wei Yang
> >>>>>> <richardw.yang@linux.intel.com>; mst@redhat.com
> >>>>>> Subject: [Qemu-devel] [PATCH v2 1/2] memory-device: not
> necessary
> >>>>>> to use goto for the last check
> >>>>>>
> >>>>>> We are already at the last condition check.
> >>>>>>
> >>>>>> Signed-off-by: Wei Yang <richardw.yang@linux.intel.com>
> >>>>>> Reviewed-by: Igor Mammedov <imammedo@redhat.com>
> >>>>>> Reviewed-by: David Hildenbrand <david@redhat.com>
> >>>>>> ---
> >>>>>>  hw/mem/memory-device.c | 1 -
> >>>>>>  1 file changed, 1 deletion(-)
> >>>>>>
> >>>>>> diff --git a/hw/mem/memory-device.c b/hw/mem/memory-
> device.c
> >>>> index
> >>>>>> 5f2c408036..df3261b32a 100644
> >>>>>> --- a/hw/mem/memory-device.c
> >>>>>> +++ b/hw/mem/memory-device.c
> >>>>>> @@ -186,7 +186,6 @@ static uint64_t
> >>>>>> memory_device_get_free_addr(MachineState *ms,
> >>>>>>      if (!range_contains_range(&as, &new)) {
> >>>>>>          error_setg(errp, "could not find position in guest address space
> for "
> >>>>>>                     "memory device - memory fragmented due to
> alignments");
> >>>>>> -        goto out;
> >>>>>
> >>>>> Is it better to return 0 (or set new_addr to 0) for this error
> >>>>> path and another
> >>>> remaining "goto out" path?
> >>>>>
> >>>>
> >>>> I may not get your point.
> >>>>
> >>>> We set errp which is handled in its caller. By doing so, the error is
> propagated.
> >>>>
> >>>> Do I miss something?
> >>>
> >>> Yes, you are right. Currently, the caller is checking errp, but not the
> returned address, so there should be no issue.
> >>> But when you see other error paths, you will find they all return 0.
> >>> To be aligned (return 0 when error), so just suggest also returning
> >>> 0 for these two "goto out" error path. :)
> >>>
> >>
> >> You may have some point.
> >>
> >> Let's see whether others have the same taste, or we can refine it
> separately.
> >>
> >
> >I don't think that's necessary (callers really should check for errors
> >before using the return values), but I would also not object to that change.
> >
> 
> In case there is no strong requirement to refactor the code. I would leave it
> here.

It was just my suggestion. I am fine with any preference you and other experts have.

Thanks,
Star

> 
> >--
> >
> >Thanks,
> >
> >David / dhildenb
> 
> --
> Wei Yang
> Help you, Help me


  reply index

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-07-30  0:37 [Qemu-devel] [PATCH v2 0/2] refine memory_device_get_free_addr Wei Yang
2019-07-30  0:37 ` [Qemu-devel] [PATCH v2 1/2] memory-device: not necessary to use goto for the last check Wei Yang
2019-08-08  1:42   ` Zeng, Star
2019-08-08  2:13     ` Wei Yang
2019-08-08  2:30       ` Zeng, Star
2019-08-08  2:38         ` Wei Yang
2019-08-08  7:06           ` David Hildenbrand
2019-08-19  2:38             ` Wei Yang
2019-08-19  5:32               ` Zeng, Star [this message]
2019-08-19  6:36                 ` Wei Yang
2019-07-30  0:37 ` [Qemu-devel] [PATCH v2 2/2] memory-device: break the loop if tmp exceed the hinted range Wei Yang
2019-07-30  7:38   ` David Hildenbrand
2019-07-30  9:30   ` Igor Mammedov
2019-09-13 23:47 ` [Qemu-devel] [PATCH v2 0/2] refine memory_device_get_free_addr Wei Yang
2019-09-14 19:40   ` Michael S. Tsirkin
2019-10-12  9:02     ` Wei Yang
2019-10-14 15:05       ` Eduardo Habkost
2019-10-14 22:00         ` Wei Yang

Reply instructions:

You may reply publically 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=0C09AFA07DD0434D9E2A0C6AEB0483104039E3A1@shsmsx102.ccr.corp.intel.com \
    --to=star.zeng@intel.com \
    --cc=david@redhat.com \
    --cc=imammedo@redhat.com \
    --cc=mst@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=richardw.yang@linux.intel.com \
    /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

QEMU-Devel Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/qemu-devel/0 qemu-devel/git/0.git
	git clone --mirror https://lore.kernel.org/qemu-devel/1 qemu-devel/git/1.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 qemu-devel qemu-devel/ https://lore.kernel.org/qemu-devel \
		qemu-devel@nongnu.org qemu-devel@archiver.kernel.org
	public-inbox-index qemu-devel

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.nongnu.qemu-devel


AGPL code for this site: git clone https://public-inbox.org/ public-inbox