qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


From: Philippe Mathieu-Daudé
Subject: [PATCH 3/3] memory: Make memory_region_to_absolute_addr() take a const MemoryRegion
Date: Sat, 6 Mar 2021 00:54:14 +0100

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;
-- 
2.26.2




reply via email to

[Prev in Thread] Current Thread [Next in Thread]