Skip to content

Commit 7776db5

Browse files
committed
odb: shut up gcc warnings regarding uninitilized variables
The `error` variable is used as a return value in the out-section of both `odb_read_1` and `read_prefix_1`. While the value will actually always be initialized inside of this section, GCC fails to realize this due to interactions with the `found` variable: if `found` is set, the error will always be initialized. If it is not, we return early without reaching the out-statements. Shut up the warnings by initializing the error variable, even though it is unnecessary.
1 parent 1b6ab16 commit 7776db5

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/odb.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1002,7 +1002,7 @@ static int odb_read_1(git_odb_object **out, git_odb *db, const git_oid *id,
10021002
git_odb_object *object;
10031003
git_oid hashed;
10041004
bool found = false;
1005-
int error;
1005+
int error = 0;
10061006

10071007
if (!only_refreshed && odb_read_hardcoded(&raw, id) == 0)
10081008
found = true;
@@ -1099,7 +1099,7 @@ static int read_prefix_1(git_odb_object **out, git_odb *db,
10991099
const git_oid *key, size_t len, bool only_refreshed)
11001100
{
11011101
size_t i;
1102-
int error;
1102+
int error = 0;
11031103
git_oid found_full_oid = {{0}};
11041104
git_rawobj raw = {0};
11051105
void *data = NULL;

0 commit comments

Comments
 (0)