[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH 1/1] util: Make some iova_tree parameters const
From: |
Eugenio Perez Martin |
Subject: |
Re: [PATCH 1/1] util: Make some iova_tree parameters const |
Date: |
Wed, 13 Oct 2021 20:26:01 +0200 |
On Wed, Oct 13, 2021 at 12:21 AM Philippe Mathieu-Daudé
<philmd@redhat.com> wrote:
>
> 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>
>
Right! Sending v2.
Thanks!