Skip to content

Commit d0c418c

Browse files
author
Matthew Plough
committed
Fix uninitialized variable warning
Fix the following warning emitted by clang: [ 16%] Building C object CMakeFiles/libgit2_clar.dir/src/submodule.c.o /Users/mplough/devel/external/libgit2/src/submodule.c:408:6: warning: variable 'i' is used uninitialized whenever 'if' condition is true [-Wsometimes-uninitialized] if ((error = load_submodule_names(names, cfg))) ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /Users/mplough/devel/external/libgit2/src/submodule.c:448:20: note: uninitialized use occurs here git_iterator_free(i); ^ /Users/mplough/devel/external/libgit2/src/submodule.c:408:2: note: remove the 'if' if its condition is always false if ((error = load_submodule_names(names, cfg))) ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /Users/mplough/devel/external/libgit2/src/submodule.c:404:17: note: initialize the variable 'i' to silence this warning git_iterator *i; ^ = NULL 1 warning generated.
1 parent 8df1cfc commit d0c418c

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/submodule.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -401,7 +401,7 @@ static int submodules_from_index(git_strmap *map, git_index *idx, git_config *cf
401401
static int submodules_from_head(git_strmap *map, git_tree *head, git_config *cfg)
402402
{
403403
int error;
404-
git_iterator *i;
404+
git_iterator *i = NULL;
405405
const git_index_entry *entry;
406406
git_strmap *names = 0;
407407
git_strmap_alloc(&names);

0 commit comments

Comments
 (0)