From: Eiji Uchiyama <eijiuchiyama@xxxxxxxxxx> This is an initial contribution to git, based on the SoC 2025 ideas for microprojects. It removes the DISABLE_SIGN_COMPARE_WARNINGS macro and solves the warnings generated by running make DEVELOPER=1 -j4 Signed-off-by: Lucas Eiji Uchiyama <eijiuchiyama@xxxxxx> --- add-interactive.c | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/add-interactive.c b/add-interactive.c index 97ff35b6f1..3a0c44c47f 100644 --- a/add-interactive.c +++ b/add-interactive.c @@ -1,5 +1,3 @@ -#define DISABLE_SIGN_COMPARE_WARNINGS - #include "git-compat-util.h" #include "add-interactive.h" #include "color.h" @@ -213,10 +211,10 @@ static ssize_t find_unique(const char *string, struct prefix_item_list *list) else if (index > 0 && starts_with(list->sorted.items[index - 1].string, string)) return -1; - else if (index + 1 < list->sorted.nr && + else if (index + 1 < (long int)(list->sorted.nr) && starts_with(list->sorted.items[index + 1].string, string)) return -1; - else if (index < list->sorted.nr && + else if (index < (long int)(list->sorted.nr) && starts_with(list->sorted.items[index].string, string)) item = list->sorted.items[index].util; else @@ -244,7 +242,7 @@ static void list(struct add_i_state *s, struct string_list *list, int *selected, color_fprintf_ln(stdout, s->header_color, "%s", opts->header); - for (i = 0; i < list->nr; i++) { + for (i = 0; i < (long int)(list->nr); i++) { opts->print_item(i, selected ? selected[i] : 0, list->items + i, opts->print_item_data); @@ -385,7 +383,7 @@ static ssize_t list_and_choose(struct add_i_state *s, to = from + 1; } - if (from < 0 || from >= items->items.nr || + if (from < 0 || from >= (long int)(items->items.nr) || (singleton && from + 1 != to)) { color_fprintf_ln(stderr, s->error_color, _("Huh (%s)?"), p); @@ -395,7 +393,7 @@ static ssize_t list_and_choose(struct add_i_state *s, break; } - if (to > items->items.nr) + if (to > (long int)(items->items.nr)) to = items->items.nr; for (; from < to; from++) @@ -859,7 +857,7 @@ static int get_untracked_files(struct repository *r, add_pattern_list(&dir, EXC_CMDL, "--exclude option"); fill_directory(&dir, r->index, ps); - for (i = 0; i < dir.nr; i++) { + for (i = 0; (long int)(i) < dir.nr; i++) { struct dir_entry *ent = dir.entries[i]; if (index_name_is_other(r->index, ent->name, ent->len)) { @@ -939,7 +937,7 @@ static int run_patch(struct add_i_state *s, const struct pathspec *ps, return -1; if (unmerged_count || binary_count) { - for (i = j = 0; i < files->items.nr; i++) { + for (i = j = 0; i < (long int)(files->items.nr); i++) { struct file_item *item = files->items.items[i].util; if (item->index.binary || item->worktree.binary) { @@ -972,7 +970,7 @@ static int run_patch(struct add_i_state *s, const struct pathspec *ps, struct strvec args = STRVEC_INIT; struct pathspec ps_selected = { 0 }; - for (i = 0; i < files->items.nr; i++) + for (i = 0; i < (long int)(files->items.nr); i++) if (files->selected[i]) strvec_push(&args, files->items.items[i].string); @@ -1018,7 +1016,7 @@ static int run_diff(struct add_i_state *s, const struct pathspec *ps, oid_to_hex(!is_initial ? &oid : s->r->hash_algo->empty_tree), "--", NULL); - for (i = 0; i < files->items.nr; i++) + for (i = 0; i < (long int)(files->items.nr); i++) if (files->selected[i]) strvec_push(&cmd.args, files->items.items[i].string); @@ -1146,7 +1144,7 @@ int run_add_i(struct repository *r, const struct pathspec *ps) ssize_t i; int res = 0; - for (i = 0; i < ARRAY_SIZE(command_list); i++) { + for (i = 0; i < (long int)(ARRAY_SIZE(command_list)); i++) { struct command_item *util = xcalloc(1, sizeof(*util)); util->command = command_list[i].command; string_list_append(&commands.items, command_list[i].string) @@ -1183,7 +1181,7 @@ int run_add_i(struct repository *r, const struct pathspec *ps) struct command_item *util; i = list_and_choose(&s, &commands, &main_loop_opts); - if (i < 0 || i >= commands.items.nr) + if (i < 0 || i >= (long int)(commands.items.nr)) util = NULL; else util = commands.items.items[i].util; -- 2.34.1