summaryrefslogtreecommitdiff
path: root/src/diff_output.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/diff_output.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/diff_output.c')
-rw-r--r--src/diff_output.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/src/diff_output.c b/src/diff_output.c
index 26b073aad..88ccc9d45 100644
--- a/src/diff_output.c
+++ b/src/diff_output.c
@@ -1280,14 +1280,15 @@ static void set_data_from_buffer(
{
file->size = (git_off_t)buffer_len;
file->mode = 0644;
+ map->len = buffer_len;
- if (!buffer)
+ if (!buffer) {
file->flags |= GIT_DIFF_FILE_NO_DATA;
- else
+ map->data = NULL;
+ } else {
+ map->data = (char *)buffer;
git_odb_hash(&file->oid, buffer, buffer_len, GIT_OBJ_BLOB);
-
- map->len = buffer_len;
- map->data = (char *)buffer;
+ }
}
typedef struct {