All of lore.kernel.org
 help / color / mirror / Atom feed
From: BALATON Zoltan <balaton@eik.bme.hu>
To: Akihiko Odaki <odaki@rsg.ci.i.u-tokyo.ac.jp>
Cc: qemu-devel@nongnu.org, "Peter Xu" <peterx@redhat.com>,
	"Paolo Bonzini" <pbonzini@redhat.com>,
	"Mark Cave-Ayland" <mark.cave-ayland@ilande.co.uk>,
	"Gerd Hoffmann" <kraxel@redhat.com>,
	"Max Filippov" <jcmvbkbc@gmail.com>,
	"Peter Maydell" <peter.maydell@linaro.org>,
	"Philippe Mathieu-Daudé" <philmd@linaro.org>
Subject: Re: [PATCH v6 5/8] memory: Factor out common ram region initialization
Date: Wed, 4 Mar 2026 12:38:33 +0100 (CET)	[thread overview]
Message-ID: <4b9a2efc-905a-335d-940b-a2d89e330689@eik.bme.hu> (raw)
In-Reply-To: <3fd2bad5-5df3-463d-a12b-c3a61ca1c4ab@rsg.ci.i.u-tokyo.ac.jp>

On Wed, 4 Mar 2026, Akihiko Odaki wrote:
> On 2026/03/04 6:47, BALATON Zoltan wrote:
>> Introduce internal helper functions to remove duplicated code from
>> different memory_region_init_*ram functions.
>> 
>> Signed-off-by: BALATON Zoltan <balaton@eik.bme.hu>
>> ---
>>   system/memory.c | 132 ++++++++++++++++++------------------------------
>>   1 file changed, 50 insertions(+), 82 deletions(-)
>> 
>> diff --git a/system/memory.c b/system/memory.c
>> index e8c4912a60..1b26c6b5a5 100644
>> --- a/system/memory.c
>> +++ b/system/memory.c
>> @@ -1589,19 +1589,16 @@ bool memory_region_init_ram_nomigrate(MemoryRegion 
>> *mr,
>>                                                     size, 0, errp);
>>   }
>>   -bool memory_region_init_ram_flags_nomigrate(MemoryRegion *mr,
>> -                                            Object *owner,
>> -                                            const char *name,
>> -                                            uint64_t size,
>> -                                            uint32_t ram_flags,
>> -                                            Error **errp)
>> +static void memory_region_setup_ram(MemoryRegion *mr)
>>   {
>> -    Error *err = NULL;
>> -    memory_region_init(mr, owner, name, size);
>>       mr->ram = true;
>>       mr->terminates = true;
>>       mr->destructor = memory_region_destructor_ram;
>> -    mr->ram_block = qemu_ram_alloc(size, ram_flags, mr, &err);
>> +}
>> +
>> +static bool memory_region_error_propagate(MemoryRegion *mr,
>> +                                          Error *err, Error **errp)
>> +{
>>       if (err) {
>>           mr->size = int128_zero();
>>           object_unparent(OBJECT(mr));
>> @@ -1611,6 +1608,18 @@ bool 
>> memory_region_init_ram_flags_nomigrate(MemoryRegion *mr,
>>       return true;
>>   }
>
> I think the optimal way to factor out error propagation is to use 
> ERRP_GUARD().

I don't think ERRP_GUARD applies here as we do not dereference errp and 
this does more than just propagate the error so I don't see how ERRP_GUARD 
could help here.

Regards,
BALATON Zoltan


  reply	other threads:[~2026-03-04 11:39 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-03 21:47 [PATCH v6 0/8] memory: Remove most _nomigrate variants BALATON Zoltan
2026-03-03 21:47 ` [PATCH v6 1/8] hw/display/{cg3.tcx}: Do not use memory_region_init_rom_nomigrate() BALATON Zoltan
2026-03-03 21:47 ` [PATCH v6 2/8] memory: Remove memory_region_init_rom_nomigrate() BALATON Zoltan
2026-03-03 21:47 ` [PATCH v6 3/8] sun4m,sun4u,tcx: Do not use memory_region_init_ram_nomigrate() BALATON Zoltan
2026-03-03 21:47 ` [PATCH v6 4/8] system/memory: Reduce memory_region_init_ram_nomigrate() usage BALATON Zoltan
2026-03-03 21:47 ` [PATCH v6 5/8] memory: Factor out common ram region initialization BALATON Zoltan
2026-03-04  5:46   ` Akihiko Odaki
2026-03-04 11:38     ` BALATON Zoltan [this message]
2026-03-05  1:57       ` Akihiko Odaki
2026-03-05 16:56         ` Peter Xu
2026-03-03 21:47 ` [PATCH v6 6/8] memory: Add internal memory_region_register_ram function BALATON Zoltan
2026-03-03 21:47 ` [PATCH v6 7/8] memory: Shorten memory_region_init_ram_device_ptr and memory_region_init_rom_device BALATON Zoltan
2026-03-03 21:47 ` [PATCH v6 8/8] memory: Factor out more common ram region initialization BALATON Zoltan
2026-03-04 19:06 ` [PATCH v6 0/8] memory: Remove most _nomigrate variants Peter Xu
2026-03-04 23:39   ` BALATON Zoltan

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=4b9a2efc-905a-335d-940b-a2d89e330689@eik.bme.hu \
    --to=balaton@eik.bme.hu \
    --cc=jcmvbkbc@gmail.com \
    --cc=kraxel@redhat.com \
    --cc=mark.cave-ayland@ilande.co.uk \
    --cc=odaki@rsg.ci.i.u-tokyo.ac.jp \
    --cc=pbonzini@redhat.com \
    --cc=peter.maydell@linaro.org \
    --cc=peterx@redhat.com \
    --cc=philmd@linaro.org \
    --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.