[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH 1/1] util: Make some iova_tree parameters const
From: |
Philippe Mathieu-Daudé |
Subject: |
Re: [PATCH 1/1] util: Make some iova_tree parameters const |
Date: |
Wed, 13 Oct 2021 00:21:25 +0200 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.1.0 |
On 10/12/21 17:50, Eugenio Pérez wrote:
> As qemu guidelines:
> Unless a pointer is used to modify the pointed-to storage, give it the
> "const" attribute.
>
> In the particular case of iova_tree_find it allows to enforce what is
> requested by its comment, since the compiler would shout in case of
> modifying or freeing the const-qualified returned pointer.
>
> Signed-off-by: Eugenio Pérez <eperezma@redhat.com>
> ---
> include/qemu/iova-tree.h | 8 ++++----
> hw/i386/intel_iommu.c | 2 +-
> util/iova-tree.c | 10 +++++-----
> 3 files changed, 10 insertions(+), 10 deletions(-)
> -DMAMap *iova_tree_find_address(IOVATree *tree, hwaddr iova)
> +const DMAMap *iova_tree_find_address(const IOVATree *tree, hwaddr iova)
> {
> DMAMap map = { .iova = iova, .size = 0 };
You missed this one ^
With it declared const:
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>