Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit a7c02c9

Browse files
authored
Merge pull request #7258 from libgit2/ethomson/build
Avoid uninitialized variable warnings in gcc
2 parents 8ae1cf5 + 83f6d0e commit a7c02c9

5 files changed

Lines changed: 6 additions & 5 deletions

File tree

src/cli/opt.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -359,7 +359,7 @@ GIT_INLINE(const cli_opt_spec *) spec_for_sort(
359359
const char *arg)
360360
{
361361
int is_negated, has_value = 0;
362-
const char *value;
362+
const char *value = NULL;
363363
const cli_opt_spec *spec = NULL;
364364
size_t idx = 0;
365365

src/libgit2/index.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1210,7 +1210,7 @@ static int canonicalize_directory_path(
12101210
{
12111211
const git_index_entry *match, *best = NULL;
12121212
char *search, *sep;
1213-
size_t pos, search_len, best_len;
1213+
size_t pos, search_len, best_len = 0;
12141214

12151215
if (!index->ignore_case)
12161216
return 0;

src/libgit2/midx.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -460,7 +460,7 @@ int git_midx_foreach_entry(
460460
{
461461
git_oid oid;
462462
size_t oid_size, i;
463-
int error;
463+
int error = 0;
464464

465465
GIT_ASSERT_ARG(idx);
466466

src/util/hashmap.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ typedef uint32_t git_hashmap_iter_t;
107107
} \
108108
GIT_INLINE(int) name##__idx(uint32_t *out, name *h, key_t key) \
109109
{ \
110+
*out = UINT_MAX; \
110111
if (h->n_buckets) { \
111112
uint32_t k, i, last, mask, step = 0; \
112113
GIT_ASSERT((h)->flags); \

src/util/runtime.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ static git_atomic32 init_count;
1616
static int init_common(git_runtime_init_fn init_fns[], size_t cnt)
1717
{
1818
size_t i;
19-
int ret;
19+
int ret = 0;
2020

2121
/* Initialize subsystems that have global state */
2222
for (i = 0; i < cnt; i++) {
@@ -110,7 +110,7 @@ GIT_INLINE(int) init_unlock(void)
110110

111111
int git_runtime_init(git_runtime_init_fn init_fns[], size_t cnt)
112112
{
113-
int ret;
113+
int ret = 0;
114114

115115
if (init_lock() < 0)
116116
return -1;

0 commit comments

Comments
 (0)