summaryrefslogtreecommitdiff
path: root/git.c
diff options
context:
space:
mode:
authormrb0nk500 <b0nk@b0nk.xyz>2022-07-24 20:33:41 -0300
committermrb0nk500 <b0nk@b0nk.xyz>2022-07-24 20:34:58 -0300
commit6fec7170544009fe3ce95b0d2b7e6ab65c97922d (patch)
tree2f9efb0b000e7995a13ba0ddb3f9a68f05131fbc /git.c
parentb71a05e0bacff4f03fe75fba22197c3100d58c09 (diff)
git: Remove reason string reference from `is_valid_index()`
Diffstat (limited to 'git.c')
-rw-r--r--git.c21
1 files changed, 9 insertions, 12 deletions
diff --git a/git.c b/git.c
index af188d7..ff3a574 100644
--- a/git.c
+++ b/git.c
@@ -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;
}