summaryrefslogtreecommitdiff
path: root/src/checkout.c
diff options
context:
space:
mode:
authorRussell Belfer <rb@github.com>2013-02-15 16:02:45 -0800
committerRussell Belfer <rb@github.com>2013-02-15 16:02:45 -0800
commit56543a609aa7adb14b308046445ddd48f44322b7 (patch)
treeda381d33ee3e01de4f957bf748dacb749a55be3a /src/checkout.c
parent71d62d3905723c0263ca00a1d68825e2c35fb987 (diff)
downloadlibgit2-56543a609aa7adb14b308046445ddd48f44322b7.tar.gz
Clear up warnings from cppcheck
The cppcheck static analyzer generates warnings for a bunch of places in the libgit2 code base. All the ones fixed in this commit are actually false positives, but I've reorganized the code to hopefully make it easier for static analysis tools to correctly understand the structure. I wouldn't do this if I felt like it was making the code harder to read or worse for humans, but in this case, these fixes don't seem too bad and will hopefully make it easier for better analysis tools to get at any real issues.
Diffstat (limited to 'src/checkout.c')
-rw-r--r--src/checkout.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/src/checkout.c b/src/checkout.c
index 0ce283beb..59cd218a9 100644
--- a/src/checkout.c
+++ b/src/checkout.c
@@ -64,6 +64,7 @@ static int checkout_notify(
{
git_diff_file wdfile;
const git_diff_file *baseline = NULL, *target = NULL, *workdir = NULL;
+ const char *path = NULL;
if (!data->opts.notify_cb)
return 0;
@@ -81,6 +82,8 @@ static int checkout_notify(
wdfile.mode = wditem->mode;
workdir = &wdfile;
+
+ path = wditem->path;
}
if (delta) {
@@ -101,11 +104,12 @@ static int checkout_notify(
baseline = &delta->old_file;
break;
}
+
+ path = delta->old_file.path;
}
return data->opts.notify_cb(
- why, delta ? delta->old_file.path : wditem->path,
- baseline, target, workdir, data->opts.notify_payload);
+ why, path, baseline, target, workdir, data->opts.notify_payload);
}
static bool checkout_is_workdir_modified(
@@ -683,7 +687,7 @@ static int blob_content_to_file(
{
int error = -1, nb_filters = 0;
mode_t file_mode = opts->file_mode;
- bool dont_free_filtered = false;
+ bool dont_free_filtered;
git_buf unfiltered = GIT_BUF_INIT, filtered = GIT_BUF_INIT;
git_vector filters = GIT_VECTOR_INIT;