summaryrefslogtreecommitdiff
path: root/src/refs.c
diff options
context:
space:
mode:
authorArkadiy Shapkin <ashapkin@artec-group.com>2013-03-17 04:46:46 +0400
committerArkadiy Shapkin <ashapkin@artec-group.com>2013-03-18 03:30:26 +0400
commit10c06114cbb1c384b7de3cca6d6601ee750f5178 (patch)
tree05b4c66610443dd41b50114480da9e8b7e99a123 /src/refs.c
parenta5f6138407efb6d8866fe8de5aac13454aefcd82 (diff)
downloadlibgit2-10c06114cbb1c384b7de3cca6d6601ee750f5178.tar.gz
Several warnings detected by static code analyzer fixed
Implicit type conversion argument of function to size_t type Suspicious sequence of types castings: size_t -> int -> size_t Consider reviewing the expression of the 'A = B == C' kind. The expression is calculated as following: 'A = (B == C)' Unsigned type is never < 0
Diffstat (limited to 'src/refs.c')
-rw-r--r--src/refs.c17
1 files changed, 12 insertions, 5 deletions
diff --git a/src/refs.c b/src/refs.c
index 41c6fd838..dde2f51a9 100644
--- a/src/refs.c
+++ b/src/refs.c
@@ -440,6 +440,7 @@ int git_reference_rename(
git_oid *oid;
const char *symbolic;
int error = 0;
+ int reference_has_log;
*out = NULL;
@@ -465,11 +466,13 @@ int git_reference_rename(
return -1;
/* Check if we have to update HEAD. */
- if ((should_head_be_updated = git_branch_is_head(ref)) < 0)
+ if ((error = git_branch_is_head(ref)) < 0)
goto on_error;
+ should_head_be_updated = (error > 0);
+
/* Now delete the old ref and save the new one. */
- if (git_refdb_delete(ref->db, ref) < 0)
+ if ((error = git_refdb_delete(ref->db, ref)) < 0)
goto on_error;
/* Save the new reference. */
@@ -477,14 +480,18 @@ int git_reference_rename(
goto rollback;
/* Update HEAD it was poiting to the reference being renamed. */
- if (should_head_be_updated && git_repository_set_head(ref->db->repo, new_name) < 0) {
+ if (should_head_be_updated && (error = git_repository_set_head(ref->db->repo, new_name)) < 0) {
giterr_set(GITERR_REFERENCE, "Failed to update HEAD after renaming reference");
goto on_error;
}
/* Rename the reflog file, if it exists. */
- if (git_reference_has_log(ref) &&
- (error = git_reflog_rename(ref, new_name)) < 0)
+ reference_has_log = git_reference_has_log(ref);
+ if (reference_has_log < 0) {
+ error = reference_has_log;
+ goto on_error;
+ }
+ if (reference_has_log && (error = git_reflog_rename(ref, new_name)) < 0)
goto on_error;
*out = result;