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é <[email protected]>
---
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;
--
2.26.2