[PATCH v3 10/25] system/memory: Have memory_region_size() take a const argument

Philippe Mathieu-Daudé posted 25 patches 2 weeks, 3 days ago
Maintainers: "Michael S. Tsirkin" <mst@redhat.com>, Igor Mammedov <imammedo@redhat.com>, Ani Sinha <anisinha@redhat.com>, Paolo Bonzini <pbonzini@redhat.com>, "Daniel P. Berrangé" <berrange@redhat.com>, Eduardo Habkost <eduardo@habkost.net>, Marcel Apfelbaum <marcel.apfelbaum@gmail.com>, Richard Henderson <richard.henderson@linaro.org>, Song Gao <gaosong@loongson.cn>, Bibo Mao <maobibo@loongson.cn>, Jiaxun Yang <jiaxun.yang@flygoat.com>, Keith Busch <kbusch@kernel.org>, Klaus Jensen <its@irrelevant.dk>, Jesper Devantier <foss@defmacro.it>, Bernhard Beschow <shentey@gmail.com>, Matthew Rosato <mjrosato@linux.ibm.com>, Eric Farman <farman@linux.ibm.com>, Thomas Huth <thuth@redhat.com>, David Hildenbrand <david@redhat.com>, Ilya Leoshkevich <iii@linux.ibm.com>, Halil Pasic <pasic@linux.ibm.com>, Christian Borntraeger <borntraeger@linux.ibm.com>, "Cédric Le Goater" <clg@kaod.org>, Peter Maydell <peter.maydell@linaro.org>, Steven Lee <steven_lee@aspeedtech.com>, Troy Lee <leetroy@gmail.com>, Jamin Lin <jamin_lin@aspeedtech.com>, Andrew Jeffery <andrew@codeconstruct.com.au>, Joel Stanley <joel@jms.id.au>, Peter Xu <peterx@redhat.com>, "Philippe Mathieu-Daudé" <philmd@linaro.org>, Fabiano Rosas <farosas@suse.de>
[PATCH v3 10/25] system/memory: Have memory_region_size() take a const argument
Posted by Philippe Mathieu-Daudé 2 weeks, 3 days ago
Since the @mr argument is not modified, it can be const.

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
 include/system/memory.h | 2 +-
 system/memory.c         | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/include/system/memory.h b/include/system/memory.h
index 3bd5ffa5e0d..45de6946812 100644
--- a/include/system/memory.h
+++ b/include/system/memory.h
@@ -1776,7 +1776,7 @@ Object *memory_region_owner(MemoryRegion *mr);
  *
  * @mr: the memory region being queried.
  */
-uint64_t memory_region_size(MemoryRegion *mr);
+uint64_t memory_region_size(const MemoryRegion *mr);
 
 /**
  * memory_region_is_ram: check whether a memory region is random access
diff --git a/system/memory.c b/system/memory.c
index 8b84661ae36..d1c060b2b50 100644
--- a/system/memory.c
+++ b/system/memory.c
@@ -1870,7 +1870,7 @@ void memory_region_unref(MemoryRegion *mr)
     }
 }
 
-uint64_t memory_region_size(MemoryRegion *mr)
+uint64_t memory_region_size(const MemoryRegion *mr)
 {
     if (int128_eq(mr->size, int128_2_64())) {
         return UINT64_MAX;
-- 
2.51.0


Re: [PATCH v3 10/25] system/memory: Have memory_region_size() take a const argument
Posted by David Hildenbrand 2 weeks, 2 days ago
On 28.10.25 19:12, Philippe Mathieu-Daudé wrote:
> Since the @mr argument is not modified, it can be const.
> 
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---

Reviewed-by: David Hildenbrand <david@redhat.com>

-- 
Cheers

David / dhildenb


Re: [PATCH v3 10/25] system/memory: Have memory_region_size() take a const argument
Posted by Richard Henderson 2 weeks, 2 days ago
On 10/28/25 19:12, Philippe Mathieu-Daudé wrote:
> Since the @mr argument is not modified, it can be const.
> 
> Signed-off-by: Philippe Mathieu-Daudé<philmd@linaro.org>
> ---
>   include/system/memory.h | 2 +-
>   system/memory.c         | 2 +-
>   2 files changed, 2 insertions(+), 2 deletions(-)

Reviewed-by: Richard Henderson <richard.henderson@linaro.org>

r~

Re: [PATCH v3 10/25] system/memory: Have memory_region_size() take a const argument
Posted by Thomas Huth 2 weeks, 2 days ago
On 28/10/2025 19.12, Philippe Mathieu-Daudé wrote:
> Since the @mr argument is not modified, it can be const.
> 
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---
>   include/system/memory.h | 2 +-
>   system/memory.c         | 2 +-
>   2 files changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/include/system/memory.h b/include/system/memory.h
> index 3bd5ffa5e0d..45de6946812 100644
> --- a/include/system/memory.h
> +++ b/include/system/memory.h
> @@ -1776,7 +1776,7 @@ Object *memory_region_owner(MemoryRegion *mr);
>    *
>    * @mr: the memory region being queried.
>    */
> -uint64_t memory_region_size(MemoryRegion *mr);
> +uint64_t memory_region_size(const MemoryRegion *mr);
>   
>   /**
>    * memory_region_is_ram: check whether a memory region is random access
> diff --git a/system/memory.c b/system/memory.c
> index 8b84661ae36..d1c060b2b50 100644
> --- a/system/memory.c
> +++ b/system/memory.c
> @@ -1870,7 +1870,7 @@ void memory_region_unref(MemoryRegion *mr)
>       }
>   }
>   
> -uint64_t memory_region_size(MemoryRegion *mr)
> +uint64_t memory_region_size(const MemoryRegion *mr)
>   {
>       if (int128_eq(mr->size, int128_2_64())) {
>           return UINT64_MAX;

Reviewed-by: Thomas Huth <thuth@redhat.com>


Re: [PATCH v3 10/25] system/memory: Have memory_region_size() take a const argument
Posted by Peter Xu 2 weeks, 2 days ago
On Tue, Oct 28, 2025 at 07:12:44PM +0100, Philippe Mathieu-Daudé wrote:
> Since the @mr argument is not modified, it can be const.
> 
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>

Acked-by: Peter Xu <peterx@redhat.com>

-- 
Peter Xu