diff mbox series

[3/3] memory: Make memory_region_to_absolute_addr() take a const MemoryRegion

Message ID 20210305235414.2358144-4-f4bug@amsat.org
State New
Headers show
Series [1/3] memory: Better name 'offset' argument in mtree_print_mr() | expand

Commit Message

Philippe Mathieu-Daudé March 5, 2021, 11:54 p.m. UTC
There is no reason to not have memory_region_to_absolute_addr()
work with a const MemoryRegion. Else we get:

softmmu/memory.c: error: passing argument 1 of ‘memory_region_to_absolute_addr’ discards ‘const’ qualifier from pointer target type [-Werror=discarded-qualifiers]
 6666 |     myaddr = memory_region_to_absolute_addr(constmr, addr);
      |                                             ^~
softmmu/memory.c:410:60: note: expected ‘MemoryRegion *’ but argument is of type ‘const MemoryRegion *’
  410 | static hwaddr memory_region_to_absolute_addr(MemoryRegion *mr, hwaddr offset)
      |                                              ~~~~~~~~~~~~~~^~

Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
 softmmu/memory.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

Comments

Philippe Mathieu-Daudé March 11, 2021, 12:19 p.m. UTC | #1
Cc'ing qemu-trivial@ for this single patch.

On 3/6/21 12:54 AM, Philippe Mathieu-Daudé wrote:
> There is no reason to not have memory_region_to_absolute_addr()
> work with a const MemoryRegion. Else we get:
> 
> softmmu/memory.c: error: passing argument 1 of ‘memory_region_to_absolute_addr’ discards ‘const’ qualifier from pointer target type [-Werror=discarded-qualifiers]
>  6666 |     myaddr = memory_region_to_absolute_addr(constmr, addr);
>       |                                             ^~
> softmmu/memory.c:410:60: note: expected ‘MemoryRegion *’ but argument is of type ‘const MemoryRegion *’
>   410 | static hwaddr memory_region_to_absolute_addr(MemoryRegion *mr, hwaddr offset)
>       |                                              ~~~~~~~~~~~~~~^~
> 
> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
> ---
>  softmmu/memory.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/softmmu/memory.c b/softmmu/memory.c
> index 991d9227a88..6d1e96ba37d 100644
> --- a/softmmu/memory.c
> +++ b/softmmu/memory.c
> @@ -407,9 +407,10 @@ static inline uint64_t memory_region_shift_write_access(uint64_t *value,
>      return tmp;
>  }
>  
> -static hwaddr memory_region_to_absolute_addr(MemoryRegion *mr, hwaddr offset)
> +static hwaddr memory_region_to_absolute_addr(const MemoryRegion *mr,
> +                                             hwaddr offset)
>  {
> -    MemoryRegion *root;
> +    const MemoryRegion *root;
>      hwaddr abs_addr = offset;
>  
>      abs_addr += mr->addr;
>
diff mbox series

Patch

diff --git a/softmmu/memory.c b/softmmu/memory.c
index 991d9227a88..6d1e96ba37d 100644
--- a/softmmu/memory.c
+++ b/softmmu/memory.c
@@ -407,9 +407,10 @@  static inline uint64_t memory_region_shift_write_access(uint64_t *value,
     return tmp;
 }
 
-static hwaddr memory_region_to_absolute_addr(MemoryRegion *mr, hwaddr offset)
+static hwaddr memory_region_to_absolute_addr(const MemoryRegion *mr,
+                                             hwaddr offset)
 {
-    MemoryRegion *root;
+    const MemoryRegion *root;
     hwaddr abs_addr = offset;
 
     abs_addr += mr->addr;