summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorRussell Belfer <rb@github.com>2012-08-24 12:19:22 -0700
committerRussell Belfer <rb@github.com>2012-08-24 12:19:22 -0700
commit97a17e4e9fa5cafa531ff79cb88a9ee5c224a613 (patch)
treec45a8400538c843c74095ea30fd22e50caa1c502 /src
parent5f4a61aea834fe25ce1596bc9c0e0b5e563aa98b (diff)
downloadlibgit2-97a17e4e9fa5cafa531ff79cb88a9ee5c224a613.tar.gz
Fix valgrind warnings and spurious error messages
Just clean up valgrind warnings about uninitialized memory and also clear out errno in some cases where it results in a false error message being generated at a later point.
Diffstat (limited to 'src')
-rw-r--r--src/checkout.c15
-rw-r--r--src/errors.c5
-rw-r--r--src/filebuf.c1
-rw-r--r--src/submodule.c2
4 files changed, 16 insertions, 7 deletions
diff --git a/src/checkout.c b/src/checkout.c
index ac540391..88df2128 100644
--- a/src/checkout.c
+++ b/src/checkout.c
@@ -31,7 +31,7 @@ typedef struct tree_walk_data
git_checkout_opts *opts;
git_repository *repo;
git_odb *odb;
- bool do_symlinks;
+ bool no_symlinks;
} tree_walk_data;
@@ -48,9 +48,9 @@ static int blob_contents_to_link(tree_walk_data *data, git_buf *fnbuf,
/* Create the link */
const char *new = git_buf_cstr(&linktarget),
*old = git_buf_cstr(fnbuf);
- retcode = data->do_symlinks
- ? p_symlink(new, old)
- : git_futils_fake_symlink(new, old);
+ retcode = data->no_symlinks
+ ? git_futils_fake_symlink(new, old)
+ : p_symlink(new, old);
}
git_buf_free(&linktarget);
git_blob_free(blob);
@@ -176,13 +176,14 @@ int git_checkout_head(git_repository *repo, git_checkout_opts *opts, git_indexer
return GIT_ERROR;
}
+ memset(&payload, 0, sizeof(payload));
+
/* Determine if symlinks should be handled */
- if (!git_repository_config(&cfg, repo)) {
+ if (!git_repository_config__weakptr(&cfg, repo)) {
int temp = true;
if (!git_config_get_bool(&temp, cfg, "core.symlinks")) {
- payload.do_symlinks = !!temp;
+ payload.no_symlinks = !temp;
}
- git_config_free(cfg);
}
stats->total = stats->processed = 0;
diff --git a/src/errors.c b/src/errors.c
index d43d7d9b..802ad364 100644
--- a/src/errors.c
+++ b/src/errors.c
@@ -110,6 +110,11 @@ void giterr_set_regex(const regex_t *regex, int error_code)
void giterr_clear(void)
{
GIT_GLOBAL->last_error = NULL;
+
+ errno = 0;
+#ifdef GIT_WIN32
+ SetLastError(0);
+#endif
}
const git_error *giterr_last(void)
diff --git a/src/filebuf.c b/src/filebuf.c
index 8b3ebb3e..cfc8528e 100644
--- a/src/filebuf.c
+++ b/src/filebuf.c
@@ -50,6 +50,7 @@ static int lock_file(git_filebuf *file, int flags)
if (flags & GIT_FILEBUF_FORCE)
p_unlink(file->path_lock);
else {
+ giterr_clear(); /* actual OS error code just confuses */
giterr_set(GITERR_OS,
"Failed to lock file '%s' for writing", file->path_lock);
return -1;
diff --git a/src/submodule.c b/src/submodule.c
index 15501a1d..a9de9ee6 100644
--- a/src/submodule.c
+++ b/src/submodule.c
@@ -367,6 +367,8 @@ int git_submodule_add_to_index(git_submodule *sm, int write_index)
error = -1;
goto cleanup;
}
+
+ memset(&entry, 0, sizeof(entry));
entry.path = sm->path;
git_index__init_entry_from_stat(&st, &entry);