[PATCH 02/35] hw/core/loader: Use address_space_get_path()

Akihiko Odaki posted 35 patches 1 month, 4 weeks ago
[PATCH 02/35] hw/core/loader: Use address_space_get_path()
Posted by Akihiko Odaki 1 month, 4 weeks ago
The name field of an QOM-ified AddressSpace represents a property name,
which may not be sufficient to identify the AddressSpace. Use
address_space_get_path() instead.

Signed-off-by: Akihiko Odaki <odaki@rsg.ci.i.u-tokyo.ac.jp>
---
 hw/core/loader.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/hw/core/loader.c b/hw/core/loader.c
index 524af6f14a09..1ee603f19c90 100644
--- a/hw/core/loader.c
+++ b/hw/core/loader.c
@@ -1258,10 +1258,10 @@ static bool roms_overlap(Rom *last_rom, Rom *this_rom)
         last_rom->addr + last_rom->romsize > this_rom->addr;
 }
 
-static const char *rom_as_name(Rom *rom)
+static const char *rom_as_path(Rom *rom)
 {
-    const char *name = rom->as ? rom->as->name : NULL;
-    return name ?: "anonymous";
+    const char *path = rom->as ? address_space_get_path(rom->as) : NULL;
+    return path ?: "anonymous";
 }
 
 static void rom_print_overlap_error_header(void)
@@ -1280,7 +1280,7 @@ static void rom_print_one_overlap_error(Rom *last_rom, Rom *rom)
 {
     error_printf(
         "\nThe following two regions overlap (in the %s address space):\n",
-        rom_as_name(rom));
+        rom_as_path(rom));
     error_printf(
         "  %s (addresses 0x" HWADDR_FMT_plx " - 0x" HWADDR_FMT_plx ")\n",
         last_rom->name, last_rom->addr, last_rom->addr + last_rom->romsize);

-- 
2.51.0
Re: [PATCH 02/35] hw/core/loader: Use address_space_get_path()
Posted by Richard Henderson 1 month, 4 weeks ago
On 9/17/25 05:56, Akihiko Odaki wrote:
> The name field of an QOM-ified AddressSpace represents a property name,
> which may not be sufficient to identify the AddressSpace. Use
> address_space_get_path() instead.
> 
> Signed-off-by: Akihiko Odaki <odaki@rsg.ci.i.u-tokyo.ac.jp>
> ---
>   hw/core/loader.c | 8 ++++----
>   1 file changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/hw/core/loader.c b/hw/core/loader.c
> index 524af6f14a09..1ee603f19c90 100644
> --- a/hw/core/loader.c
> +++ b/hw/core/loader.c
> @@ -1258,10 +1258,10 @@ static bool roms_overlap(Rom *last_rom, Rom *this_rom)
>           last_rom->addr + last_rom->romsize > this_rom->addr;
>   }
>   
> -static const char *rom_as_name(Rom *rom)
> +static const char *rom_as_path(Rom *rom)
>   {
> -    const char *name = rom->as ? rom->as->name : NULL;
> -    return name ?: "anonymous";
> +    const char *path = rom->as ? address_space_get_path(rom->as) : NULL;
> +    return path ?: "anonymous";
>   }

You're not freeing the result of address_space_get_path.


r~

>   
>   static void rom_print_overlap_error_header(void)
> @@ -1280,7 +1280,7 @@ static void rom_print_one_overlap_error(Rom *last_rom, Rom *rom)
>   {
>       error_printf(
>           "\nThe following two regions overlap (in the %s address space):\n",
> -        rom_as_name(rom));
> +        rom_as_path(rom));
>       error_printf(
>           "  %s (addresses 0x" HWADDR_FMT_plx " - 0x" HWADDR_FMT_plx ")\n",
>           last_rom->name, last_rom->addr, last_rom->addr + last_rom->romsize);
>
Re: [PATCH 02/35] hw/core/loader: Use address_space_get_path()
Posted by Richard Henderson 1 month, 4 weeks ago
On 9/17/25 08:18, Richard Henderson wrote:
> On 9/17/25 05:56, Akihiko Odaki wrote:
>> The name field of an QOM-ified AddressSpace represents a property name,
>> which may not be sufficient to identify the AddressSpace. Use
>> address_space_get_path() instead.
>>
>> Signed-off-by: Akihiko Odaki <odaki@rsg.ci.i.u-tokyo.ac.jp>
>> ---
>>   hw/core/loader.c | 8 ++++----
>>   1 file changed, 4 insertions(+), 4 deletions(-)
>>
>> diff --git a/hw/core/loader.c b/hw/core/loader.c
>> index 524af6f14a09..1ee603f19c90 100644
>> --- a/hw/core/loader.c
>> +++ b/hw/core/loader.c
>> @@ -1258,10 +1258,10 @@ static bool roms_overlap(Rom *last_rom, Rom *this_rom)
>>           last_rom->addr + last_rom->romsize > this_rom->addr;
>>   }
>> -static const char *rom_as_name(Rom *rom)
>> +static const char *rom_as_path(Rom *rom)
>>   {
>> -    const char *name = rom->as ? rom->as->name : NULL;
>> -    return name ?: "anonymous";
>> +    const char *path = rom->as ? address_space_get_path(rom->as) : NULL;
>> +    return path ?: "anonymous";
>>   }
> 
> You're not freeing the result of address_space_get_path.

In addition, I think the result of address_space_get_path cannot be null, so,

   if (rom->as) {
     return address_space_get_path(rom->as);
   }
   return g_strdup("anonymous");

r~