mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-04 00:03:54 -06:00
util: Make some iova_tree parameters const
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> Acked-by: Peter Xu <peterx@redhat.com> Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> Message-Id: <20211013182713.888753-2-eperezma@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
This commit is contained in:
parent
9840999112
commit
a89b34be5e
3 changed files with 11 additions and 11 deletions
|
@ -42,14 +42,14 @@ IOVATree *iova_tree_new(void)
|
|||
return iova_tree;
|
||||
}
|
||||
|
||||
DMAMap *iova_tree_find(IOVATree *tree, DMAMap *map)
|
||||
const DMAMap *iova_tree_find(const IOVATree *tree, const DMAMap *map)
|
||||
{
|
||||
return g_tree_lookup(tree->tree, map);
|
||||
}
|
||||
|
||||
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 };
|
||||
const DMAMap map = { .iova = iova, .size = 0 };
|
||||
|
||||
return iova_tree_find(tree, &map);
|
||||
}
|
||||
|
@ -60,7 +60,7 @@ static inline void iova_tree_insert_internal(GTree *gtree, DMAMap *range)
|
|||
g_tree_insert(gtree, range, range);
|
||||
}
|
||||
|
||||
int iova_tree_insert(IOVATree *tree, DMAMap *map)
|
||||
int iova_tree_insert(IOVATree *tree, const DMAMap *map)
|
||||
{
|
||||
DMAMap *new;
|
||||
|
||||
|
@ -96,9 +96,9 @@ void iova_tree_foreach(IOVATree *tree, iova_tree_iterator iterator)
|
|||
g_tree_foreach(tree->tree, iova_tree_traverse, iterator);
|
||||
}
|
||||
|
||||
int iova_tree_remove(IOVATree *tree, DMAMap *map)
|
||||
int iova_tree_remove(IOVATree *tree, const DMAMap *map)
|
||||
{
|
||||
DMAMap *overlap;
|
||||
const DMAMap *overlap;
|
||||
|
||||
while ((overlap = iova_tree_find(tree, map))) {
|
||||
g_tree_remove(tree->tree, overlap);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue