summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPatrick Steinhardt <ps@pks.im>2017-01-27 14:05:10 +0100
committerPatrick Steinhardt <ps@pks.im>2017-02-17 11:41:06 +0100
commit85d2748c6f75bd810c7376647c8ae32984b5e3bb (patch)
treea4468d9df7903b1659fb5eca622d453ab3acefaf
parentf31cb45ad2ca46cc743dfadf5ac8b916cbe4ea9c (diff)
downloadlibgit2-85d2748c6f75bd810c7376647c8ae32984b5e3bb.tar.gz
khash: avoid using `kh_key`/`kh_val` as lvalue
-rw-r--r--src/cache.c4
-rw-r--r--src/indexer.c4
-rw-r--r--src/odb_mempack.c4
-rw-r--r--src/oidmap.h8
-rw-r--r--src/pack-objects.c4
-rw-r--r--src/pack.c2
-rw-r--r--src/revwalk.c2
-rw-r--r--src/sortedcache.c4
-rw-r--r--src/strmap.h1
-rw-r--r--tests/core/oidmap.c4
10 files changed, 20 insertions, 17 deletions
diff --git a/src/cache.c b/src/cache.c
index 965fc0c9b..5f71d16bb 100644
--- a/src/cache.c
+++ b/src/cache.c
@@ -219,8 +219,8 @@ static void *cache_store(git_cache *cache, git_cached_obj *entry)
git_cached_obj_decref(stored_entry);
git_cached_obj_incref(entry);
- git_oidmap_key(cache->map, pos) = &entry->oid;
- git_oidmap_value_at(cache->map, pos) = entry;
+ git_oidmap_set_key_at(cache->map, pos, &entry->oid);
+ git_oidmap_set_value_at(cache->map, pos, entry);
} else {
/* NO OP */
}
diff --git a/src/indexer.c b/src/indexer.c
index 888a06cdb..3e88bc7ba 100644
--- a/src/indexer.c
+++ b/src/indexer.c
@@ -308,7 +308,7 @@ static int store_object(git_indexer *idx)
}
- git_oidmap_value_at(idx->pack->idx_cache, k) = pentry;
+ git_oidmap_set_value_at(idx->pack->idx_cache, k, pentry);
git_oid_cpy(&entry->oid, &oid);
@@ -356,7 +356,7 @@ static int save_entry(git_indexer *idx, struct entry *entry, struct git_pack_ent
return -1;
}
- git_oidmap_value_at(idx->pack->idx_cache, k) = pentry;
+ git_oidmap_set_value_at(idx->pack->idx_cache, k, pentry);
/* Add the object to the list */
if (git_vector_insert(&idx->objects, entry) < 0)
diff --git a/src/odb_mempack.c b/src/odb_mempack.c
index da3d85f78..52f8089e1 100644
--- a/src/odb_mempack.c
+++ b/src/odb_mempack.c
@@ -57,8 +57,8 @@ static int impl__write(git_odb_backend *_backend, const git_oid *oid, const void
obj->len = len;
obj->type = type;
- git_oidmap_key(db->objects, pos) = &obj->oid;
- git_oidmap_value_at(db->objects, pos) = obj;
+ git_oidmap_set_key_at(db->objects, pos, &obj->oid);
+ git_oidmap_set_value_at(db->objects, pos, obj);
if (type == GIT_OBJ_COMMIT) {
struct memobject **store = git_array_alloc(db->commits);
diff --git a/src/oidmap.h b/src/oidmap.h
index c34547aae..e736a516b 100644
--- a/src/oidmap.h
+++ b/src/oidmap.h
@@ -39,9 +39,11 @@ GIT_INLINE(khint_t) git_oidmap_hash(const git_oid *oid)
#define git_oidmap_exists(h, k) (kh_get(oid, h, k) != kh_end(h))
#define git_oidmap_has_data(h, idx) kh_exist(h, idx)
-#define git_oidmap_key(h, idx) kh_key(h, idx)
-#define git_oidmap_value_at(h, idx) kh_val(h, idx)
-#define git_oidmap_delete_at(h, idx) kh_del(oid, h, idx)
+#define git_oidmap_key(h, idx) kh_key(h, idx)
+#define git_oidmap_set_key_at(h, idx, k) kh_key(h, idx) = k
+#define git_oidmap_value_at(h, idx) kh_val(h, idx)
+#define git_oidmap_set_value_at(h, idx, v) kh_val(h, idx) = v
+#define git_oidmap_delete_at(h, idx) kh_del(oid, h, idx)
#define git_oidmap_put(h, k, err) kh_put(oid, h, k, err)
diff --git a/src/pack-objects.c b/src/pack-objects.c
index 1604744c3..fa11763c2 100644
--- a/src/pack-objects.c
+++ b/src/pack-objects.c
@@ -200,7 +200,7 @@ static void rehash(git_packbuilder *pb)
git_oidmap_clear(pb->object_ix);
for (i = 0, po = pb->object_list; i < pb->nr_objects; i++, po++) {
pos = git_oidmap_put(pb->object_ix, &po->id, &ret);
- git_oidmap_value_at(pb->object_ix, pos) = po;
+ git_oidmap_set_value_at(pb->object_ix, pos, po);
}
}
@@ -252,7 +252,7 @@ int git_packbuilder_insert(git_packbuilder *pb, const git_oid *oid,
return ret;
}
assert(ret != 0);
- git_oidmap_value_at(pb->object_ix, pos) = po;
+ git_oidmap_set_value_at(pb->object_ix, pos, po);
pb->done = false;
diff --git a/src/pack.c b/src/pack.c
index 857d26639..4e30ca7c3 100644
--- a/src/pack.c
+++ b/src/pack.c
@@ -171,7 +171,7 @@ static int cache_add(
k = git_offmap_put(cache->entries, offset, &error);
assert(error != 0);
- git_oidmap_value_at(cache->entries, k) = entry;
+ git_offmap_set_value_at(cache->entries, k, entry);
cache->memory_used += entry->raw.len;
*cached_out = entry;
diff --git a/src/revwalk.c b/src/revwalk.c
index 6581d7a37..ac5400253 100644
--- a/src/revwalk.c
+++ b/src/revwalk.c
@@ -37,7 +37,7 @@ git_commit_list_node *git_revwalk__commit_lookup(
pos = git_oidmap_put(walk->commits, &commit->oid, &ret);
assert(ret != 0);
- git_oidmap_value_at(walk->commits, pos) = commit;
+ git_oidmap_set_value_at(walk->commits, pos, commit);
return commit;
}
diff --git a/src/sortedcache.c b/src/sortedcache.c
index e9e50636b..20e137e91 100644
--- a/src/sortedcache.c
+++ b/src/sortedcache.c
@@ -299,8 +299,8 @@ int git_sortedcache_upsert(void **out, git_sortedcache *sc, const char *key)
goto done;
if (!error)
- git_strmap_key(sc->map, pos) = item_key;
- git_strmap_value_at(sc->map, pos) = item;
+ git_strmap_set_key_at(sc->map, pos, item_key);
+ git_strmap_set_value_at(sc->map, pos, item);
error = git_vector_insert(&sc->items, item);
if (error < 0)
diff --git a/src/strmap.h b/src/strmap.h
index 4c5f888ae..7b9695695 100644
--- a/src/strmap.h
+++ b/src/strmap.h
@@ -38,6 +38,7 @@ typedef khiter_t git_strmap_iter;
#define git_strmap_has_data(h, idx) kh_exist(h, idx)
#define git_strmap_key(h, idx) kh_key(h, idx)
+#define git_strmap_set_key_at(h, idx, k) kh_val(h, idx) = k
#define git_strmap_value_at(h, idx) kh_val(h, idx)
#define git_strmap_set_value_at(h, idx, v) kh_val(h, idx) = v
#define git_strmap_delete_at(h, idx) kh_del(str, h, idx)
diff --git a/tests/core/oidmap.c b/tests/core/oidmap.c
index 88db692fc..92b8c1937 100644
--- a/tests/core/oidmap.c
+++ b/tests/core/oidmap.c
@@ -39,7 +39,7 @@ void test_core_oidmap__basic(void)
pos = git_oidmap_put(map, &items[i].oid, &ret);
cl_assert(ret != 0);
- git_oidmap_value_at(map, pos) = &items[i];
+ git_oidmap_set_value_at(map, pos, &items[i]);
}
@@ -93,7 +93,7 @@ void test_core_oidmap__hash_collision(void)
pos = git_oidmap_put(map, &items[i].oid, &ret);
cl_assert(ret != 0);
- git_oidmap_value_at(map, pos) = &items[i];
+ git_oidmap_set_value_at(map, pos, &items[i]);
}