libgit2 / libgit2/libgit2

1.7.2: LTO exposes a lot of `-Wmaybe-uninitialized` issues

Open
#6,734 5 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C
Stars
10.6k
Forks
2.7k
PR merge metrics
No merged PRs in 30d

Description

First just summary build time warning stats

[tkloczko@pers-jacek SPECS]$ rpmbuild -ba libgit2.spec 2>&1 | grep -- \\[-W | sed 's/.*\[//; s/\]//' | sort | uniq -c | sort -nr
     62 -Wmaybe-uninitialized
      1 -Wuse-after-free
      1 -Wstringop-overread
      1 -Wdangling-pointer=
      1 -Warray-parameter=
extracted stderr with all warnings
deps/ntlmclient/unicode_builtin.c: In function ‘unicode_builtin_encoding_convert’:
deps/ntlmclient/unicode_builtin.c:380:37: warning: pointer ‘out_19’ may be used after ‘realloc’ [-Wuse-after-free]
  380 |                 out_len = out_start - out;
      |                           ~~~~~~~~~~^~~~~
deps/ntlmclient/unicode_builtin.c:375:32: note: call to ‘realloc’ here
  375 |                 if ((new_out = realloc(out, out_size)) == NULL) {
      |                                ^~~~~~~~~~~~~~~~~~~~~~
src/util/futils.c:224:23: warning: argument 3 of type ‘unsigned char[32]’ with mismatched bound [-Warray-parameter=]
  224 |         unsigned char checksum[GIT_HASH_SHA256_SIZE],
      |         ~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from src/util/futils.c:8:
src/util/futils.h:28:23: note: previously declared as ‘unsigned char[20]’
   28 |         unsigned char checksum[GIT_HASH_SHA1_SIZE],
      |         ~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
At top level:
cc1: note: unrecognized command-line option ‘-Wno-documentation-deprecated-sync’ may have been intended to silence earlier diagnostics
cc1: note: unrecognized command-line option ‘-Wno-documentation-deprecated-sync’ may have been intended to silence earlier diagnostics
src/libgit2/transports/httpclient.c: In function ‘git_http_client_read_body’:
src/libgit2/transports/httpclient.c:1461:29: warning: storing the address of local variable ‘parser_context’ in ‘client_17(D)->parser.data’ [-Wdangling-pointer=]
 1461 |         client->parser.data = &parser_context;
      |         ~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~
src/libgit2/transports/httpclient.c:1441:29: note: ‘parser_context’ declared here
 1441 |         http_parser_context parser_context = {0};
      |                             ^~~~~~~~~~~~~~
src/libgit2/transports/httpclient.c:1437:26: note: ‘client’ declared here
 1437 |         git_http_client *client,
      |         ~~~~~~~~~~~~~~~~~^~~~~~
At top level:
cc1: note: unrecognized command-line option ‘-Wno-documentation-deprecated-sync’ may have been intended to silence earlier diagnostics
In function ‘git_regexp_match’,
    inlined from ‘git_config_backend_foreach_match’ at src/libgit2/config.c:532:17:
src/util/regexp.c:37:22: warning: ‘regex’ may be used uninitialized [-Wmaybe-uninitialized]
   37 |         if ((error = pcre_exec(*r, NULL, string, (int) strlen(string), 0, 0, NULL, 0)) < 0)
      |                      ^
src/libgit2/config.c: In function ‘git_config_backend_foreach_match’:
src/libgit2/config.c:516:20: note: ‘regex’ was declared here
  516 |         git_regexp regex;
      |                    ^
In function ‘git_fs_path_owner_is’,
    inlined from ‘validate_ownership_path’ at src/libgit2/repository.c:631:11,
    inlined from ‘validate_ownership’ at src/libgit2/repository.c:671:16,
    inlined from ‘git_repository_open_ext’ at src/libgit2/repository.c:1124:15:
src/util/fs_path.c:1990:45: warning: ‘sudo_uid’ may be used uninitialized [-Wmaybe-uninitialized]
 1990 |             sudo_uid_lookup(&sudo_uid) == 0 &&
      |                                             ^
src/util/fs_path.c: In function ‘git_repository_open_ext’:
src/util/fs_path.c:1959:21: note: ‘sudo_uid’ was declared here
 1959 |         uid_t euid, sudo_uid;
      |                     ^
In function ‘handle_next’,
    inlined from ‘test_dirent__diriter_with_fullname’ at tests/util/dirent.c:270:3:
tests/util/dirent.c:253:9: warning: ‘filename’ may be used uninitialized [-Wmaybe-uninitialized]
  253 |         cl_assert_equal_s(fullpath+4, filename);
      |         ^
tests/util/dirent.c: In function ‘test_dirent__diriter_with_fullname’:
tests/util/dirent.c:246:32: note: ‘filename’ was declared here
  246 |         const char *fullpath, *filename;
      |                                ^
In function ‘reflog_parse’,
    inlined from ‘refdb_reflog_fs__read’ at src/libgit2/refdb_fs.c:2090:15:
src/libgit2/refdb_fs.c:1968:20: warning: ‘c’ may be used uninitialized [-Wmaybe-uninitialized]
 1968 |                 if (c == '\t') {
      |                    ^
src/libgit2/refdb_fs.c: In function ‘refdb_reflog_fs__read’:
src/libgit2/refdb_fs.c:1949:22: note: ‘c’ was declared here
 1949 |                 char c;
      |                      ^
tests/util/strtol.c: In function ‘assert_l32_parses’:
tests/util/strtol.c:7:9: warning: ‘i’ may be used uninitialized [-Wmaybe-uninitialized]
    7 |         cl_assert_equal_i(i, expected);
      |         ^
tests/util/strtol.c:5:17: note: ‘i’ was declared here
    5 |         int32_t i;
      |                 ^
tests/util/strtol.c: In function ‘test_strtol__buffer_length_truncates’:
tests/util/strtol.c:97:9: warning: ‘i32’ may be used uninitialized [-Wmaybe-uninitialized]
   97 |         cl_assert_equal_i(i32, 1);
      |         ^
tests/util/strtol.c:93:17: note: ‘i32’ was declared here
   93 |         int32_t i32;
      |                 ^
In function ‘reflog_parse’,
    inlined from ‘refdb_reflog_fs__read’ at src/libgit2/refdb_fs.c:2090:15:
src/libgit2/refdb_fs.c:1968:20: warning: ‘c’ may be used uninitialized [-Wmaybe-uninitialized]
 1968 |                 if (c == '\t') {
      |                    ^
src/libgit2/refdb_fs.c: In function ‘refdb_reflog_fs__read’:
src/libgit2/refdb_fs.c:1949:22: note: ‘c’ was declared here
 1949 |                 char c;
      |                      ^
In function ‘git_fs_path_owner_is’,
    inlined from ‘validate_ownership_path’ at src/libgit2/repository.c:631:11,
    inlined from ‘validate_ownership’ at src/libgit2/repository.c:671:16,
    inlined from ‘git_repository_open_ext’ at src/libgit2/repository.c:1124:15:
src/util/fs_path.c:1990:45: warning: ‘sudo_uid’ may be used uninitialized [-Wmaybe-uninitialized]
 1990 |             sudo_uid_lookup(&sudo_uid) == 0 &&
      |                                             ^
src/util/fs_path.c: In function ‘git_repository_open_ext’:
src/util/fs_path.c:1959:21: note: ‘sudo_uid’ was declared here
 1959 |         uid_t euid, sudo_uid;
      |                     ^
src/libgit2/config.c: In function ‘git_config_get_multivar_foreach.constprop’:
src/libgit2/config.c:1000:23: warning: ‘iter’ may be used uninitialized [-Wmaybe-uninitialized]
 1000 |         while ((err = iter->next(&entry, iter)) == 0) {
      |                       ^
src/libgit2/config.c:993:30: note: ‘iter’ was declared here
  993 |         git_config_iterator *iter;
      |                              ^
tests/libgit2/status/worktree.c: In function ‘test_status_worktree__at_head_parent’:
tests/libgit2/status/worktree.c:1351:23: warning: ‘parent_tree’ may be used uninitialized [-Wmaybe-uninitialized]
 1351 |         opts.baseline = parent_tree;
      |                       ^
tests/libgit2/status/worktree.c:1337:19: note: ‘parent_tree’ was declared here
 1337 |         git_tree *parent_tree;
      |                   ^
In function ‘clar__assert’,
    inlined from ‘check_tree_entry’ at tests/libgit2/iterator/tree.c:270:2:
tests/clar/clar.c:708:12: warning: ‘te’ may be used uninitialized [-Wmaybe-uninitialized]
  708 |         if (condition)
      |            ^
tests/libgit2/iterator/tree.c: In function ‘check_tree_entry’:
tests/libgit2/iterator/tree.c:266:31: note: ‘te’ was declared here
  266 |         const git_tree_entry *te;
      |                               ^
tests/libgit2/iterator/tree.c: In function ‘check_tree_range’:
tests/libgit2/iterator/tree.c:371:9: warning: ‘head’ may be used uninitialized [-Wmaybe-uninitialized]
  371 |         cl_git_pass(git_iterator_for_tree(&i, head, &i_opts));
      |         ^
tests/libgit2/iterator/tree.c:360:19: note: ‘head’ was declared here
  360 |         git_tree *head;
      |                   ^
tests/libgit2/iterator/tree.c: In function ‘test_iterator_tree__icase_0’:
tests/libgit2/iterator/tree.c:418:9: warning: ‘head’ may be used uninitialized [-Wmaybe-uninitialized]
  418 |         cl_git_pass(git_iterator_for_tree(&i, head, NULL));
      |         ^
tests/libgit2/iterator/tree.c:411:19: note: ‘head’ was declared here
  411 |         git_tree *head;
      |                   ^
tests/libgit2/iterator/tree.c: In function ‘test_iterator_tree__icase_1’:
tests/libgit2/iterator/tree.c:454:9: warning: ‘head’ may be used uninitialized [-Wmaybe-uninitialized]
  454 |         cl_git_pass(git_iterator_for_tree(&i, head, &i_opts));
      |         ^
tests/libgit2/iterator/tree.c:442:19: note: ‘head’ was declared here
  442 |         git_tree *head;
      |                   ^
tests/libgit2/iterator/tree.c: In function ‘test_iterator_tree__icase_2’:
tests/libgit2/iterator/tree.c:596:9: warning: ‘head’ may be used uninitialized [-Wmaybe-uninitialized]
  596 |         cl_git_pass(git_iterator_for_tree(&i, head, NULL));
      |         ^
tests/libgit2/iterator/tree.c:545:19: note: ‘head’ was declared here
  545 |         git_tree *head;
      |                   ^
tests/libgit2/index/read_index.c: In function ‘test_index_read_index__initialize’:
tests/libgit2/index/read_index.c:19:9: warning: ‘head_ref’ may be used uninitialized [-Wmaybe-uninitialized]
   19 |         git_reference_free(head_ref);
      |         ^
tests/libgit2/index/read_index.c:12:24: note: ‘head_ref’ was declared here
   12 |         git_reference *head_ref;
      |                        ^
tests/libgit2/index/read_index.c:16:9: warning: ‘head’ may be used uninitialized [-Wmaybe-uninitialized]
   16 |         cl_git_pass(git_reset(_repo, head, GIT_RESET_HARD, NULL));
      |         ^
tests/libgit2/index/read_index.c:11:21: note: ‘head’ was declared here
   11 |         git_object *head;
      |                     ^
In function ‘reflog_parse’,
    inlined from ‘refdb_reflog_fs__read’ at src/libgit2/refdb_fs.c:2090:15:
src/libgit2/refdb_fs.c:1968:20: warning: ‘c’ may be used uninitialized [-Wmaybe-uninitialized]
 1968 |                 if (c == '\t') {
      |                    ^
src/libgit2/refdb_fs.c: In function ‘refdb_reflog_fs__read’:
src/libgit2/refdb_fs.c:1949:22: note: ‘c’ was declared here
 1949 |                 char c;
      |                      ^
In function ‘git_describe_format’,
    inlined from ‘assert_describe_workdir’ at tests/libgit2/describe/describe_helpers.c:38:2:
src/libgit2/describe.c:862:9: warning: ‘result’ may be used uninitialized [-Wmaybe-uninitialized]
  862 |         GIT_BUF_WRAP_PRIVATE(out, git_describe__format, result, given);
      |         ^
tests/libgit2/describe/describe_helpers.c: In function ‘assert_describe_workdir’:
tests/libgit2/describe/describe_helpers.c:35:30: note: ‘result’ was declared here
   35 |         git_describe_result *result;
      |                              ^
tests/libgit2/index/read_index.c: In function ‘test_index_read_index__handles_conflicts’:
tests/libgit2/index/read_index.c:199:9: warning: ‘conflict_iterator’ may be used uninitialized [-Wmaybe-uninitialized]
  199 |         cl_git_pass(git_index_conflict_next(
      |         ^
tests/libgit2/index/read_index.c:172:38: note: ‘conflict_iterator’ was declared here
  172 |         git_index_conflict_iterator *conflict_iterator;
      |                                      ^
tests/libgit2/index/tests.c: In function ‘test_index_tests__can_iterate’:
tests/libgit2/index/tests.c:1114:17: warning: ‘entry’ may be used uninitialized [-Wmaybe-uninitialized]
 1114 |                 cl_assert_equal_i(entry->file_size, test_entries[i].file_size);
      |                 ^
tests/libgit2/index/tests.c:1092:32: note: ‘entry’ was declared here
 1092 |         const git_index_entry *entry;
      |                                ^
tests/libgit2/apply/apply_helpers.c: In function ‘validate_workdir_unchanged’:
tests/libgit2/apply/apply_helpers.c:122:9: warning: ‘head’ may be used uninitialized [-Wmaybe-uninitialized]
  122 |         cl_git_pass(git_iterator_for_tree(&head_iterator, head, NULL));
      |         ^
tests/libgit2/apply/apply_helpers.c:112:19: note: ‘head’ was declared here
  112 |         git_tree *head;
      |                   ^
tests/libgit2/object/validate.c: In function ‘test_object_validate__cannot_parse_sha256_as_sha1’:
tests/libgit2/object/validate.c:75:9: warning: ‘valid’ may be used uninitialized [-Wmaybe-uninitialized]
   75 |         cl_assert_equal_i(0, valid);
      |         ^
tests/libgit2/object/validate.c:72:13: note: ‘valid’ was declared here
   72 |         int valid;
      |             ^
tests/libgit2/object/validate.c: In function ‘test_object_validate__invalid_sha1’:
tests/libgit2/object/validate.c:86:9: warning: ‘valid’ may be used uninitialized [-Wmaybe-uninitialized]
   86 |         cl_assert_equal_i(0, valid);
      |         ^
tests/libgit2/object/validate.c:83:13: note: ‘valid’ was declared here
   83 |         int valid;
      |             ^
tests/libgit2/index/conflicts.c: In function ‘test_index_conflicts__iterate’:
tests/libgit2/index/conflicts.c:224:9: warning: ‘iterator’ may be used uninitialized [-Wmaybe-uninitialized]
  224 |         cl_git_pass(git_index_conflict_next(&conflict_entry[0], &conflict_entry[1], &conflict_entry[2], iterator));
      |         ^
tests/libgit2/index/conflicts.c:218:38: note: ‘iterator’ was declared here
  218 |         git_index_conflict_iterator *iterator;
      |                                      ^
tests/libgit2/diff/workdir.c: In function ‘test_diff_workdir__larger_hunks’:
tests/libgit2/diff/workdir.c:1066:47: warning: ‘num_l’ may be used uninitialized [-Wmaybe-uninitialized]
 1066 |                                 for (l = 0; l < num_l; ++l) {
      |                                               ^
tests/libgit2/diff/workdir.c:1026:42: note: ‘num_l’ was declared here
 1026 |         size_t i, d, num_d, h, num_h, l, num_l;
      |                                          ^
tests/libgit2/win32/forbidden.c: In function ‘test_win32_forbidden__can_diff_tree_to_index’:
tests/libgit2/win32/forbidden.c:98:9: warning: ‘tree’ may be used uninitialized [-Wmaybe-uninitialized]
   98 |         cl_git_pass(git_diff_tree_to_index(&diff, repo, tree, NULL, NULL));
      |         ^
tests/libgit2/win32/forbidden.c:95:19: note: ‘tree’ was declared here
   95 |         git_tree *tree;
      |                   ^
tests/libgit2/win32/forbidden.c: In function ‘test_win32_forbidden__can_diff_tree_to_tree’:
tests/libgit2/win32/forbidden.c:110:9: warning: ‘tree’ may be used uninitialized [-Wmaybe-uninitialized]
  110 |         cl_git_pass(git_diff_tree_to_tree(&diff, repo, tree, tree, NULL));
      |         ^
tests/libgit2/win32/forbidden.c:107:19: note: ‘tree’ was declared here
  107 |         git_tree *tree;
      |                   ^
In function ‘git_object_free’,
    inlined from ‘git_commit_free’ at src/libgit2/object_api.c:33:2,
    inlined from ‘test_win32_forbidden__can_diff_index_to_workdir’ at tests/libgit2/win32/forbidden.c:134:2:
src/libgit2/object.c:290:12: warning: ‘tree’ may be used uninitialized [-Wmaybe-uninitialized]
  290 |         if (object == NULL)
      |            ^
tests/libgit2/win32/forbidden.c: In function ‘test_win32_forbidden__can_diff_index_to_workdir’:
tests/libgit2/win32/forbidden.c:121:19: note: ‘tree’ was declared here
  121 |         git_tree *tree;
      |                   ^
tests/libgit2/diff/workdir.c: In function ‘test_diff_workdir__cannot_diff_against_a_bare_repository’:
tests/libgit2/diff/workdir.c:1186:9: warning: ‘tree’ may be used uninitialized [-Wmaybe-uninitialized]
 1186 |         cl_assert_equal_i(
      |         ^
tests/libgit2/diff/workdir.c:1177:19: note: ‘tree’ was declared here
 1177 |         git_tree *tree;
      |                   ^
tests/libgit2/submodule/escape.c: In function ‘test_submodule_escape__from_gitdir’:
tests/libgit2/submodule/escape.c:62:9: warning: ‘sm_location’ may be used uninitialized [-Wmaybe-uninitialized]
   62 |         cl_assert_equal_i(GIT_SUBMODULE_STATUS_IN_INDEX | GIT_SUBMODULE_STATUS_IN_HEAD, sm_location);
      |         ^
tests/libgit2/submodule/escape.c:37:22: note: ‘sm_location’ declared here
   37 |         unsigned int sm_location;
      |                      ^
tests/libgit2/iterator/index.c: In function ‘test_iterator_index__range_icase’:
tests/libgit2/iterator/index.c:258:9: warning: ‘head’ may be used uninitialized [-Wmaybe-uninitialized]
  258 |         cl_git_pass(git_index_read_tree(index, head));
      |         ^
tests/libgit2/iterator/index.c:251:19: note: ‘head’ was declared here
  251 |         git_tree *head;
      |                   ^
tests/libgit2/submodule/escape.c: In function ‘test_submodule_escape__from_gitdir_windows’:
tests/libgit2/submodule/escape.c:96:9: warning: ‘sm_location’ may be used uninitialized [-Wmaybe-uninitialized]
   96 |         cl_assert_equal_i(GIT_SUBMODULE_STATUS_IN_INDEX | GIT_SUBMODULE_STATUS_IN_HEAD, sm_location);
      |         ^
tests/libgit2/submodule/escape.c:71:22: note: ‘sm_location’ declared here
   71 |         unsigned int sm_location;
      |                      ^
In function ‘git_odb_add_backend’,
    inlined from ‘test_odb_backend_mempack__initialize’ at tests/libgit2/odb/backend/mempack.c:18:2:
src/libgit2/odb.c:618:16: warning: ‘backend’ may be used uninitialized [-Wmaybe-uninitialized]
  618 |         return add_backend_internal(odb, backend, priority, false, 0);
      |                ^
tests/libgit2/odb/backend/mempack.c: In function ‘test_odb_backend_mempack__initialize’:
tests/libgit2/odb/backend/mempack.c:14:26: note: ‘backend’ was declared here
   14 |         git_odb_backend *backend;
      |                          ^
tests/libgit2/odb/backend/multiple.c: In function ‘test_odb_backend_multiple__initialize’:
tests/libgit2/odb/backend/multiple.c:33:22: warning: ‘backend’ may be used uninitialized [-Wmaybe-uninitialized]
   33 |         _fake_filled = (fake_backend *)backend;
      |                      ^
tests/libgit2/odb/backend/multiple.c:25:26: note: ‘backend’ was declared here
   25 |         git_odb_backend *backend;
      |                          ^
tests/libgit2/message/trailer.c: In function ‘assert_trailers’:
tests/libgit2/message/trailer.c:5:35: warning: ‘arr.trailers’ may be used uninitialized [-Wmaybe-uninitialized]
    5 |         git_message_trailer_array arr;
      |                                   ^
tests/libgit2/message/trailer.c:12:19: warning: ‘arr.count’ may be used uninitialized [-Wmaybe-uninitialized]
   12 |         for(i=0; i<arr.count; i++) {
      |                   ^
tests/libgit2/message/trailer.c:5:35: note: ‘arr.count’ was declared here
    5 |         git_message_trailer_array arr;
      |                                   ^
In function ‘git__free’,
    inlined from ‘git_message_trailer_array_free’ at src/libgit2/trailer.c:428:2,
    inlined from ‘assert_trailers’ at tests/libgit2/message/trailer.c:19:2:
src/util/alloc.h:39:9: warning: ‘arr._trailer_block’ may be used uninitialized [-Wmaybe-uninitialized]
   39 |         git__allocator.gfree(ptr);
      |         ^
tests/libgit2/message/trailer.c: In function ‘assert_trailers’:
tests/libgit2/message/trailer.c:5:35: note: ‘arr._trailer_block’ was declared here
    5 |         git_message_trailer_array arr;
      |                                   ^
In function ‘git_odb_add_backend’,
    inlined from ‘setup_backend’ at tests/libgit2/odb/backend/simple.c:19:2:
src/libgit2/odb.c:618:16: warning: ‘backend’ may be used uninitialized [-Wmaybe-uninitialized]
  618 |         return add_backend_internal(odb, backend, priority, false, 0);
      |                ^
tests/libgit2/odb/backend/simple.c: In function ‘setup_backend’:
tests/libgit2/odb/backend/simple.c:14:26: note: ‘backend’ was declared here
   14 |         git_odb_backend *backend;
      |                          ^
In function ‘git_submodule_owner’,
    inlined from ‘test_submodule_lookup__can_be_dupped’ at tests/libgit2/submodule/lookup.c:71:2:
src/libgit2/submodule.c:1063:25: warning: ‘sm_duplicate’ may be used uninitialized [-Wmaybe-uninitialized]
 1063 |         return submodule->repo;
      |                         ^
tests/libgit2/submodule/lookup.c: In function ‘test_submodule_lookup__can_be_dupped’:
tests/libgit2/submodule/lookup.c:49:24: note: ‘sm_duplicate’ was declared here
   49 |         git_submodule *sm_duplicate;
      |                        ^
In function ‘git_atomic__swap’,
    inlined from ‘set_refdb’ at src/libgit2/repository.c:114:15,
    inlined from ‘git_repository_set_refdb’ at src/libgit2/repository.c:1567:2,
    inlined from ‘test_odb_backend_nobackend__initialize’ at tests/libgit2/odb/backend/nobackend.c:21:2:
src/util/thread.h:184:9: warning: ‘refdb’ may be used uninitialized [-Wmaybe-uninitialized]
  184 |         __atomic_exchange(ptr, &newval, &foundval, __ATOMIC_SEQ_CST);
      |         ^
tests/libgit2/odb/backend/nobackend.c: In function ‘test_odb_backend_nobackend__initialize’:
tests/libgit2/odb/backend/nobackend.c:12:20: note: ‘refdb’ was declared here
   12 |         git_refdb *refdb;
      |                    ^
In function ‘git_fs_path_owner_is’,
    inlined from ‘validate_ownership_path’ at src/libgit2/repository.c:631:11,
    inlined from ‘validate_ownership’ at src/libgit2/repository.c:671:16,
    inlined from ‘git_repository_open_ext’ at src/libgit2/repository.c:1124:15:
src/util/fs_path.c:1990:45: warning: ‘sudo_uid’ may be used uninitialized [-Wmaybe-uninitialized]
 1990 |             sudo_uid_lookup(&sudo_uid) == 0 &&
      |                                             ^
src/util/fs_path.c: In function ‘git_repository_open_ext’:
src/util/fs_path.c:1959:21: note: ‘sudo_uid’ was declared here
 1959 |         uid_t euid, sudo_uid;
      |                     ^
tests/libgit2/worktree/worktree.c: In function ‘test_worktree_worktree__init’:
tests/libgit2/worktree/worktree.c:216:9: warning: ‘branch’ may be used uninitialized [-Wmaybe-uninitialized]
  216 |         git_reference_free(branch);
      |         ^
tests/libgit2/worktree/worktree.c:203:24: note: ‘branch’ declared here
  203 |         git_reference *branch;
      |                        ^
In function ‘git_iterator_for_workdir’,
    inlined from ‘test_iterator_workdir__bounded_submodules’ at tests/libgit2/iterator/workdir.c:1207:3:
src/libgit2/iterator.h:147:16: warning: ‘head’ may be used uninitialized [-Wmaybe-uninitialized]
  147 |         return git_iterator_for_workdir_ext(out, repo, NULL, index, tree, options);
      |                ^
tests/libgit2/iterator/workdir.c: In function ‘test_iterator_workdir__bounded_submodules’:
tests/libgit2/iterator/workdir.c:1187:19: note: ‘head’ was declared here
 1187 |         git_tree *head;
      |                   ^
In function ‘git_object_free’,
    inlined from ‘git_commit_free’ at src/libgit2/object_api.c:33:2,
    inlined from ‘test_checkout_index__initialize’ at tests/libgit2/checkout/index.c:23:2:
src/libgit2/object.c:290:12: warning: ‘tree’ may be used uninitialized [-Wmaybe-uninitialized]
  290 |         if (object == NULL)
      |            ^
tests/libgit2/checkout/index.c: In function ‘test_checkout_index__initialize’:
tests/libgit2/checkout/index.c:16:19: note: ‘tree’ was declared here
   16 |         git_tree *tree;
      |                   ^
In function ‘git_reference_iterator_new’,
    inlined from ‘test_refs_iterator__empty’ at tests/libgit2/refs/iterator.c:134:2:
src/libgit2/refs.c:752:13: warning: ‘empty’ may be used uninitialized [-Wmaybe-uninitialized]
  752 |         if (git_repository_refdb__weakptr(&refdb, repo) < 0)
      |             ^
tests/libgit2/refs/iterator.c: In function ‘test_refs_iterator__empty’:
tests/libgit2/refs/iterator.c:129:25: note: ‘empty’ was declared here
  129 |         git_repository *empty;
      |                         ^
In function ‘memcpy’,
    inlined from ‘git_oid_raw_cpy’ at src/libgit2/oid.h:202:2,
    inlined from ‘git_oid_cpy’ at src/libgit2/oid.c:240:9,
    inlined from ‘dup_reflog’ at src/libgit2/transaction.c:264:3,
    inlined from ‘git_transaction_set_reflog’ at src/libgit2/transaction.c:290:15,
    inlined from ‘git_stash_drop’ at src/libgit2/stash.c:1252:15:
/usr/include/bits/string_fortified.h:29:10: warning: ‘__builtin_memcpy’ reading 20 bytes from a region of size 0 [-Wstringop-overread]
   29 |   return __builtin___memcpy_chk (__dest, __src, __len,
      |          ^
In function ‘git_stash_drop’:
lto1: note: source object is likely at address zero
tests/libgit2/worktree/worktree.c: In function ‘test_worktree_worktree__add_locked’:
tests/libgit2/worktree/worktree.c:241:9: warning: ‘branch’ may be used uninitialized [-Wmaybe-uninitialized]
  241 |         git_reference_free(branch);
      |         ^
tests/libgit2/worktree/worktree.c:224:24: note: ‘branch’ declared here
  224 |         git_reference *branch;
      |                        ^
tests/libgit2/diff/index.c: In function ‘test_diff_index__to_index’:
tests/libgit2/diff/index.c:291:9: warning: ‘diff’ may be used uninitialized [-Wmaybe-uninitialized]
  291 |         cl_git_pass(git_diff_foreach(
      |         ^
tests/libgit2/diff/index.c:279:19: note: ‘diff’ was declared here
  279 |         git_diff *diff;
      |                   ^
In function ‘git_grafts_get’,
    inlined from ‘test_grafts_shallow__shallow_oids’ at tests/libgit2/grafts/shallow.c:55:2:
src/libgit2/grafts.c:241:21: warning: ‘grafts’ may be used uninitialized [-Wmaybe-uninitialized]
  241 |         if ((*out = git_oidmap_get(grafts->commits, oid)) == NULL)
      |                     ^
tests/libgit2/grafts/shallow.c: In function ‘test_grafts_shallow__shallow_oids’:
tests/libgit2/grafts/shallow.c:49:21: note: ‘grafts’ was declared here
   49 |         git_grafts *grafts;
      |                     ^
tests/libgit2/diff/submodules.c: In function ‘test_diff_submodules__dirty_submodule_2’:
tests/libgit2/diff/submodules.c:157:17: warning: ‘head’ may be used uninitialized [-Wmaybe-uninitialized]
  157 |                 cl_git_pass(git_diff_tree_to_index(&diff2, g_repo, head, NULL, &opts));
      |                 ^
tests/libgit2/diff/submodules.c:154:27: note: ‘head’ was declared here
  154 |                 git_tree *head;
      |                           ^
tests/libgit2/diff/submodules.c: In function ‘test_diff_submodules__submod2_head_to_index’:
tests/libgit2/diff/submodules.c:222:9: warning: ‘head’ may be used uninitialized [-Wmaybe-uninitialized]
  222 |         cl_git_pass(git_diff_tree_to_index(&diff, g_repo, head, NULL, &opts));
      |         ^
tests/libgit2/diff/submodules.c:207:19: note: ‘head’ was declared here
  207 |         git_tree *head;
      |                   ^
tests/libgit2/grafts/shallow.c: In function ‘test_grafts_shallow__errors_on_borked’:
tests/libgit2/grafts/shallow.c:94:9: warning: ‘grafts’ may be used uninitialized [-Wmaybe-uninitialized]
   94 |         cl_git_fail(git_grafts_refresh(grafts));
      |         ^
tests/libgit2/grafts/shallow.c:88:21: note: ‘grafts’ was declared here
   88 |         git_grafts *grafts;
      |                     ^
In function ‘git_grafts_get’,
    inlined from ‘test_grafts_shallow__cache_clearing’ at tests/libgit2/grafts/shallow.c:69:2:
src/libgit2/grafts.c:241:21: warning: ‘grafts’ may be used uninitialized [-Wmaybe-uninitialized]
  241 |         if ((*out = git_oidmap_get(grafts->commits, oid)) == NULL)
      |                     ^
tests/libgit2/grafts/shallow.c: In function ‘test_grafts_shallow__cache_clearing’:
tests/libgit2/grafts/shallow.c:61:21: note: ‘grafts’ was declared here
   61 |         git_grafts *grafts;
      |                     ^
In function ‘merge_preference’,
    inlined from ‘git_merge_analysis_for_ref’ at src/libgit2/merge.c:3265:15,
    inlined from ‘analysis_from_branch’ at tests/libgit2/merge/analysis.c:74:2:
src/libgit2/merge.c:3236:9: warning: ‘config’ may be used uninitialized [-Wmaybe-uninitialized]
 3236 |         git_config_free(config);
      |         ^
src/libgit2/merge.c: In function ‘analysis_from_branch’:
src/libgit2/merge.c:3209:21: note: ‘config’ declared here
 3209 |         git_config *config;
      |                     ^
In function ‘git_object_id’,
    inlined from ‘git_commit_id’ at src/libgit2/object_api.c:38:9,
    inlined from ‘test_graph_ahead_behind__returns_correct_result’ at tests/libgit2/graph/ahead_behind.c:43:2:
src/libgit2/object.c:298:9: warning: ‘other’ may be used uninitialized [-Wmaybe-uninitialized]
  298 |         GIT_ASSERT_ARG_WITH_RETVAL(obj, NULL);
      |         ^
tests/libgit2/graph/ahead_behind.c: In function ‘test_graph_ahead_behind__returns_correct_result’:
tests/libgit2/graph/ahead_behind.c:30:21: note: ‘other’ was declared here
   30 |         git_commit *other;
      |                     ^
tests/libgit2/diff/patch.c: In function ‘test_diff_patch__hunks_have_correct_line_numbers’:
tests/libgit2/diff/patch.c:288:9: warning: ‘head’ may be used uninitialized [-Wmaybe-uninitialized]
  288 |         cl_git_pass(git_diff_tree_to_workdir(&diff, g_repo, head, &opt));
      |         ^
tests/libgit2/diff/patch.c:262:19: note: ‘head’ was declared here
  262 |         git_tree *head;
      |                   ^
In function ‘git_config_next’,
    inlined from ‘test_config_read__iterator’ at tests/libgit2/config/read.c:366:16:
src/libgit2/config.c:1117:16: warning: ‘iter’ may be used uninitialized [-Wmaybe-uninitialized]
 1117 |         return iter->next(entry, iter);
      |                ^
tests/libgit2/config/read.c: In function ‘test_config_read__iterator’:
tests/libgit2/config/read.c:353:30: note: ‘iter’ was declared here
  353 |         git_config_iterator *iter;
      |                              ^
tests/libgit2/rebase/inmemory.c: In function ‘test_rebase_inmemory__can_resolve_conflicts’:
tests/libgit2/rebase/inmemory.c:91:9: warning: ‘rebase_index’ may be used uninitialized [-Wmaybe-uninitialized]
   91 |         cl_assert(git_index_has_conflicts(rebase_index));
      |         ^
tests/libgit2/rebase/inmemory.c:61:20: note: ‘rebase_index’ was declared here
   61 |         git_index *rebase_index, *repo_index;
      |                    ^
tests/libgit2/apply/apply_helpers.c: In function ‘validate_index_unchanged’:
tests/libgit2/apply/apply_helpers.c:95:9: warning: ‘head’ may be used uninitialized [-Wmaybe-uninitialized]
   95 |         cl_git_pass(git_iterator_for_tree(&head_iterator, head, NULL));
      |         ^
tests/libgit2/apply/apply_helpers.c:88:19: note: ‘head’ was declared here
   88 |         git_tree *head;
      |                   ^
In function ‘git_object_id’,
    inlined from ‘git_commit_id’ at src/libgit2/object_api.c:38:9,
    inlined from ‘test_graph_descendant_of__returns_correct_result’ at tests/libgit2/graph/descendant_of.c:34:2:
src/libgit2/object.c:298:9: warning: ‘other’ may be used uninitialized [-Wmaybe-uninitialized]
  298 |         GIT_ASSERT_ARG_WITH_RETVAL(obj, NULL);
      |         ^
tests/libgit2/graph/descendant_of.c: In function ‘test_graph_descendant_of__returns_correct_result’:
tests/libgit2/graph/descendant_of.c:27:21: note: ‘other’ was declared here
   27 |         git_commit *other;
      |                     ^
tests/libgit2/diff/tree.c: In function ‘test_diff_tree__larger_hunks’:
tests/libgit2/diff/tree.c:283:39: warning: ‘num_l’ may be used uninitialized [-Wmaybe-uninitialized]
  283 |                         for (l = 0; l < num_l; ++l) {
      |                                       ^
tests/libgit2/diff/tree.c:259:39: note: ‘num_l’ was declared here
  259 |         size_t d, num_d, h, num_h, l, num_l;
      |                                       ^
In function ‘git_regexp_match’,
    inlined from ‘git_config_backend_foreach_match’ at src/libgit2/config.c:532:17:
src/util/regexp.c:37:22: warning: ‘regex’ may be used uninitialized [-Wmaybe-uninitialized]
   37 |         if ((error = pcre_exec(*r, NULL, string, (int) strlen(string), 0, 0, NULL, 0)) < 0)
      |                      ^
src/libgit2/config.c: In function ‘git_config_backend_foreach_match’:
src/libgit2/config.c:516:20: note: ‘regex’ was declared here
  516 |         git_regexp regex;
      |                    ^

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the warning summary with the rpmbuild command shown in the issue, then group the diagnostics by source file. Start with the listed locations such as src/util/regexp.c, src/util/fs_path.c, src/libgit2/refdb_fs.c, and the affected test files. Done means the reported -Wmaybe-uninitialized diagnostics and the other listed warnings are addressed without breaking the test suite.

Written by the indexing model from the issue text.

Assessment

Tech stack
c
Domain
build-system, tooling
Issue type
Refactor
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.