[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v2 11/12] qht: constify arguments to some internal f
From: |
Emilio G. Cota |
Subject: |
[Qemu-devel] [PATCH v2 11/12] qht: constify arguments to some internal functions |
Date: |
Mon, 10 Sep 2018 14:58:58 -0400 |
These functions do not modify their @ht or @bucket arguments.
Constify those arguments.
Signed-off-by: Emilio G. Cota <address@hidden>
---
util/qht.c | 16 ++++++++++------
1 file changed, 10 insertions(+), 6 deletions(-)
diff --git a/util/qht.c b/util/qht.c
index 4378775d68..aa51be3c52 100644
--- a/util/qht.c
+++ b/util/qht.c
@@ -268,7 +268,8 @@ static void qht_map_unlock_buckets(struct qht_map *map)
* Call with at least a bucket lock held.
* @map should be the value read before acquiring the lock (or locks).
*/
-static inline bool qht_map_is_stale__locked(struct qht *ht, struct qht_map
*map)
+static inline bool qht_map_is_stale__locked(const struct qht *ht,
+ const struct qht_map *map)
{
return map != ht->map;
}
@@ -337,12 +338,12 @@ struct qht_bucket *qht_bucket_lock__no_stale(struct qht
*ht, uint32_t hash,
return b;
}
-static inline bool qht_map_needs_resize(struct qht_map *map)
+static inline bool qht_map_needs_resize(const struct qht_map *map)
{
return atomic_read(&map->n_added_buckets) > map->n_added_buckets_threshold;
}
-static inline void qht_chain_destroy(struct qht_bucket *head)
+static inline void qht_chain_destroy(const struct qht_bucket *head)
{
struct qht_bucket *curr = head->next;
struct qht_bucket *prev;
@@ -550,8 +551,11 @@ void *qht_lookup(const struct qht *ht, const void *userp,
uint32_t hash)
return qht_lookup_custom(ht, userp, hash, ht->cmp);
}
-/* call with head->lock held */
-static void *qht_insert__locked(struct qht *ht, struct qht_map *map,
+/*
+ * call with head->lock held
+ * @ht is const since it is only used for ht->cmp()
+ */
+static void *qht_insert__locked(const struct qht *ht, struct qht_map *map,
struct qht_bucket *head, void *p, uint32_t
hash,
bool *needs_resize)
{
@@ -645,7 +649,7 @@ bool qht_insert(struct qht *ht, void *p, uint32_t hash,
void **existing)
return false;
}
-static inline bool qht_entry_is_last(struct qht_bucket *b, int pos)
+static inline bool qht_entry_is_last(const struct qht_bucket *b, int pos)
{
if (pos == QHT_BUCKET_ENTRIES - 1) {
if (b->next == NULL) {
--
2.17.1
- [Qemu-devel] [PATCH v2 00/12] qht improvements for 3.1, Emilio G. Cota, 2018/09/10
- [Qemu-devel] [PATCH v2 02/12] qht: add qht_iter_remove, Emilio G. Cota, 2018/09/10
- [Qemu-devel] [PATCH v2 01/12] qht: remove unused map param from qht_remove__locked, Emilio G. Cota, 2018/09/10
- [Qemu-devel] [PATCH v2 08/12] qht: fix comment in qht_bucket_remove_entry, Emilio G. Cota, 2018/09/10
- [Qemu-devel] [PATCH v2 10/12] qht: constify qht_statistics_init, Emilio G. Cota, 2018/09/10
- [Qemu-devel] [PATCH v2 04/12] test-qht: test removal of non-existent entries, Emilio G. Cota, 2018/09/10
- [Qemu-devel] [PATCH v2 11/12] qht: constify arguments to some internal functions,
Emilio G. Cota <=
- [Qemu-devel] [PATCH v2 03/12] test-qht: test qht_iter_remove, Emilio G. Cota, 2018/09/10
- [Qemu-devel] [PATCH v2 09/12] qht: constify qht_lookup, Emilio G. Cota, 2018/09/10
- [Qemu-devel] [PATCH v2 05/12] test-qht: test deletion of the last entry in a bucket, Emilio G. Cota, 2018/09/10
- [Qemu-devel] [PATCH v2 06/12] test-qht: speed up + test qht_resize, Emilio G. Cota, 2018/09/10
- [Qemu-devel] [PATCH v2 07/12] qht: drop ht argument from qht iterators, Emilio G. Cota, 2018/09/10
- [Qemu-devel] [PATCH v2 12/12] qht-bench: add -p flag to precompute hash values, Emilio G. Cota, 2018/09/10
- Re: [Qemu-devel] [PATCH v2 00/12] qht improvements for 3.1, Richard Henderson, 2018/09/12