diff options
Diffstat (limited to 'git.c')
-rw-r--r-- | git.c | 21 |
1 files changed, 9 insertions, 12 deletions
@@ -284,7 +284,7 @@ file **get_branch_commits(git_branch *br) { return NULL; } -int is_valid_index(index *idx, char **reason) { +int is_valid_index(index *idx) { int did_alloc = 0; char *err_str = NULL; @@ -303,13 +303,16 @@ int is_valid_index(index *idx, char **reason) { /* Did we get an error? */ if (err_str != NULL) { - *reason = err_str; - /* Return -1 if error string was allocated, and false if not. */ - return (did_alloc) ? -1 : 0; + log_reason(LOG_ERR, "Invalid index.", reason); + if (did_alloc) { + free(err_str); + } + /* Invalid index, return false. */ + return 0; /* Is there another index after this one? */ } else if (idx->next != NULL) { /* Return the validity of the next index. */ - return is_valid_index(idx->next, reason); + return is_valid_index(idx->next); } /* Valid index, return true. */ return 1; @@ -320,13 +323,7 @@ char *make_index_path(const char *root, index *idx, int path_type) { char *tmp; int path_len = strlen(root) + 1; /* Is the index invalid? */ - const int valid_index = is_valid_index(idx, &reason); - if (valid_index <= 0) { - log_reason(LOG_NOTICE, "Invalid index.", reason); - /* Was the reason string allocated? */ - if (valid_index < 0) { - free(reason); - } + if (!is_valid_index(idx)) { return NULL; } |