Skip to content

Commit a9ba029

Browse files
committed
hashmap: add some asserts
Quiet down static code analysis.
1 parent 5ead0bd commit a9ba029

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/util/hashmap.h

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -340,6 +340,9 @@ typedef uint32_t git_hashmap_iter_t;
340340
int error = name##__put_idx(&idx, &key_exists, h, key); \
341341
if (error) \
342342
return error; \
343+
GIT_ASSERT((h)->flags); \
344+
GIT_ASSERT((h)->keys); \
345+
GIT_ASSERT((h)->keys); \
343346
if (!key_exists) \
344347
(h)->keys[idx] = key; \
345348
(h)->vals[idx] = val; \
@@ -382,8 +385,11 @@ typedef uint32_t git_hashmap_iter_t;
382385
int error = name##__put_idx(&idx, &key_exists, h, key); \
383386
if (error) \
384387
return error; \
385-
if (!key_exists) \
388+
GIT_ASSERT((h)->flags); \
389+
GIT_ASSERT((h)->keys); \
390+
if (!key_exists) { \
386391
(h)->keys[idx] = key; \
392+
} \
387393
return 0; \
388394
} \
389395
GIT_UNUSED_FUNCTION scope int name##_iterate(git_hashmap_iter_t *iter, key_t *key, name *h) \

0 commit comments

Comments
 (0)