Skip to content

Commit 73028af

Browse files
committed
khash: avoid using macro magic to get return address
1 parent 85d2748 commit 73028af

File tree

18 files changed

+37
-37
lines changed

18 files changed

+37
-37
lines changed

src/attr.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ int git_attr_foreach(
209209
if (git_strmap_exists(seen, assign->name))
210210
continue;
211211

212-
git_strmap_insert(seen, assign->name, assign, error);
212+
git_strmap_insert(seen, assign->name, assign, &error);
213213
if (error < 0)
214214
goto cleanup;
215215

src/attrcache.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ static int attr_cache_make_entry(
8282
&entry, git_repository_workdir(repo), path, &cache->pool);
8383

8484
if (!error) {
85-
git_strmap_insert(cache->files, entry->path, entry, error);
85+
git_strmap_insert(cache->files, entry->path, entry, &error);
8686
if (error > 0)
8787
error = 0;
8888
}
@@ -435,7 +435,7 @@ int git_attr_cache__insert_macro(git_repository *repo, git_attr_rule *macro)
435435
giterr_set(GITERR_OS, "unable to get attr cache lock");
436436
error = -1;
437437
} else {
438-
git_strmap_insert(macros, macro->match.pattern, macro, error);
438+
git_strmap_insert(macros, macro->match.pattern, macro, &error);
439439
git_mutex_unlock(&cache->lock);
440440
}
441441

src/cache.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ static void *cache_store(git_cache *cache, git_cached_obj *entry)
199199
if (!git_oidmap_valid_index(cache->map, pos)) {
200200
int rval;
201201

202-
git_oidmap_insert(cache->map, &entry->oid, entry, rval);
202+
git_oidmap_insert(cache->map, &entry->oid, entry, &rval);
203203
if (rval >= 0) {
204204
git_cached_obj_incref(entry);
205205
cache->used_memory += entry->size;

src/config_file.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ static int append_entry(git_strmap *values, cvar_t *var)
179179

180180
pos = git_strmap_lookup_index(values, var->entry->name);
181181
if (!git_strmap_valid_index(values, pos)) {
182-
git_strmap_insert(values, var->entry->name, var, error);
182+
git_strmap_insert(values, var->entry->name, var, &error);
183183
} else {
184184
existing = git_strmap_value_at(values, pos);
185185
while (existing->next != NULL) {

src/describe.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ static int add_to_known_names(
127127
if (!found) {
128128
int ret;
129129

130-
git_oidmap_insert(names, &e->peeled, e, ret);
130+
git_oidmap_insert(names, &e->peeled, e, &ret);
131131
if (ret < 0)
132132
return -1;
133133
}

src/diff_driver.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ static int git_diff_driver_builtin(
217217
goto done;
218218
}
219219

220-
git_strmap_insert(reg->drivers, drv->name, drv, error);
220+
git_strmap_insert(reg->drivers, drv->name, drv, &error);
221221
if (error > 0)
222222
error = 0;
223223

@@ -331,7 +331,7 @@ static int git_diff_driver_load(
331331
goto done;
332332

333333
/* store driver in registry */
334-
git_strmap_insert(reg->drivers, drv->name, drv, error);
334+
git_strmap_insert(reg->drivers, drv->name, drv, &error);
335335
if (error < 0)
336336
goto done;
337337
error = 0;

src/fileops.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -607,7 +607,7 @@ int git_futils_mkdir_relative(
607607

608608
memcpy(cache_path, make_path.ptr, make_path.size + 1);
609609

610-
git_strmap_insert(opts->dir_map, cache_path, cache_path, error);
610+
git_strmap_insert(opts->dir_map, cache_path, cache_path, &error);
611611
if (error < 0)
612612
goto done;
613613
}

src/idxmap.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -51,16 +51,16 @@ static kh_inline khint_t idxentry_hash(const git_index_entry *e)
5151
((*(hp) = kh_init(idxicase)) == NULL) ? giterr_set_oom(), -1 : 0
5252

5353
#define git_idxmap_insert(h, key, val, rval) do { \
54-
khiter_t __pos = kh_put(idx, h, key, &rval); \
55-
if (rval >= 0) { \
56-
if (rval == 0) kh_key(h, __pos) = key; \
54+
khiter_t __pos = kh_put(idx, h, key, rval); \
55+
if ((*rval) >= 0) { \
56+
if ((*rval) == 0) kh_key(h, __pos) = key; \
5757
kh_val(h, __pos) = val; \
5858
} } while (0)
5959

6060
#define git_idxmap_icase_insert(h, key, val, rval) do { \
61-
khiter_t __pos = kh_put(idxicase, h, key, &rval); \
62-
if (rval >= 0) { \
63-
if (rval == 0) kh_key(h, __pos) = key; \
61+
khiter_t __pos = kh_put(idxicase, h, key, rval); \
62+
if ((*rval) >= 0) { \
63+
if ((*rval) == 0) kh_key(h, __pos) = key; \
6464
kh_val(h, __pos) = val; \
6565
} } while (0)
6666

src/index.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1365,7 +1365,7 @@ static int index_insert(
13651365
error = git_vector_insert_sorted(&index->entries, entry, index_no_dups);
13661366

13671367
if (error == 0) {
1368-
INSERT_IN_MAP(index, entry, error);
1368+
INSERT_IN_MAP(index, entry, &error);
13691369
}
13701370
}
13711371

@@ -1592,7 +1592,7 @@ int git_index__fill(git_index *index, const git_vector *source_entries)
15921592
if ((ret = git_vector_insert(&index->entries, entry)) < 0)
15931593
break;
15941594

1595-
INSERT_IN_MAP(index, entry, ret);
1595+
INSERT_IN_MAP(index, entry, &ret);
15961596
if (ret < 0)
15971597
break;
15981598
}
@@ -2499,7 +2499,7 @@ static int parse_index(git_index *index, const char *buffer, size_t buffer_size)
24992499
goto done;
25002500
}
25012501

2502-
INSERT_IN_MAP(index, entry, error);
2502+
INSERT_IN_MAP(index, entry, &error);
25032503

25042504
if (error < 0) {
25052505
index_entry_free(entry);
@@ -2984,7 +2984,7 @@ int git_index_read_tree(git_index *index, const git_tree *tree)
29842984
kh_resize(idx, entries_map, entries.length);
29852985

29862986
git_vector_foreach(&entries, i, e) {
2987-
INSERT_IN_MAP_EX(index, entries_map, e, error);
2987+
INSERT_IN_MAP_EX(index, entries_map, e, &error);
29882988

29892989
if (error < 0) {
29902990
giterr_set(GITERR_INDEX, "failed to insert entry into map");
@@ -3103,7 +3103,7 @@ static int git_index_read_iterator(
31033103

31043104
if (add_entry) {
31053105
if ((error = git_vector_insert(&new_entries, add_entry)) == 0)
3106-
INSERT_IN_MAP_EX(index, new_entries_map, add_entry, error);
3106+
INSERT_IN_MAP_EX(index, new_entries_map, add_entry, &error);
31073107
}
31083108

31093109
if (remove_entry && error >= 0)

src/mwindow.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ int git_mwindow_get_pack(struct git_pack_file **out, const char *path)
8484

8585
git_atomic_inc(&pack->refcount);
8686

87-
git_strmap_insert(git__pack_cache, pack->pack_name, pack, error);
87+
git_strmap_insert(git__pack_cache, pack->pack_name, pack, &error);
8888
git_mutex_unlock(&git__mwindow_mutex);
8989

9090
if (error < 0) {

0 commit comments

Comments
 (0)