From 56543a609aa7adb14b308046445ddd48f44322b7 Mon Sep 17 00:00:00 2001 From: Russell Belfer Date: Fri, 15 Feb 2013 16:02:45 -0800 Subject: 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. --- src/diff_output.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'src/diff_output.c') 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 { -- cgit v1.2.1