diff options
author | Patrick Steinhardt <ps@pks.im> | 2024-12-06 11:27:24 +0100 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2024-12-06 12:20:04 +0100 |
commit | 80c9e70ebe871f0826bc101142c66ff783405100 (patch) | |
tree | c95f04cef2dc0abb2d1fe8e4470e9e385e637b12 /diagnose.c | |
parent | pkt-line: fix -Wsign-compare warning on 32 bit platform (diff) | |
download | git-80c9e70ebe871f0826bc101142c66ff783405100.tar.xz git-80c9e70ebe871f0826bc101142c66ff783405100.zip |
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>
Diffstat (limited to 'diagnose.c')
-rw-r--r-- | diagnose.c | 8 |
1 files changed, 3 insertions, 5 deletions
diff --git a/diagnose.c b/diagnose.c index f340996e27..b11931df86 100644 --- a/diagnose.c +++ b/diagnose.c @@ -1,5 +1,4 @@ #define USE_THE_REPOSITORY_VARIABLE -#define DISABLE_SIGN_COMPARE_WARNINGS #include "git-compat-util.h" #include "diagnose.h" @@ -32,7 +31,6 @@ static struct diagnose_option diagnose_options[] = { int option_parse_diagnose(const struct option *opt, const char *arg, int unset) { - int i; enum diagnose_mode *diagnose = opt->value; if (!arg) { @@ -40,7 +38,7 @@ int option_parse_diagnose(const struct option *opt, const char *arg, int unset) return 0; } - for (i = 0; i < ARRAY_SIZE(diagnose_options); i++) { + for (size_t i = 0; i < ARRAY_SIZE(diagnose_options); i++) { if (!strcmp(arg, diagnose_options[i].option_name)) { *diagnose = diagnose_options[i].mode; return 0; @@ -187,7 +185,7 @@ int create_diagnostics_archive(struct strbuf *zip_path, enum diagnose_mode mode) char **argv_copy = NULL; int stdout_fd = -1, archiver_fd = -1; struct strbuf buf = STRBUF_INIT; - int res, i; + int res; struct archive_dir archive_dirs[] = { { ".git", 0 }, { ".git/hooks", 0 }, @@ -240,7 +238,7 @@ int create_diagnostics_archive(struct strbuf *zip_path, enum diagnose_mode mode) /* Only include this if explicitly requested */ if (mode == DIAGNOSE_ALL) { - for (i = 0; i < ARRAY_SIZE(archive_dirs); i++) { + for (size_t i = 0; i < ARRAY_SIZE(archive_dirs); i++) { if (add_directory_to_archiver(&archiver_args, archive_dirs[i].path, archive_dirs[i].recursive)) { |