global: trivial conversions to fix -Wsign-compare warnings

We have a bunch of loops which iterate up to an unsigned boundary using
a signed index, which generates warnigs because we compare a signed and
unsigned value in the loop condition. Address these sites for trivial
cases and enable `-Wsign-compare` warnings for these code units.

This patch only adapts those code units where we can drop the
`DISABLE_SIGN_COMPARE_WARNINGS` macro in the same step.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Patrick Steinhardt
2024-12-06 11:27:24 +01:00
committed by Junio C Hamano
parent 25435e4ad8
commit 80c9e70ebe
55 changed files with 105 additions and 238 deletions

View File

@@ -1,5 +1,3 @@
#define DISABLE_SIGN_COMPARE_WARNINGS
#include "git-compat-util.h"
#include "advice.h"
#include "config.h"
@@ -162,7 +160,6 @@ void advise_if_enabled(enum advice_type type, const char *advice, ...)
int git_default_advice_config(const char *var, const char *value)
{
const char *k, *slot_name;
int i;
if (!strcmp(var, "color.advice")) {
advice_use_color = git_config_colorbool(var, value);
@@ -181,7 +178,7 @@ int git_default_advice_config(const char *var, const char *value)
if (!skip_prefix(var, "advice.", &k))
return 0;
for (i = 0; i < ARRAY_SIZE(advice_setting); i++) {
for (size_t i = 0; i < ARRAY_SIZE(advice_setting); i++) {
if (strcasecmp(k, advice_setting[i].key))
continue;
advice_setting[i].level = git_config_bool(var, value)
@@ -195,9 +192,7 @@ int git_default_advice_config(const char *var, const char *value)
void list_config_advices(struct string_list *list, const char *prefix)
{
int i;
for (i = 0; i < ARRAY_SIZE(advice_setting); i++)
for (size_t i = 0; i < ARRAY_SIZE(advice_setting); i++)
list_config_item(list, prefix, advice_setting[i].key);
}