qemu-devel
[Top][All Lists]
Advanced

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

Re: [PATCH 3/3] memory: Make memory_region_to_absolute_addr() take a con


From: Philippe Mathieu-Daudé
Subject: Re: [PATCH 3/3] memory: Make memory_region_to_absolute_addr() take a const MemoryRegion
Date: Thu, 11 Mar 2021 13:19:34 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.7.0

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



reply via email to

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