summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPatrick Steinhardt <ps@pks.im>2017-05-03 12:15:12 +0200
committerPatrick Steinhardt <ps@pks.im>2017-05-15 07:34:03 +0200
commit7776db51bbc0256b994f4b4037213938af6c4d73 (patch)
treed3957519730cc76d510f7d11878127e41baab895
parent1b6ab16fa5ab1b3f827045a3a9181519281f9892 (diff)
downloadlibgit2-7776db51bbc0256b994f4b4037213938af6c4d73.tar.gz
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.
-rw-r--r--src/odb.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/odb.c b/src/odb.c
index 3090ccaac..f28152bff 100644
--- a/src/odb.c
+++ b/src/odb.c
@@ -1002,7 +1002,7 @@ static int odb_read_1(git_odb_object **out, git_odb *db, const git_oid *id,
git_odb_object *object;
git_oid hashed;
bool found = false;
- int error;
+ int error = 0;
if (!only_refreshed && odb_read_hardcoded(&raw, id) == 0)
found = true;
@@ -1099,7 +1099,7 @@ static int read_prefix_1(git_odb_object **out, git_odb *db,
const git_oid *key, size_t len, bool only_refreshed)
{
size_t i;
- int error;
+ int error = 0;
git_oid found_full_oid = {{0}};
git_rawobj raw = {0};
void *data = NULL;