Skip to content

Commit 487233f

Browse files
authored
Merge pull request libgit2#4895 from pks-t/pks/unused-warnings
Unused function warnings
2 parents a904fc6 + ffe39ba commit 487233f

35 files changed

+365
-308
lines changed

CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -228,8 +228,8 @@ ELSE ()
228228
ENABLE_WARNINGS(strict-prototypes)
229229
ENABLE_WARNINGS(declaration-after-statement)
230230
ENABLE_WARNINGS(shift-count-overflow)
231-
DISABLE_WARNINGS(unused-const-variable)
232-
DISABLE_WARNINGS(unused-function)
231+
ENABLE_WARNINGS(unused-const-variable)
232+
ENABLE_WARNINGS(unused-function)
233233
ENABLE_WARNINGS(format)
234234
ENABLE_WARNINGS(format-security)
235235
ENABLE_WARNINGS(int-conversion)

src/attrcache.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ GIT_INLINE(void) attr_cache_unlock(git_attr_cache *cache)
3333
GIT_INLINE(git_attr_file_entry *) attr_cache_lookup_entry(
3434
git_attr_cache *cache, const char *path)
3535
{
36-
khiter_t pos = git_strmap_lookup_index(cache->files, path);
36+
size_t pos = git_strmap_lookup_index(cache->files, path);
3737

3838
if (git_strmap_valid_index(cache->files, pos))
3939
return git_strmap_value_at(cache->files, pos);
@@ -266,7 +266,7 @@ bool git_attr_cache__is_cached(
266266
{
267267
git_attr_cache *cache = git_repository_attr_cache(repo);
268268
git_strmap *files;
269-
khiter_t pos;
269+
size_t pos;
270270
git_attr_file_entry *entry;
271271

272272
if (!cache || !(files = cache->files))
@@ -457,7 +457,7 @@ git_attr_rule *git_attr_cache__lookup_macro(
457457
git_repository *repo, const char *name)
458458
{
459459
git_strmap *macros = git_repository_attr_cache(repo)->macros;
460-
khiter_t pos;
460+
size_t pos;
461461

462462
pos = git_strmap_lookup_index(macros, name);
463463

src/cache.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ static void cache_evict_entries(git_cache *cache)
123123
}
124124

125125
while (evict_count > 0) {
126-
khiter_t pos = seed++ % git_oidmap_end(cache->map);
126+
size_t pos = seed++ % git_oidmap_end(cache->map);
127127

128128
if (git_oidmap_has_data(cache->map, pos)) {
129129
git_cached_obj *evict = git_oidmap_value_at(cache->map, pos);
@@ -148,7 +148,7 @@ static bool cache_should_store(git_otype object_type, size_t object_size)
148148

149149
static void *cache_get(git_cache *cache, const git_oid *oid, unsigned int flags)
150150
{
151-
khiter_t pos;
151+
size_t pos;
152152
git_cached_obj *entry = NULL;
153153

154154
if (!git_cache__enabled || git_rwlock_rdlock(&cache->lock) < 0)
@@ -172,7 +172,7 @@ static void *cache_get(git_cache *cache, const git_oid *oid, unsigned int flags)
172172

173173
static void *cache_store(git_cache *cache, git_cached_obj *entry)
174174
{
175-
khiter_t pos;
175+
size_t pos;
176176

177177
git_cached_obj_incref(entry);
178178

src/config_entries.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,9 +131,9 @@ void git_config_entries_free(git_config_entries *entries)
131131

132132
int git_config_entries_append(git_config_entries *entries, git_config_entry *entry)
133133
{
134-
git_strmap_iter pos;
135134
config_entry_list *existing, *var;
136135
int error = 0;
136+
size_t pos;
137137

138138
var = git__calloc(1, sizeof(config_entry_list));
139139
GITERR_CHECK_ALLOC(var);
@@ -171,7 +171,7 @@ int git_config_entries_append(git_config_entries *entries, git_config_entry *ent
171171

172172
int config_entry_get(config_entry_list **out, git_config_entries *entries, const char *key)
173173
{
174-
khiter_t pos;
174+
size_t pos;
175175

176176
pos = git_strmap_lookup_index(entries->map, key);
177177

src/describe.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ struct commit_name {
3636

3737
static void *oidmap_value_bykey(git_oidmap *map, const git_oid *key)
3838
{
39-
khint_t pos = git_oidmap_lookup_index(map, key);
39+
size_t pos = git_oidmap_lookup_index(map, key);
4040

4141
if (!git_oidmap_valid_index(map, pos))
4242
return NULL;

src/diff_driver.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -234,8 +234,7 @@ static int git_diff_driver_load(
234234
int error = 0;
235235
git_diff_driver_registry *reg;
236236
git_diff_driver *drv = NULL;
237-
size_t namelen;
238-
khiter_t pos;
237+
size_t namelen, pos;
239238
git_config *cfg = NULL;
240239
git_buf name = GIT_BUF_INIT;
241240
git_config_entry *ce = NULL;

src/idxmap.c

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,16 @@
77

88
#include "idxmap.h"
99

10+
#define kmalloc git__malloc
11+
#define kcalloc git__calloc
12+
#define krealloc git__realloc
13+
#define kreallocarray git__reallocarray
14+
#define kfree git__free
15+
#include "khash.h"
16+
17+
__KHASH_TYPE(idx, const git_index_entry *, git_index_entry *)
18+
__KHASH_TYPE(idxicase, const git_index_entry *, git_index_entry *)
19+
1020
/* This is __ac_X31_hash_string but with tolower and it takes the entry's stage into account */
1121
static kh_inline khint_t idxentry_hash(const git_index_entry *e)
1222
{
@@ -104,11 +114,21 @@ void git_idxmap_free(git_idxmap *map)
104114
kh_destroy(idx, map);
105115
}
106116

117+
void git_idxmap_icase_free(git_idxmap_icase *map)
118+
{
119+
kh_destroy(idxicase, map);
120+
}
121+
107122
void git_idxmap_clear(git_idxmap *map)
108123
{
109124
kh_clear(idx, map);
110125
}
111126

127+
void git_idxmap_icase_clear(git_idxmap_icase *map)
128+
{
129+
kh_clear(idxicase, map);
130+
}
131+
112132
void git_idxmap_delete_at(git_idxmap *map, size_t idx)
113133
{
114134
kh_del(idx, map, idx);

src/idxmap.h

Lines changed: 4 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -9,23 +9,10 @@
99

1010
#include "common.h"
1111

12-
#include <ctype.h>
1312
#include "git2/index.h"
1413

15-
#define kmalloc git__malloc
16-
#define kcalloc git__calloc
17-
#define krealloc git__realloc
18-
#define kreallocarray git__reallocarray
19-
#define kfree git__free
20-
#include "khash.h"
21-
22-
__KHASH_TYPE(idx, const git_index_entry *, git_index_entry *)
23-
__KHASH_TYPE(idxicase, const git_index_entry *, git_index_entry *)
24-
25-
typedef khash_t(idx) git_idxmap;
26-
typedef khash_t(idxicase) git_idxmap_icase;
27-
28-
typedef khiter_t git_idxmap_iter;
14+
typedef struct kh_idx_s git_idxmap;
15+
typedef struct kh_idxicase_s git_idxmap_icase;
2916

3017
int git_idxmap_alloc(git_idxmap **map);
3118
int git_idxmap_icase_alloc(git_idxmap_icase **map);
@@ -41,15 +28,14 @@ int git_idxmap_has_data(git_idxmap *map, size_t idx);
4128
void git_idxmap_resize(git_idxmap *map, size_t size);
4229
void git_idxmap_icase_resize(git_idxmap_icase *map, size_t size);
4330
void git_idxmap_free(git_idxmap *map);
31+
void git_idxmap_icase_free(git_idxmap_icase *map);
4432
void git_idxmap_clear(git_idxmap *map);
33+
void git_idxmap_icase_clear(git_idxmap_icase *map);
4534

4635
void git_idxmap_delete_at(git_idxmap *map, size_t idx);
4736
void git_idxmap_icase_delete_at(git_idxmap_icase *map, size_t idx);
4837

4938
void git_idxmap_delete(git_idxmap *map, const git_index_entry *key);
5039
void git_idxmap_icase_delete(git_idxmap_icase *map, const git_index_entry *key);
5140

52-
#define git_idxmap_begin kh_begin
53-
#define git_idxmap_end kh_end
54-
5541
#endif

src/index.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929

3030
#define INSERT_IN_MAP_EX(idx, map, e, err) do { \
3131
if ((idx)->ignore_case) \
32-
git_idxmap_icase_insert((khash_t(idxicase) *) (map), (e), (e), (err)); \
32+
git_idxmap_icase_insert((git_idxmap_icase *) (map), (e), (e), (err)); \
3333
else \
3434
git_idxmap_insert((map), (e), (e), (err)); \
3535
} while (0)
@@ -38,14 +38,14 @@
3838

3939
#define LOOKUP_IN_MAP(p, idx, k) do { \
4040
if ((idx)->ignore_case) \
41-
(p) = git_idxmap_icase_lookup_index((khash_t(idxicase) *) index->entries_map, (k)); \
41+
(p) = git_idxmap_icase_lookup_index((git_idxmap_icase *) index->entries_map, (k)); \
4242
else \
4343
(p) = git_idxmap_lookup_index(index->entries_map, (k)); \
4444
} while (0)
4545

4646
#define DELETE_IN_MAP(idx, e) do { \
4747
if ((idx)->ignore_case) \
48-
git_idxmap_icase_delete((khash_t(idxicase) *) (idx)->entries_map, (e)); \
48+
git_idxmap_icase_delete((git_idxmap_icase *) (idx)->entries_map, (e)); \
4949
else \
5050
git_idxmap_delete((idx)->entries_map, (e)); \
5151
} while (0)
@@ -851,8 +851,8 @@ const git_index_entry *git_index_get_byindex(
851851
const git_index_entry *git_index_get_bypath(
852852
git_index *index, const char *path, int stage)
853853
{
854-
khiter_t pos;
855854
git_index_entry key = {{ 0 }};
855+
size_t pos;
856856

857857
assert(index);
858858

@@ -1619,7 +1619,7 @@ int git_index__fill(git_index *index, const git_vector *source_entries)
16191619
return 0;
16201620

16211621
git_vector_size_hint(&index->entries, source_entries->length);
1622-
git_idxmap_resize(index->entries_map, (khint_t)(source_entries->length * 1.3));
1622+
git_idxmap_resize(index->entries_map, (size_t)(source_entries->length * 1.3));
16231623

16241624
git_vector_foreach(source_entries, i, source_entry) {
16251625
git_index_entry *entry = NULL;
@@ -2603,7 +2603,7 @@ static int parse_index(git_index *index, const char *buffer, size_t buffer_size)
26032603
assert(!index->entries.length);
26042604

26052605
if (index->ignore_case)
2606-
git_idxmap_icase_resize((khash_t(idxicase) *) index->entries_map, header.entry_count);
2606+
git_idxmap_icase_resize((git_idxmap_icase *) index->entries_map, header.entry_count);
26072607
else
26082608
git_idxmap_resize(index->entries_map, header.entry_count);
26092609

@@ -3124,7 +3124,7 @@ int git_index_read_tree(git_index *index, const git_tree *tree)
31243124
goto cleanup;
31253125

31263126
if (index->ignore_case)
3127-
git_idxmap_icase_resize((khash_t(idxicase) *) entries_map, entries.length);
3127+
git_idxmap_icase_resize((git_idxmap_icase *) entries_map, entries.length);
31283128
else
31293129
git_idxmap_resize(entries_map, entries.length);
31303130

@@ -3184,7 +3184,7 @@ static int git_index_read_iterator(
31843184
goto done;
31853185

31863186
if (index->ignore_case && new_length_hint)
3187-
git_idxmap_icase_resize((khash_t(idxicase) *) new_entries_map, new_length_hint);
3187+
git_idxmap_icase_resize((git_idxmap_icase *) new_entries_map, new_length_hint);
31883188
else if (new_length_hint)
31893189
git_idxmap_resize(new_entries_map, new_length_hint);
31903190

src/indexer.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -402,7 +402,7 @@ static int check_object_connectivity(git_indexer *idx, const git_rawobj *obj)
402402
static int store_object(git_indexer *idx)
403403
{
404404
int i, error;
405-
khiter_t k;
405+
size_t k;
406406
git_oid oid;
407407
struct entry *entry;
408408
git_off_t entry_size;
@@ -483,7 +483,7 @@ GIT_INLINE(bool) has_entry(git_indexer *idx, git_oid *id)
483483
static int save_entry(git_indexer *idx, struct entry *entry, struct git_pack_entry *pentry, git_off_t entry_start)
484484
{
485485
int i, error;
486-
khiter_t k;
486+
size_t k;
487487

488488
if (entry_start > UINT31_MAX) {
489489
entry->offset = UINT32_MAX;
@@ -1292,7 +1292,7 @@ int git_indexer_commit(git_indexer *idx, git_transfer_progress *stats)
12921292

12931293
void git_indexer_free(git_indexer *idx)
12941294
{
1295-
khiter_t pos;
1295+
size_t pos;
12961296

12971297
if (idx == NULL)
12981298
return;

0 commit comments

Comments
 (0)