summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorRussell Belfer <rb@github.com>2012-11-09 14:01:44 -0800
committerRussell Belfer <rb@github.com>2012-11-09 14:01:44 -0800
commit757b406504021b3a73e52ce9f95d590d65c7dce5 (patch)
tree8603837628030ae68b3bbc054f9bcf55eae53f43 /src
parent0f3def715dc9af442f5f025c50a041c6319df1e8 (diff)
downloadlibgit2-757b406504021b3a73e52ce9f95d590d65c7dce5.tar.gz
Fix warnings and valgrind issues
This fixes some various warnings that showed up in Travis and a couple uses of uninitialized memory and one memory leak.
Diffstat (limited to 'src')
-rw-r--r--src/checkout.c8
-rw-r--r--src/index.c2
-rw-r--r--src/pack-objects.c12
-rw-r--r--src/transports/http.c2
4 files changed, 15 insertions, 9 deletions
diff --git a/src/checkout.c b/src/checkout.c
index 8d164cfca..0d14e2625 100644
--- a/src/checkout.c
+++ b/src/checkout.c
@@ -432,8 +432,8 @@ static int checkout_get_actions(
int error;
git_diff_list *diff = data->diff;
git_diff_delta *delta;
- size_t i, *counts;
- uint32_t *actions;
+ size_t i, *counts = NULL;
+ uint32_t *actions = NULL;
git_tree *head = NULL;
git_iterator *hiter = NULL;
char *pfx = git_pathspec_prefix(&data->opts->paths);
@@ -456,6 +456,7 @@ static int checkout_get_actions(
goto fail;
git__free(pfx);
+ pfx = NULL;
*counts_ptr = counts = git__calloc(CHECKOUT_ACTION__MAX+1, sizeof(size_t));
*actions_ptr = actions = git__calloc(diff->deltas.length, sizeof(uint32_t));
@@ -509,6 +510,8 @@ static int checkout_get_actions(
}
git_iterator_free(hiter);
+ git_tree_free(head);
+
return 0;
fail:
@@ -518,6 +521,7 @@ fail:
git__free(actions);
git_iterator_free(hiter);
+ git_tree_free(head);
git__free(pfx);
return -1;
diff --git a/src/index.c b/src/index.c
index 0ae1b4479..43244494a 100644
--- a/src/index.c
+++ b/src/index.c
@@ -402,7 +402,7 @@ int git_index_read(git_index *index)
{
int error = 0, updated;
git_buf buffer = GIT_BUF_INIT;
- git_futils_filestamp stamp;
+ git_futils_filestamp stamp = {0};
if (!index->index_file_path) {
giterr_set(GITERR_INDEX,
diff --git a/src/pack-objects.c b/src/pack-objects.c
index 7acc93328..af7472aff 100644
--- a/src/pack-objects.c
+++ b/src/pack-objects.c
@@ -73,16 +73,16 @@ static int packbuilder_config(git_packbuilder *pb)
{
git_config *config;
int ret;
+ int64_t val;
if (git_repository_config__weakptr(&config, pb->repo) < 0)
return -1;
-#define config_get(key, dst, default) \
- ret = git_config_get_int64((int64_t *)&dst, config, key); \
- if (ret == GIT_ENOTFOUND) \
- dst = default; \
- else if (ret < 0) \
- return -1;
+#define config_get(KEY,DST,DFLT) do { \
+ ret = git_config_get_int64(&val, config, KEY); \
+ if (!ret) (DST) = val; \
+ else if (ret == GIT_ENOTFOUND) (DST) = (DFLT); \
+ else if (ret < 0) return -1; } while (0)
config_get("pack.deltaCacheSize", pb->max_delta_cache_size,
GIT_PACK_DELTA_CACHE_SIZE);
diff --git a/src/transports/http.c b/src/transports/http.c
index 78977f44a..34ade947a 100644
--- a/src/transports/http.c
+++ b/src/transports/http.c
@@ -629,6 +629,8 @@ int git_smart_subtransport_http(git_smart_subtransport **out,
http_subtransport *t;
int flags;
+ (void)flags;
+
if (!out)
return -1;