summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2024-12-23 09:32:10 -0800
committerJunio C Hamano <gitster@pobox.com>2024-12-23 09:32:11 -0800
commit4156b6a741c7fb15a4eccb320612fb6e453f439c (patch)
tree203f68166cc5f2337fd80f6628c3b344d2dd3abf
parentf7c607fac3dd906c46d0d86ff174215698912316 (diff)
parente03d2a9ccb88c7ff42237f5890a05e071497f8ae (diff)
Merge branch 'ps/build-sign-compare'
Start working to make the codebase buildable with -Wsign-compare. * ps/build-sign-compare: t/helper: don't depend on implicit wraparound scalar: address -Wsign-compare warnings builtin/patch-id: fix type of `get_one_patchid()` builtin/blame: fix type of `length` variable when emitting object ID gpg-interface: address -Wsign-comparison warnings daemon: fix type of `max_connections` daemon: fix loops that have mismatching integer types global: trivial conversions to fix `-Wsign-compare` warnings pkt-line: fix -Wsign-compare warning on 32 bit platform csum-file: fix -Wsign-compare warning on 32-bit platform diff.h: fix index used to loop through unsigned integer config.mak.dev: drop `-Wno-sign-compare` global: mark code units that generate warnings with `-Wsign-compare` compat/win32: fix -Wsign-compare warning in "wWinMain()" compat/regex: explicitly ignore "-Wsign-compare" warnings git-compat-util: introduce macros to disable "-Wsign-compare" warnings
-rw-r--r--add-interactive.c1
-rw-r--r--add-patch.c1
-rw-r--r--advice.c7
-rw-r--r--apply.c1
-rw-r--r--archive.c1
-rw-r--r--attr.c1
-rw-r--r--base85.c3
-rw-r--r--bisect.c1
-rw-r--r--blame.c1
-rw-r--r--bloom.c2
-rw-r--r--builtin/add.c9
-rw-r--r--builtin/am.c1
-rw-r--r--builtin/bisect.c2
-rw-r--r--builtin/blame.c11
-rw-r--r--builtin/branch.c2
-rw-r--r--builtin/cat-file.c3
-rw-r--r--builtin/checkout--worker.c2
-rw-r--r--builtin/checkout-index.c3
-rw-r--r--builtin/checkout.c2
-rw-r--r--builtin/clean.c3
-rw-r--r--builtin/clone.c3
-rw-r--r--builtin/commit.c3
-rw-r--r--builtin/describe.c2
-rw-r--r--builtin/diff-files.c3
-rw-r--r--builtin/diff-index.c2
-rw-r--r--builtin/diff-tree.c1
-rw-r--r--builtin/diff.c3
-rw-r--r--builtin/difftool.c5
-rw-r--r--builtin/fast-export.c3
-rw-r--r--builtin/fast-import.c2
-rw-r--r--builtin/fetch-pack.c2
-rw-r--r--builtin/fetch.c3
-rw-r--r--builtin/for-each-repo.c5
-rw-r--r--builtin/fsmonitor--daemon.c2
-rw-r--r--builtin/gc.c3
-rw-r--r--builtin/grep.c3
-rw-r--r--builtin/help.c6
-rw-r--r--builtin/index-pack.c2
-rw-r--r--builtin/log.c3
-rw-r--r--builtin/ls-files.c3
-rw-r--r--builtin/mailsplit.c6
-rw-r--r--builtin/merge-file.c2
-rw-r--r--builtin/merge-index.c2
-rw-r--r--builtin/merge-ours.c2
-rw-r--r--builtin/merge-tree.c6
-rw-r--r--builtin/merge.c3
-rw-r--r--builtin/mv.c2
-rw-r--r--builtin/name-rev.c2
-rw-r--r--builtin/pack-objects.c2
-rw-r--r--builtin/pack-redundant.c4
-rw-r--r--builtin/pack-refs.c1
-rw-r--r--builtin/patch-id.c16
-rw-r--r--builtin/prune.c2
-rw-r--r--builtin/pull.c4
-rw-r--r--builtin/push.c6
-rw-r--r--builtin/range-diff.c1
-rw-r--r--builtin/rebase.c3
-rw-r--r--builtin/receive-pack.c2
-rw-r--r--builtin/reflog.c1
-rw-r--r--builtin/remote.c2
-rw-r--r--builtin/repack.c2
-rw-r--r--builtin/replay.c4
-rw-r--r--builtin/rerere.c9
-rw-r--r--builtin/reset.c2
-rw-r--r--builtin/rev-list.c2
-rw-r--r--builtin/rev-parse.c3
-rw-r--r--builtin/revert.c1
-rw-r--r--builtin/rm.c3
-rw-r--r--builtin/shortlog.c1
-rw-r--r--builtin/show-branch.c2
-rw-r--r--builtin/show-index.c2
-rw-r--r--builtin/sparse-checkout.c2
-rw-r--r--builtin/stash.c7
-rw-r--r--builtin/submodule--helper.c8
-rw-r--r--builtin/tag.c3
-rw-r--r--builtin/unpack-objects.c2
-rw-r--r--builtin/update-index.c3
-rw-r--r--builtin/update-ref.c2
-rw-r--r--builtin/var.c5
-rw-r--r--builtin/worktree.c2
-rw-r--r--bulk-checkin.c1
-rw-r--r--bundle-uri.c1
-rw-r--r--bundle.c1
-rw-r--r--cache-tree.c1
-rw-r--r--chunk-format.c1
-rw-r--r--color.c2
-rw-r--r--column.c2
-rw-r--r--combine-diff.c1
-rw-r--r--commit-graph.c1
-rw-r--r--commit-reach.c1
-rw-r--r--commit.c3
-rw-r--r--compat/fsmonitor/fsm-listen-darwin.c3
-rw-r--r--compat/mingw.c1
-rw-r--r--compat/poll/poll.c2
-rw-r--r--compat/regex/regex.c2
-rw-r--r--compat/terminal.c3
-rw-r--r--compat/win32/headless.c17
-rw-r--r--compat/win32mmap.c2
-rw-r--r--compat/winansi.c2
-rw-r--r--config.c1
-rw-r--r--config.mak.dev1
-rw-r--r--connect.c1
-rw-r--r--convert.c1
-rw-r--r--credential.c1
-rw-r--r--csum-file.c2
-rw-r--r--daemon.c31
-rw-r--r--date.c2
-rw-r--r--decorate.c3
-rw-r--r--delta-islands.c1
-rw-r--r--diagnose.c7
-rw-r--r--diff-delta.c2
-rw-r--r--diff-lib.c1
-rw-r--r--diff-no-index.c2
-rw-r--r--diff.c1
-rw-r--r--diff.h3
-rw-r--r--diffcore-order.c1
-rw-r--r--diffcore-pickaxe.c3
-rw-r--r--diffcore-rename.c3
-rw-r--r--diffcore-rotate.c1
-rw-r--r--dir.c1
-rw-r--r--entry.c4
-rw-r--r--ewah/ewah_bitmap.c5
-rw-r--r--ewah/ewah_io.c3
-rw-r--r--ewah/ewah_rlw.c3
-rw-r--r--fetch-pack.c1
-rw-r--r--fmt-merge-msg.c1
-rw-r--r--fsmonitor.c1
-rw-r--r--gettext.c2
-rw-r--r--git-compat-util.h10
-rw-r--r--git.c32
-rw-r--r--gpg-interface.c14
-rw-r--r--graph.c1
-rw-r--r--grep.c2
-rw-r--r--help.c1
-rw-r--r--help.h8
-rw-r--r--hex.c6
-rw-r--r--http-backend.c1
-rw-r--r--http-push.c3
-rw-r--r--http-walker.c1
-rw-r--r--http.c1
-rw-r--r--imap-send.c1
-rw-r--r--json-writer.c2
-rw-r--r--kwset.c2
-rw-r--r--line-log.c2
-rw-r--r--list-objects-filter-options.c4
-rw-r--r--list-objects.c7
-rw-r--r--log-tree.c1
-rw-r--r--ls-refs.c4
-rw-r--r--mailinfo.c1
-rw-r--r--mailmap.c1
-rw-r--r--match-trees.c1
-rw-r--r--mem-pool.c2
-rw-r--r--merge-ll.c1
-rw-r--r--merge-ort.c1
-rw-r--r--merge-recursive.c1
-rw-r--r--merge.c4
-rw-r--r--midx-write.c2
-rw-r--r--midx.c2
-rw-r--r--name-hash.c1
-rw-r--r--notes-merge.c1
-rw-r--r--notes.c1
-rw-r--r--object-file-convert.c1
-rw-r--r--object-file.c1
-rw-r--r--object-name.c1
-rw-r--r--object.c1
-rw-r--r--oss-fuzz/fuzz-parse-attr-line.c2
-rw-r--r--pack-bitmap-write.c1
-rw-r--r--pack-bitmap.c2
-rw-r--r--pack-check.c1
-rw-r--r--packfile.c1
-rw-r--r--parallel-checkout.c1
-rw-r--r--path.c4
-rw-r--r--pathspec.c1
-rw-r--r--pkt-line.c23
-rw-r--r--preload-index.c1
-rw-r--r--pretty.c1
-rw-r--r--progress.c1
-rw-r--r--pseudo-merge.c1
-rw-r--r--quote.c2
-rw-r--r--range-diff.c1
-rw-r--r--read-cache.c1
-rw-r--r--ref-filter.c1
-rw-r--r--reflog.c1
-rw-r--r--refs.c1
-rw-r--r--refs/debug.c3
-rw-r--r--refs/files-backend.c1
-rw-r--r--refs/iterator.c2
-rw-r--r--refs/packed-backend.c1
-rw-r--r--refspec.c1
-rw-r--r--reftable/system.h2
-rw-r--r--remote-curl.c1
-rw-r--r--remote.c1
-rw-r--r--rerere.c1
-rw-r--r--resolve-undo.c1
-rw-r--r--revision.c1
-rw-r--r--run-command.c1
-rw-r--r--scalar.c6
-rw-r--r--send-pack.c5
-rw-r--r--sequencer.c1
-rw-r--r--serve.c7
-rw-r--r--server-info.c1
-rw-r--r--setup.c1
-rw-r--r--shallow.c1
-rw-r--r--sideband.c1
-rw-r--r--sparse-index.c1
-rw-r--r--split-index.c1
-rw-r--r--strbuf.c2
-rw-r--r--string-list.c2
-rw-r--r--strvec.c3
-rw-r--r--submodule-config.c1
-rw-r--r--submodule.c1
-rw-r--r--symlinks.c2
-rw-r--r--t/helper/test-bloom.c9
-rw-r--r--t/helper/test-cache-tree.c1
-rw-r--r--t/helper/test-config.c1
-rw-r--r--t/helper/test-csprng.c3
-rw-r--r--t/helper/test-drop-caches.c2
-rw-r--r--t/helper/test-dump-fsmonitor.c3
-rw-r--r--t/helper/test-dump-split-index.c3
-rw-r--r--t/helper/test-dump-untracked-cache.c6
-rw-r--r--t/helper/test-genrandom.c2
-rw-r--r--t/helper/test-genzeros.c2
-rw-r--r--t/helper/test-hash-speed.c5
-rw-r--r--t/helper/test-mergesort.c2
-rw-r--r--t/helper/test-parse-options.c5
-rw-r--r--t/helper/test-path-utils.c1
-rw-r--r--t/helper/test-reach.c3
-rw-r--r--t/helper/test-ref-store.c3
-rw-r--r--t/helper/test-run-command.c2
-rw-r--r--t/helper/test-string-list.c2
-rw-r--r--t/helper/test-tool.c3
-rw-r--r--t/helper/test-trace2.c1
-rw-r--r--t/unit-tests/lib-reftable.c2
-rw-r--r--t/unit-tests/t-example-decorate.c4
-rw-r--r--t/unit-tests/t-prio-queue.c2
-rw-r--r--t/unit-tests/t-reftable-readwrite.c2
-rw-r--r--t/unit-tests/t-reftable-stack.c2
-rw-r--r--t/unit-tests/t-trailer.c2
-rw-r--r--t/unit-tests/test-lib.c2
-rw-r--r--tag.c1
-rw-r--r--tmp-objdir.c3
-rw-r--r--trace.c1
-rw-r--r--trace2.c2
-rw-r--r--trace2/tr2_sysenv.c2
-rw-r--r--trace2/tr2_tgt_event.c2
-rw-r--r--trace2/tr2_tgt_perf.c2
-rw-r--r--trailer.c3
-rw-r--r--transport-helper.c13
-rw-r--r--transport.c13
-rw-r--r--tree-diff.c1
-rw-r--r--unix-socket.c2
-rw-r--r--unpack-trees.c1
-rw-r--r--upload-pack.c1
-rw-r--r--urlmatch.c2
-rw-r--r--usage.c3
-rw-r--r--userdiff.c1
-rw-r--r--utf8.c2
-rw-r--r--version.c3
-rw-r--r--versioncmp.c3
-rw-r--r--worktree.c1
-rw-r--r--wrapper.c3
-rw-r--r--ws.c3
-rw-r--r--wt-status.c1
-rw-r--r--xdiff-interface.c1
-rw-r--r--xdiff/xdiffi.c1
-rw-r--r--xdiff/xinclude.h2
266 files changed, 524 insertions, 235 deletions
diff --git a/add-interactive.c b/add-interactive.c
index 49042b3026..d0f8c10e6f 100644
--- a/add-interactive.c
+++ b/add-interactive.c
@@ -1,4 +1,5 @@
#define USE_THE_REPOSITORY_VARIABLE
+#define DISABLE_SIGN_COMPARE_WARNINGS
#include "git-compat-util.h"
#include "add-interactive.h"
diff --git a/add-patch.c b/add-patch.c
index 557903310d..7b598e14df 100644
--- a/add-patch.c
+++ b/add-patch.c
@@ -1,4 +1,5 @@
#define USE_THE_REPOSITORY_VARIABLE
+#define DISABLE_SIGN_COMPARE_WARNINGS
#include "git-compat-util.h"
#include "add-interactive.h"
diff --git a/advice.c b/advice.c
index e3dd8b468c..1df43b7536 100644
--- a/advice.c
+++ b/advice.c
@@ -161,7 +161,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);
@@ -180,7 +179,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)
@@ -194,9 +193,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);
}
diff --git a/apply.c b/apply.c
index a3fc2d5330..4a7b6120ac 100644
--- a/apply.c
+++ b/apply.c
@@ -8,6 +8,7 @@
*/
#define USE_THE_REPOSITORY_VARIABLE
+#define DISABLE_SIGN_COMPARE_WARNINGS
#include "git-compat-util.h"
#include "abspath.h"
diff --git a/archive.c b/archive.c
index a7a92ff839..b9c200cba6 100644
--- a/archive.c
+++ b/archive.c
@@ -1,4 +1,5 @@
#define USE_THE_REPOSITORY_VARIABLE
+#define DISABLE_SIGN_COMPARE_WARNINGS
#include "git-compat-util.h"
#include "abspath.h"
diff --git a/attr.c b/attr.c
index 192936c4bc..0bd2750528 100644
--- a/attr.c
+++ b/attr.c
@@ -7,6 +7,7 @@
*/
#define USE_THE_REPOSITORY_VARIABLE
+#define DISABLE_SIGN_COMPARE_WARNINGS
#include "git-compat-util.h"
#include "config.h"
diff --git a/base85.c b/base85.c
index bbacdca31b..80e899a2b1 100644
--- a/base85.c
+++ b/base85.c
@@ -29,10 +29,9 @@ static const char en85[] = {
static char de85[256];
static void prep_base85(void)
{
- int i;
if (de85['Z'])
return;
- for (i = 0; i < ARRAY_SIZE(en85); i++) {
+ for (size_t i = 0; i < ARRAY_SIZE(en85); i++) {
int ch = en85[i];
de85[ch] = i + 1;
}
diff --git a/bisect.c b/bisect.c
index d71c4e4b44..1a9069c9ad 100644
--- a/bisect.c
+++ b/bisect.c
@@ -1,4 +1,5 @@
#define USE_THE_REPOSITORY_VARIABLE
+#define DISABLE_SIGN_COMPARE_WARNINGS
#include "git-compat-util.h"
#include "config.h"
diff --git a/blame.c b/blame.c
index bf69768a7d..a15ddf9333 100644
--- a/blame.c
+++ b/blame.c
@@ -1,4 +1,5 @@
#define USE_THE_REPOSITORY_VARIABLE
+#define DISABLE_SIGN_COMPARE_WARNINGS
#include "git-compat-util.h"
#include "refs.h"
diff --git a/bloom.c b/bloom.c
index c428634105..0c8d2cebf9 100644
--- a/bloom.c
+++ b/bloom.c
@@ -1,3 +1,5 @@
+#define DISABLE_SIGN_COMPARE_WARNINGS
+
#include "git-compat-util.h"
#include "bloom.h"
#include "diff.h"
diff --git a/builtin/add.c b/builtin/add.c
index 7d35307792..78dfb26577 100644
--- a/builtin/add.c
+++ b/builtin/add.c
@@ -3,6 +3,7 @@
*
* Copyright (C) 2006 Linus Torvalds
*/
+
#include "builtin.h"
#include "advice.h"
#include "config.h"
@@ -39,9 +40,9 @@ static int chmod_pathspec(struct repository *repo,
char flip,
int show_only)
{
- int i, ret = 0;
+ int ret = 0;
- for (i = 0; i < repo->index->cache_nr; i++) {
+ for (size_t i = 0; i < repo->index->cache_nr; i++) {
struct cache_entry *ce = repo->index->cache[i];
int err;
@@ -69,9 +70,9 @@ static int renormalize_tracked_files(struct repository *repo,
const struct pathspec *pathspec,
int flags)
{
- int i, retval = 0;
+ int retval = 0;
- for (i = 0; i < repo->index->cache_nr; i++) {
+ for (size_t i = 0; i < repo->index->cache_nr; i++) {
struct cache_entry *ce = repo->index->cache[i];
if (!include_sparse &&
diff --git a/builtin/am.c b/builtin/am.c
index bfa95147cf..1338b606fe 100644
--- a/builtin/am.c
+++ b/builtin/am.c
@@ -5,6 +5,7 @@
*/
#define USE_THE_REPOSITORY_VARIABLE
+
#include "builtin.h"
#include "abspath.h"
#include "advice.h"
diff --git a/builtin/bisect.c b/builtin/bisect.c
index 8166d4abf5..8b8d870cd1 100644
--- a/builtin/bisect.c
+++ b/builtin/bisect.c
@@ -1,4 +1,6 @@
#define USE_THE_REPOSITORY_VARIABLE
+#define DISABLE_SIGN_COMPARE_WARNINGS
+
#include "builtin.h"
#include "copy.h"
#include "environment.h"
diff --git a/builtin/blame.c b/builtin/blame.c
index 6a7bb3b072..867032e4c1 100644
--- a/builtin/blame.c
+++ b/builtin/blame.c
@@ -4,7 +4,9 @@
* Copyright (c) 2006, 2014 by its authors
* See COPYING for licensing conditions
*/
+
#define USE_THE_REPOSITORY_VARIABLE
+
#include "builtin.h"
#include "config.h"
#include "color.h"
@@ -465,9 +467,14 @@ static void emit_other(struct blame_scoreboard *sb, struct blame_entry *ent, int
reset = GIT_COLOR_RESET;
}
+ if (abbrev < MINIMUM_ABBREV)
+ BUG("abbreviation is smaller than minimum length: %d < %d",
+ abbrev, MINIMUM_ABBREV);
+
for (cnt = 0; cnt < ent->num_lines; cnt++) {
char ch;
- int length = (opt & OUTPUT_LONG_OBJECT_NAME) ? the_hash_algo->hexsz : abbrev;
+ size_t length = (opt & OUTPUT_LONG_OBJECT_NAME) ?
+ the_hash_algo->hexsz : (size_t) abbrev;
if (opt & OUTPUT_COLOR_LINE) {
if (cnt > 0) {
@@ -498,7 +505,7 @@ static void emit_other(struct blame_scoreboard *sb, struct blame_entry *ent, int
length--;
putchar('?');
}
- printf("%.*s", length, hex);
+ fwrite(hex, 1, length, stdout);
if (opt & OUTPUT_ANNOTATE_COMPAT) {
const char *name;
if (opt & OUTPUT_SHOW_EMAIL)
diff --git a/builtin/branch.c b/builtin/branch.c
index 200909c23e..6e7b0cfddb 100644
--- a/builtin/branch.c
+++ b/builtin/branch.c
@@ -4,7 +4,9 @@
* Copyright (c) 2006 Kristian Høgsberg <krh@redhat.com>
* Based on git-branch.sh by Junio C Hamano.
*/
+
#define USE_THE_REPOSITORY_VARIABLE
+
#include "builtin.h"
#include "config.h"
#include "color.h"
diff --git a/builtin/cat-file.c b/builtin/cat-file.c
index d67b101c20..b13561cf73 100644
--- a/builtin/cat-file.c
+++ b/builtin/cat-file.c
@@ -3,7 +3,10 @@
*
* Copyright (C) Linus Torvalds, 2005
*/
+
#define USE_THE_REPOSITORY_VARIABLE
+#define DISABLE_SIGN_COMPARE_WARNINGS
+
#include "builtin.h"
#include "config.h"
#include "convert.h"
diff --git a/builtin/checkout--worker.c b/builtin/checkout--worker.c
index ff6cdccc21..b81002a1df 100644
--- a/builtin/checkout--worker.c
+++ b/builtin/checkout--worker.c
@@ -1,4 +1,6 @@
#define USE_THE_REPOSITORY_VARIABLE
+#define DISABLE_SIGN_COMPARE_WARNINGS
+
#include "builtin.h"
#include "config.h"
#include "entry.h"
diff --git a/builtin/checkout-index.c b/builtin/checkout-index.c
index 6dd38eb05d..a81501098d 100644
--- a/builtin/checkout-index.c
+++ b/builtin/checkout-index.c
@@ -4,7 +4,10 @@
* Copyright (C) 2005 Linus Torvalds
*
*/
+
#define USE_THE_REPOSITORY_VARIABLE
+#define DISABLE_SIGN_COMPARE_WARNINGS
+
#include "builtin.h"
#include "config.h"
#include "gettext.h"
diff --git a/builtin/checkout.c b/builtin/checkout.c
index 5e5afa0f26..01ea9ff8b2 100644
--- a/builtin/checkout.c
+++ b/builtin/checkout.c
@@ -1,4 +1,6 @@
#define USE_THE_REPOSITORY_VARIABLE
+#define DISABLE_SIGN_COMPARE_WARNINGS
+
#include "builtin.h"
#include "advice.h"
#include "branch.h"
diff --git a/builtin/clean.c b/builtin/clean.c
index 9c48dd0271..053c94fc6b 100644
--- a/builtin/clean.c
+++ b/builtin/clean.c
@@ -5,7 +5,10 @@
*
* Based on git-clean.sh by Pavel Roskin
*/
+
#define USE_THE_REPOSITORY_VARIABLE
+#define DISABLE_SIGN_COMPARE_WARNINGS
+
#include "builtin.h"
#include "abspath.h"
#include "config.h"
diff --git a/builtin/clone.c b/builtin/clone.c
index 21721db28a..fd001d800c 100644
--- a/builtin/clone.c
+++ b/builtin/clone.c
@@ -7,7 +7,10 @@
*
* Clone a repository into a different directory that does not yet exist.
*/
+
#define USE_THE_REPOSITORY_VARIABLE
+#define DISABLE_SIGN_COMPARE_WARNINGS
+
#include "builtin.h"
#include "abspath.h"
diff --git a/builtin/commit.c b/builtin/commit.c
index 71d674138c..ef5e622c07 100644
--- a/builtin/commit.c
+++ b/builtin/commit.c
@@ -4,7 +4,10 @@
* Copyright (c) 2007 Kristian Høgsberg <krh@redhat.com>
* Based on git-commit.sh by Junio C Hamano and Linus Torvalds
*/
+
#define USE_THE_REPOSITORY_VARIABLE
+#define DISABLE_SIGN_COMPARE_WARNINGS
+
#include "builtin.h"
#include "advice.h"
#include "config.h"
diff --git a/builtin/describe.c b/builtin/describe.c
index a6ef8af32a..e2e73f3d75 100644
--- a/builtin/describe.c
+++ b/builtin/describe.c
@@ -1,4 +1,6 @@
#define USE_THE_REPOSITORY_VARIABLE
+#define DISABLE_SIGN_COMPARE_WARNINGS
+
#include "builtin.h"
#include "config.h"
#include "environment.h"
diff --git a/builtin/diff-files.c b/builtin/diff-files.c
index e0e0ccec23..604b04bb2c 100644
--- a/builtin/diff-files.c
+++ b/builtin/diff-files.c
@@ -3,7 +3,10 @@
*
* Copyright (C) Linus Torvalds, 2005
*/
+
#define USE_THE_REPOSITORY_VARIABLE
+#define DISABLE_SIGN_COMPARE_WARNINGS
+
#include "builtin.h"
#include "config.h"
#include "diff.h"
diff --git a/builtin/diff-index.c b/builtin/diff-index.c
index ad503624c0..ebc824602e 100644
--- a/builtin/diff-index.c
+++ b/builtin/diff-index.c
@@ -1,4 +1,6 @@
#define USE_THE_REPOSITORY_VARIABLE
+#define DISABLE_SIGN_COMPARE_WARNINGS
+
#include "builtin.h"
#include "config.h"
#include "diff.h"
diff --git a/builtin/diff-tree.c b/builtin/diff-tree.c
index 4b6656bb9f..40804e7b48 100644
--- a/builtin/diff-tree.c
+++ b/builtin/diff-tree.c
@@ -1,4 +1,5 @@
#define USE_THE_REPOSITORY_VARIABLE
+
#include "builtin.h"
#include "config.h"
#include "diff.h"
diff --git a/builtin/diff.c b/builtin/diff.c
index 2fe92f373e..a4fffee42c 100644
--- a/builtin/diff.c
+++ b/builtin/diff.c
@@ -3,7 +3,10 @@
*
* Copyright (c) 2006 Junio C Hamano
*/
+
#define USE_THE_REPOSITORY_VARIABLE
+#define DISABLE_SIGN_COMPARE_WARNINGS
+
#include "builtin.h"
#include "config.h"
#include "ewah/ewok.h"
diff --git a/builtin/difftool.c b/builtin/difftool.c
index 40e971e225..03a8bb92a9 100644
--- a/builtin/difftool.c
+++ b/builtin/difftool.c
@@ -11,7 +11,9 @@
*
* Copyright (C) 2016 Johannes Schindelin
*/
+
#define USE_THE_REPOSITORY_VARIABLE
+
#include "builtin.h"
#include "abspath.h"
@@ -364,7 +366,8 @@ static int run_dir_diff(const char *extcmd, int symlinks, const char *prefix,
char *lbase_dir = NULL, *rbase_dir = NULL;
size_t ldir_len, rdir_len, wtdir_len;
const char *workdir, *tmp;
- int ret = 0, i;
+ int ret = 0;
+ size_t i;
FILE *fp = NULL;
struct hashmap working_tree_dups = HASHMAP_INIT(working_tree_entry_cmp,
NULL);
diff --git a/builtin/fast-export.c b/builtin/fast-export.c
index e17f262e8e..a5c82eef1d 100644
--- a/builtin/fast-export.c
+++ b/builtin/fast-export.c
@@ -3,7 +3,10 @@
*
* Copyright (C) 2007 Johannes E. Schindelin
*/
+
#define USE_THE_REPOSITORY_VARIABLE
+#define DISABLE_SIGN_COMPARE_WARNINGS
+
#include "builtin.h"
#include "config.h"
#include "gettext.h"
diff --git a/builtin/fast-import.c b/builtin/fast-import.c
index a67c1c4416..1fa2929a01 100644
--- a/builtin/fast-import.c
+++ b/builtin/fast-import.c
@@ -1,4 +1,6 @@
#define USE_THE_REPOSITORY_VARIABLE
+#define DISABLE_SIGN_COMPARE_WARNINGS
+
#include "builtin.h"
#include "abspath.h"
#include "environment.h"
diff --git a/builtin/fetch-pack.c b/builtin/fetch-pack.c
index 62e8c3aa6b..bed2816c2d 100644
--- a/builtin/fetch-pack.c
+++ b/builtin/fetch-pack.c
@@ -1,4 +1,6 @@
#define USE_THE_REPOSITORY_VARIABLE
+#define DISABLE_SIGN_COMPARE_WARNINGS
+
#include "builtin.h"
#include "gettext.h"
#include "hex.h"
diff --git a/builtin/fetch.c b/builtin/fetch.c
index 872ad49834..2d37a378ba 100644
--- a/builtin/fetch.c
+++ b/builtin/fetch.c
@@ -1,7 +1,10 @@
/*
* "git fetch"
*/
+
#define USE_THE_REPOSITORY_VARIABLE
+#define DISABLE_SIGN_COMPARE_WARNINGS
+
#include "builtin.h"
#include "advice.h"
#include "config.h"
diff --git a/builtin/for-each-repo.c b/builtin/for-each-repo.c
index fae7f91cf1..325a7925f1 100644
--- a/builtin/for-each-repo.c
+++ b/builtin/for-each-repo.c
@@ -1,4 +1,5 @@
#define USE_THE_REPOSITORY_VARIABLE
+
#include "builtin.h"
#include "config.h"
#include "gettext.h"
@@ -36,7 +37,7 @@ int cmd_for_each_repo(int argc,
{
static const char *config_key = NULL;
int keep_going = 0;
- int i, result = 0;
+ int result = 0;
const struct string_list *values;
int err;
@@ -61,7 +62,7 @@ int cmd_for_each_repo(int argc,
else if (err)
return 0;
- for (i = 0; i < values->nr; i++) {
+ for (size_t i = 0; i < values->nr; i++) {
int ret = run_command_on_repo(values->items[i].string, argc, argv);
if (ret) {
if (!keep_going)
diff --git a/builtin/fsmonitor--daemon.c b/builtin/fsmonitor--daemon.c
index f3f6bd330b..029dc64d6c 100644
--- a/builtin/fsmonitor--daemon.c
+++ b/builtin/fsmonitor--daemon.c
@@ -1,4 +1,6 @@
#define USE_THE_REPOSITORY_VARIABLE
+#define DISABLE_SIGN_COMPARE_WARNINGS
+
#include "builtin.h"
#include "abspath.h"
#include "config.h"
diff --git a/builtin/gc.c b/builtin/gc.c
index 4ae5196aed..a9b1c36de2 100644
--- a/builtin/gc.c
+++ b/builtin/gc.c
@@ -9,7 +9,10 @@
*
* Copyright (c) 2006 Shawn O. Pearce
*/
+
#define USE_THE_REPOSITORY_VARIABLE
+#define DISABLE_SIGN_COMPARE_WARNINGS
+
#include "builtin.h"
#include "abspath.h"
#include "date.h"
diff --git a/builtin/grep.c b/builtin/grep.c
index 98b85c7fca..d00ee76f24 100644
--- a/builtin/grep.c
+++ b/builtin/grep.c
@@ -3,7 +3,10 @@
*
* Copyright (c) 2006 Junio C Hamano
*/
+
#define USE_THE_REPOSITORY_VARIABLE
+#define DISABLE_SIGN_COMPARE_WARNINGS
+
#include "builtin.h"
#include "abspath.h"
#include "gettext.h"
diff --git a/builtin/help.c b/builtin/help.c
index 6a72d991a8..05136279cf 100644
--- a/builtin/help.c
+++ b/builtin/help.c
@@ -1,8 +1,9 @@
-
/*
* Builtin help command
*/
+
#define USE_THE_REPOSITORY_VARIABLE
+
#include "builtin.h"
#include "config.h"
#include "exec-cmd.h"
@@ -129,7 +130,6 @@ static void list_config_help(enum show_config_type type)
struct string_list keys = STRING_LIST_INIT_DUP;
struct string_list keys_uniq = STRING_LIST_INIT_DUP;
struct string_list_item *item;
- int i;
for (p = config_name_list; *p; p++) {
const char *var = *p;
@@ -156,7 +156,7 @@ static void list_config_help(enum show_config_type type)
e->prefix, e->placeholder);
string_list_sort(&keys);
- for (i = 0; i < keys.nr; i++) {
+ for (size_t i = 0; i < keys.nr; i++) {
const char *var = keys.items[i].string;
const char *wildcard, *tag, *cut;
const char *dot = NULL;
diff --git a/builtin/index-pack.c b/builtin/index-pack.c
index cde49e0b4d..d773809c4c 100644
--- a/builtin/index-pack.c
+++ b/builtin/index-pack.c
@@ -1,4 +1,6 @@
#define USE_THE_REPOSITORY_VARIABLE
+#define DISABLE_SIGN_COMPARE_WARNINGS
+
#include "builtin.h"
#include "config.h"
#include "delta.h"
diff --git a/builtin/log.c b/builtin/log.c
index 923e4e6069..75e1b34123 100644
--- a/builtin/log.c
+++ b/builtin/log.c
@@ -4,7 +4,10 @@
* (C) Copyright 2006 Linus Torvalds
* 2006 Junio Hamano
*/
+
#define USE_THE_REPOSITORY_VARIABLE
+#define DISABLE_SIGN_COMPARE_WARNINGS
+
#include "builtin.h"
#include "abspath.h"
#include "config.h"
diff --git a/builtin/ls-files.c b/builtin/ls-files.c
index e016b0415d..15499cd12b 100644
--- a/builtin/ls-files.c
+++ b/builtin/ls-files.c
@@ -5,7 +5,10 @@
*
* Copyright (C) Linus Torvalds, 2005
*/
+
#define USE_THE_REPOSITORY_VARIABLE
+#define DISABLE_SIGN_COMPARE_WARNINGS
+
#include "builtin.h"
#include "config.h"
#include "convert.h"
diff --git a/builtin/mailsplit.c b/builtin/mailsplit.c
index b8f7150ce9..41dd304731 100644
--- a/builtin/mailsplit.c
+++ b/builtin/mailsplit.c
@@ -4,6 +4,9 @@
* It just splits a mbox into a list of files: "0001" "0002" ..
* so you can process them further from there.
*/
+
+#define DISABLE_SIGN_COMPARE_WARNINGS
+
#include "builtin.h"
#include "gettext.h"
#include "string-list.h"
@@ -172,7 +175,6 @@ static int split_maildir(const char *maildir, const char *dir,
char *file = NULL;
FILE *f = NULL;
int ret = -1;
- int i;
struct string_list list = STRING_LIST_INIT_DUP;
list.cmp = maildir_filename_cmp;
@@ -180,7 +182,7 @@ static int split_maildir(const char *maildir, const char *dir,
if (populate_maildir_list(&list, maildir) < 0)
goto out;
- for (i = 0; i < list.nr; i++) {
+ for (size_t i = 0; i < list.nr; i++) {
char *name;
free(file);
diff --git a/builtin/merge-file.c b/builtin/merge-file.c
index cb42865eb5..7e315f374b 100644
--- a/builtin/merge-file.c
+++ b/builtin/merge-file.c
@@ -1,4 +1,6 @@
#define USE_THE_REPOSITORY_VARIABLE
+#define DISABLE_SIGN_COMPARE_WARNINGS
+
#include "builtin.h"
#include "abspath.h"
#include "diff.h"
diff --git a/builtin/merge-index.c b/builtin/merge-index.c
index a5b87ee3c5..342699edb7 100644
--- a/builtin/merge-index.c
+++ b/builtin/merge-index.c
@@ -1,4 +1,6 @@
#define USE_THE_REPOSITORY_VARIABLE
+#define DISABLE_SIGN_COMPARE_WARNINGS
+
#include "builtin.h"
#include "hex.h"
#include "read-cache-ll.h"
diff --git a/builtin/merge-ours.c b/builtin/merge-ours.c
index 1fcf53f005..3ecd9172f1 100644
--- a/builtin/merge-ours.c
+++ b/builtin/merge-ours.c
@@ -7,7 +7,9 @@
*
* Pretend we resolved the heads, but declare our tree trumps everybody else.
*/
+
#define USE_THE_REPOSITORY_VARIABLE
+
#include "git-compat-util.h"
#include "builtin.h"
#include "diff.h"
diff --git a/builtin/merge-tree.c b/builtin/merge-tree.c
index c5ed472967..9a6c8b4e4c 100644
--- a/builtin/merge-tree.c
+++ b/builtin/merge-tree.c
@@ -1,4 +1,5 @@
#define USE_THE_REPOSITORY_VARIABLE
+
#include "builtin.h"
#include "tree-walk.h"
#include "xdiff-interface.h"
@@ -497,10 +498,9 @@ static int real_merge(struct merge_tree_options *o,
if (!result.clean) {
struct string_list conflicted_files = STRING_LIST_INIT_NODUP;
const char *last = NULL;
- int i;
merge_get_conflicted_files(&result, &conflicted_files);
- for (i = 0; i < conflicted_files.nr; i++) {
+ for (size_t i = 0; i < conflicted_files.nr; i++) {
const char *name = conflicted_files.items[i].string;
struct stage_info *c = conflicted_files.items[i].util;
if (!o->name_only)
@@ -584,7 +584,7 @@ int cmd_merge_tree(int argc,
if (xopts.nr && o.mode == MODE_TRIVIAL)
die(_("--trivial-merge is incompatible with all other options"));
- for (int x = 0; x < xopts.nr; x++)
+ for (size_t x = 0; x < xopts.nr; x++)
if (parse_merge_opt(&o.merge_options, xopts.v[x]))
die(_("unknown strategy option: -X%s"), xopts.v[x]);
diff --git a/builtin/merge.c b/builtin/merge.c
index e32c99087f..5f67007bba 100644
--- a/builtin/merge.c
+++ b/builtin/merge.c
@@ -5,7 +5,10 @@
*
* Based on git-merge.sh by Junio C Hamano.
*/
+
#define USE_THE_REPOSITORY_VARIABLE
+#define DISABLE_SIGN_COMPARE_WARNINGS
+
#include "builtin.h"
#include "abspath.h"
diff --git a/builtin/mv.c b/builtin/mv.c
index 472a278737..55a7d471dc 100644
--- a/builtin/mv.c
+++ b/builtin/mv.c
@@ -3,7 +3,9 @@
*
* Copyright (C) 2006 Johannes Schindelin
*/
+
#define USE_THE_REPOSITORY_VARIABLE
+#define DISABLE_SIGN_COMPARE_WARNINGS
#include "builtin.h"
#include "abspath.h"
diff --git a/builtin/name-rev.c b/builtin/name-rev.c
index 765eb20a93..beac166b5c 100644
--- a/builtin/name-rev.c
+++ b/builtin/name-rev.c
@@ -1,4 +1,6 @@
#define USE_THE_REPOSITORY_VARIABLE
+#define DISABLE_SIGN_COMPARE_WARNINGS
+
#include "builtin.h"
#include "environment.h"
#include "gettext.h"
diff --git a/builtin/pack-objects.c b/builtin/pack-objects.c
index 7dc51c03c4..1c3b842651 100644
--- a/builtin/pack-objects.c
+++ b/builtin/pack-objects.c
@@ -1,4 +1,6 @@
#define USE_THE_REPOSITORY_VARIABLE
+#define DISABLE_SIGN_COMPARE_WARNINGS
+
#include "builtin.h"
#include "environment.h"
#include "gettext.h"
diff --git a/builtin/pack-redundant.c b/builtin/pack-redundant.c
index bc61990a93..e046575871 100644
--- a/builtin/pack-redundant.c
+++ b/builtin/pack-redundant.c
@@ -5,6 +5,7 @@
* This file is licensed under the GPL v2.
*
*/
+
#define USE_THE_REPOSITORY_VARIABLE
#include "builtin.h"
@@ -389,7 +390,6 @@ static int cmp_remaining_objects(const void *a, const void *b)
static void sort_pack_list(struct pack_list **pl)
{
struct pack_list **ary, *p;
- int i;
size_t n = pack_list_size(*pl);
if (n < 2)
@@ -403,7 +403,7 @@ static void sort_pack_list(struct pack_list **pl)
QSORT(ary, n, cmp_remaining_objects);
/* link them back again */
- for (i = 0; i < n - 1; i++)
+ for (size_t i = 0; i < n - 1; i++)
ary[i]->next = ary[i + 1];
ary[n - 1]->next = NULL;
*pl = ary[0];
diff --git a/builtin/pack-refs.c b/builtin/pack-refs.c
index 2d83c1ed2a..4fdd68880e 100644
--- a/builtin/pack-refs.c
+++ b/builtin/pack-refs.c
@@ -1,4 +1,5 @@
#define USE_THE_REPOSITORY_VARIABLE
+
#include "builtin.h"
#include "config.h"
#include "gettext.h"
diff --git a/builtin/patch-id.c b/builtin/patch-id.c
index 93b398e391..f540d8daa7 100644
--- a/builtin/patch-id.c
+++ b/builtin/patch-id.c
@@ -1,4 +1,5 @@
#define USE_THE_REPOSITORY_VARIABLE
+
#include "builtin.h"
#include "config.h"
#include "diff.h"
@@ -8,13 +9,13 @@
#include "parse-options.h"
#include "setup.h"
-static void flush_current_id(int patchlen, struct object_id *id, struct object_id *result)
+static void flush_current_id(size_t patchlen, struct object_id *id, struct object_id *result)
{
if (patchlen)
printf("%s %s\n", oid_to_hex(result), oid_to_hex(id));
}
-static int remove_space(char *line)
+static size_t remove_space(char *line)
{
char *src = line;
char *dst = line;
@@ -61,10 +62,11 @@ static int scan_hunk_header(const char *p, int *p_before, int *p_after)
return 1;
}
-static int get_one_patchid(struct object_id *next_oid, struct object_id *result,
- struct strbuf *line_buf, int stable, int verbatim)
+static size_t get_one_patchid(struct object_id *next_oid, struct object_id *result,
+ struct strbuf *line_buf, int stable, int verbatim)
{
- int patchlen = 0, found_next = 0;
+ size_t patchlen = 0;
+ int found_next = 0;
int before = -1, after = -1;
int diff_is_binary = 0;
char pre_oid_str[GIT_MAX_HEXSZ + 1], post_oid_str[GIT_MAX_HEXSZ + 1];
@@ -76,7 +78,7 @@ static int get_one_patchid(struct object_id *next_oid, struct object_id *result,
while (strbuf_getwholeline(line_buf, stdin, '\n') != EOF) {
char *line = line_buf->buf;
const char *p = line;
- int len;
+ size_t len;
/* Possibly skip over the prefix added by "log" or "format-patch" */
if (!skip_prefix(line, "commit ", &p) &&
@@ -177,7 +179,7 @@ static int get_one_patchid(struct object_id *next_oid, struct object_id *result,
static void generate_id_list(int stable, int verbatim)
{
struct object_id oid, n, result;
- int patchlen;
+ size_t patchlen;
struct strbuf line_buf = STRBUF_INIT;
oidclr(&oid, the_repository->hash_algo);
diff --git a/builtin/prune.c b/builtin/prune.c
index 2b1de01339..aeff9ca1b3 100644
--- a/builtin/prune.c
+++ b/builtin/prune.c
@@ -1,4 +1,6 @@
#define USE_THE_REPOSITORY_VARIABLE
+#define DISABLE_SIGN_COMPARE_WARNINGS
+
#include "builtin.h"
#include "commit.h"
#include "diff.h"
diff --git a/builtin/pull.c b/builtin/pull.c
index edc56907aa..9c4a00620a 100644
--- a/builtin/pull.c
+++ b/builtin/pull.c
@@ -7,6 +7,7 @@
*/
#define USE_THE_REPOSITORY_VARIABLE
+
#include "builtin.h"
#include "advice.h"
#include "config.h"
@@ -941,11 +942,10 @@ static int get_can_ff(struct object_id *orig_head,
static int already_up_to_date(struct object_id *orig_head,
struct oid_array *merge_heads)
{
- int i;
struct commit *ours;
ours = lookup_commit_reference(the_repository, orig_head);
- for (i = 0; i < merge_heads->nr; i++) {
+ for (size_t i = 0; i < merge_heads->nr; i++) {
struct commit_list *list = NULL;
struct commit *theirs;
int ok;
diff --git a/builtin/push.c b/builtin/push.c
index 51c609f208..90de3746b5 100644
--- a/builtin/push.c
+++ b/builtin/push.c
@@ -1,7 +1,9 @@
/*
* "git push"
*/
+
#define USE_THE_REPOSITORY_VARIABLE
+
#include "builtin.h"
#include "advice.h"
#include "branch.h"
@@ -417,7 +419,7 @@ static int do_push(int flags,
const struct string_list *push_options,
struct remote *remote)
{
- int i, errs;
+ int errs;
struct strvec *url;
struct refspec *push_refspec = &rs;
@@ -432,7 +434,7 @@ static int do_push(int flags,
}
errs = 0;
url = push_url_of_remote(remote);
- for (i = 0; i < url->nr; i++) {
+ for (size_t i = 0; i < url->nr; i++) {
struct transport *transport =
transport_get(remote, url->v[i]);
if (flags & TRANSPORT_PUSH_OPTIONS)
diff --git a/builtin/range-diff.c b/builtin/range-diff.c
index 1b33ab66a7..433c305fc5 100644
--- a/builtin/range-diff.c
+++ b/builtin/range-diff.c
@@ -1,4 +1,5 @@
#define USE_THE_REPOSITORY_VARIABLE
+
#include "builtin.h"
#include "gettext.h"
#include "object-name.h"
diff --git a/builtin/rebase.c b/builtin/rebase.c
index bbaca3c5d5..0498fff3c9 100644
--- a/builtin/rebase.c
+++ b/builtin/rebase.c
@@ -3,7 +3,10 @@
*
* Copyright (c) 2018 Pratik Karki
*/
+
#define USE_THE_REPOSITORY_VARIABLE
+#define DISABLE_SIGN_COMPARE_WARNINGS
+
#include "builtin.h"
#include "abspath.h"
diff --git a/builtin/receive-pack.c b/builtin/receive-pack.c
index 9d2c07f68d..c2e9103f11 100644
--- a/builtin/receive-pack.c
+++ b/builtin/receive-pack.c
@@ -1,4 +1,6 @@
#define USE_THE_REPOSITORY_VARIABLE
+#define DISABLE_SIGN_COMPARE_WARNINGS
+
#include "builtin.h"
#include "abspath.h"
diff --git a/builtin/reflog.c b/builtin/reflog.c
index 5a0c22f2f7..95f264989b 100644
--- a/builtin/reflog.c
+++ b/builtin/reflog.c
@@ -1,4 +1,5 @@
#define USE_THE_REPOSITORY_VARIABLE
+
#include "builtin.h"
#include "config.h"
#include "gettext.h"
diff --git a/builtin/remote.c b/builtin/remote.c
index 32d02ca4a0..0435963286 100644
--- a/builtin/remote.c
+++ b/builtin/remote.c
@@ -1,4 +1,6 @@
#define USE_THE_REPOSITORY_VARIABLE
+#define DISABLE_SIGN_COMPARE_WARNINGS
+
#include "builtin.h"
#include "config.h"
#include "gettext.h"
diff --git a/builtin/repack.c b/builtin/repack.c
index 9c21fc482d..0c6dad7df4 100644
--- a/builtin/repack.c
+++ b/builtin/repack.c
@@ -1,4 +1,6 @@
#define USE_THE_REPOSITORY_VARIABLE
+#define DISABLE_SIGN_COMPARE_WARNINGS
+
#include "builtin.h"
#include "config.h"
#include "dir.h"
diff --git a/builtin/replay.c b/builtin/replay.c
index 2d12a4e403..1afc6d1ee0 100644
--- a/builtin/replay.c
+++ b/builtin/replay.c
@@ -2,9 +2,11 @@
* "git replay" builtin command
*/
+#define USE_THE_REPOSITORY_VARIABLE
+#define DISABLE_SIGN_COMPARE_WARNINGS
+
#include "git-compat-util.h"
-#define USE_THE_REPOSITORY_VARIABLE
#include "builtin.h"
#include "environment.h"
#include "hex.h"
diff --git a/builtin/rerere.c b/builtin/rerere.c
index f7143c3f5d..41127e24e5 100644
--- a/builtin/rerere.c
+++ b/builtin/rerere.c
@@ -1,4 +1,5 @@
#define USE_THE_REPOSITORY_VARIABLE
+
#include "builtin.h"
#include "config.h"
#include "gettext.h"
@@ -55,7 +56,7 @@ int cmd_rerere(int argc,
struct repository *repo UNUSED)
{
struct string_list merge_rr = STRING_LIST_INIT_DUP;
- int i, autoupdate = -1, flags = 0;
+ int autoupdate = -1, flags = 0;
struct option options[] = {
OPT_SET_INT(0, "rerere-autoupdate", &autoupdate,
@@ -98,11 +99,11 @@ int cmd_rerere(int argc,
if (setup_rerere(the_repository, &merge_rr,
flags | RERERE_READONLY) < 0)
return 0;
- for (i = 0; i < merge_rr.nr; i++)
+ for (size_t i = 0; i < merge_rr.nr; i++)
printf("%s\n", merge_rr.items[i].string);
} else if (!strcmp(argv[0], "remaining")) {
rerere_remaining(the_repository, &merge_rr);
- for (i = 0; i < merge_rr.nr; i++) {
+ for (size_t i = 0; i < merge_rr.nr; i++) {
if (merge_rr.items[i].util != RERERE_RESOLVED)
printf("%s\n", merge_rr.items[i].string);
else
@@ -114,7 +115,7 @@ int cmd_rerere(int argc,
if (setup_rerere(the_repository, &merge_rr,
flags | RERERE_READONLY) < 0)
return 0;
- for (i = 0; i < merge_rr.nr; i++) {
+ for (size_t i = 0; i < merge_rr.nr; i++) {
const char *path = merge_rr.items[i].string;
const struct rerere_id *id = merge_rr.items[i].util;
if (diff_two(rerere_path(id, "preimage"), path, path, path))
diff --git a/builtin/reset.c b/builtin/reset.c
index 7154f88826..73b4537a9a 100644
--- a/builtin/reset.c
+++ b/builtin/reset.c
@@ -7,7 +7,9 @@
*
* Copyright (c) 2005, 2006 Linus Torvalds and Junio C Hamano
*/
+
#define USE_THE_REPOSITORY_VARIABLE
+
#include "builtin.h"
#include "advice.h"
#include "config.h"
diff --git a/builtin/rev-list.c b/builtin/rev-list.c
index 8fe83893fa..3196da7b2d 100644
--- a/builtin/rev-list.c
+++ b/builtin/rev-list.c
@@ -1,4 +1,6 @@
#define USE_THE_REPOSITORY_VARIABLE
+#define DISABLE_SIGN_COMPARE_WARNINGS
+
#include "builtin.h"
#include "config.h"
#include "commit.h"
diff --git a/builtin/rev-parse.c b/builtin/rev-parse.c
index 8401b4d7ab..949747a6b6 100644
--- a/builtin/rev-parse.c
+++ b/builtin/rev-parse.c
@@ -3,7 +3,10 @@
*
* Copyright (C) Linus Torvalds, 2005
*/
+
#define USE_THE_REPOSITORY_VARIABLE
+#define DISABLE_SIGN_COMPARE_WARNINGS
+
#include "builtin.h"
#include "abspath.h"
diff --git a/builtin/revert.c b/builtin/revert.c
index b7917dddd3..aca6c293cd 100644
--- a/builtin/revert.c
+++ b/builtin/revert.c
@@ -1,4 +1,5 @@
#define USE_THE_REPOSITORY_VARIABLE
+
#include "git-compat-util.h"
#include "builtin.h"
#include "parse-options.h"
diff --git a/builtin/rm.c b/builtin/rm.c
index eaff027258..12ae086a55 100644
--- a/builtin/rm.c
+++ b/builtin/rm.c
@@ -3,7 +3,10 @@
*
* Copyright (C) Linus Torvalds 2006
*/
+
#define USE_THE_REPOSITORY_VARIABLE
+#define DISABLE_SIGN_COMPARE_WARNINGS
+
#include "builtin.h"
#include "advice.h"
#include "config.h"
diff --git a/builtin/shortlog.c b/builtin/shortlog.c
index c86b75d981..30075b67be 100644
--- a/builtin/shortlog.c
+++ b/builtin/shortlog.c
@@ -1,4 +1,5 @@
#define USE_THE_REPOSITORY_VARIABLE
+
#include "builtin.h"
#include "config.h"
#include "commit.h"
diff --git a/builtin/show-branch.c b/builtin/show-branch.c
index cd6bdf63bc..fce6b404e9 100644
--- a/builtin/show-branch.c
+++ b/builtin/show-branch.c
@@ -1,4 +1,6 @@
#define USE_THE_REPOSITORY_VARIABLE
+#define DISABLE_SIGN_COMPARE_WARNINGS
+
#include "builtin.h"
#include "config.h"
#include "environment.h"
diff --git a/builtin/show-index.c b/builtin/show-index.c
index f164c01bbe..3152d3c74b 100644
--- a/builtin/show-index.c
+++ b/builtin/show-index.c
@@ -1,4 +1,6 @@
#define USE_THE_REPOSITORY_VARIABLE
+#define DISABLE_SIGN_COMPARE_WARNINGS
+
#include "builtin.h"
#include "gettext.h"
#include "hash.h"
diff --git a/builtin/sparse-checkout.c b/builtin/sparse-checkout.c
index 34af5b2590..14dcace5f8 100644
--- a/builtin/sparse-checkout.c
+++ b/builtin/sparse-checkout.c
@@ -1,4 +1,6 @@
#define USE_THE_REPOSITORY_VARIABLE
+#define DISABLE_SIGN_COMPARE_WARNINGS
+
#include "builtin.h"
#include "config.h"
#include "dir.h"
diff --git a/builtin/stash.c b/builtin/stash.c
index c212b1c0b2..dbaa999cf1 100644
--- a/builtin/stash.c
+++ b/builtin/stash.c
@@ -1,4 +1,5 @@
#define USE_THE_REPOSITORY_VARIABLE
+
#include "builtin.h"
#include "abspath.h"
#include "config.h"
@@ -873,9 +874,8 @@ static void diff_include_untracked(const struct stash_info *info, struct diff_op
struct tree *tree[ARRAY_SIZE(oid)];
struct tree_desc tree_desc[ARRAY_SIZE(oid)];
struct unpack_trees_options unpack_tree_opt = { 0 };
- int i;
- for (i = 0; i < ARRAY_SIZE(oid); i++) {
+ for (size_t i = 0; i < ARRAY_SIZE(oid); i++) {
tree[i] = parse_tree_indirect(oid[i]);
if (parse_tree(tree[i]) < 0)
die(_("failed to parse tree"));
@@ -1557,12 +1557,11 @@ static int do_push_stash(const struct pathspec *ps, const char *stash_msg, int q
repo_read_index_preload(the_repository, NULL, 0);
if (!include_untracked && ps->nr) {
- int i;
char *ps_matched = xcalloc(ps->nr, 1);
/* TODO: audit for interaction with sparse-index. */
ensure_full_index(the_repository->index);
- for (i = 0; i < the_repository->index->cache_nr; i++)
+ for (size_t i = 0; i < the_repository->index->cache_nr; i++)
ce_path_match(the_repository->index, the_repository->index->cache[i], ps,
ps_matched);
diff --git a/builtin/submodule--helper.c b/builtin/submodule--helper.c
index 19e5878381..f9b970f8a6 100644
--- a/builtin/submodule--helper.c
+++ b/builtin/submodule--helper.c
@@ -1,4 +1,5 @@
#define USE_THE_REPOSITORY_VARIABLE
+
#include "builtin.h"
#include "abspath.h"
#include "environment.h"
@@ -194,7 +195,7 @@ static int module_list_compute(const char **argv,
struct pathspec *pathspec,
struct module_list *list)
{
- int i, result = 0;
+ int result = 0;
char *ps_matched = NULL;
parse_pathspec(pathspec, 0,
@@ -207,7 +208,7 @@ static int module_list_compute(const char **argv,
if (repo_read_index(the_repository) < 0)
die(_("index file corrupt"));
- for (i = 0; i < the_repository->index->cache_nr; i++) {
+ for (size_t i = 0; i < the_repository->index->cache_nr; i++) {
const struct cache_entry *ce = the_repository->index->cache[i];
if (!match_pathspec(the_repository->index, pathspec, ce->name, ce_namelen(ce),
@@ -3396,7 +3397,6 @@ static void die_on_index_match(const char *path, int force)
die(_("index file corrupt"));
if (ps.nr) {
- int i;
char *ps_matched = xcalloc(ps.nr, 1);
/* TODO: audit for interaction with sparse-index. */
@@ -3406,7 +3406,7 @@ static void die_on_index_match(const char *path, int force)
* Since there is only one pathspec, we just need to
* check ps_matched[0] to know if a cache entry matched.
*/
- for (i = 0; i < the_repository->index->cache_nr; i++) {
+ for (size_t i = 0; i < the_repository->index->cache_nr; i++) {
ce_path_match(the_repository->index, the_repository->index->cache[i], &ps,
ps_matched);
diff --git a/builtin/tag.c b/builtin/tag.c
index affa14d659..c4bd145831 100644
--- a/builtin/tag.c
+++ b/builtin/tag.c
@@ -5,7 +5,10 @@
* Carlos Rica <jasampler@gmail.com>
* Based on git-tag.sh and mktag.c by Linus Torvalds.
*/
+
#define USE_THE_REPOSITORY_VARIABLE
+#define DISABLE_SIGN_COMPARE_WARNINGS
+
#include "builtin.h"
#include "advice.h"
#include "config.h"
diff --git a/builtin/unpack-objects.c b/builtin/unpack-objects.c
index 02b8d02f63..2197d6d933 100644
--- a/builtin/unpack-objects.c
+++ b/builtin/unpack-objects.c
@@ -1,4 +1,6 @@
#define USE_THE_REPOSITORY_VARIABLE
+#define DISABLE_SIGN_COMPARE_WARNINGS
+
#include "builtin.h"
#include "bulk-checkin.h"
#include "config.h"
diff --git a/builtin/update-index.c b/builtin/update-index.c
index 45b4a8b555..74bbad9f87 100644
--- a/builtin/update-index.c
+++ b/builtin/update-index.c
@@ -3,7 +3,10 @@
*
* Copyright (C) Linus Torvalds, 2005
*/
+
#define USE_THE_REPOSITORY_VARIABLE
+#define DISABLE_SIGN_COMPARE_WARNINGS
+
#include "builtin.h"
#include "bulk-checkin.h"
#include "config.h"
diff --git a/builtin/update-ref.c b/builtin/update-ref.c
index 670e7812d6..4d35bdc4b4 100644
--- a/builtin/update-ref.c
+++ b/builtin/update-ref.c
@@ -1,4 +1,6 @@
#define USE_THE_REPOSITORY_VARIABLE
+#define DISABLE_SIGN_COMPARE_WARNINGS
+
#include "builtin.h"
#include "config.h"
#include "gettext.h"
diff --git a/builtin/var.c b/builtin/var.c
index 2ecaed51b4..1449656cc9 100644
--- a/builtin/var.c
+++ b/builtin/var.c
@@ -3,7 +3,9 @@
*
* Copyright (C) Eric Biederman, 2005
*/
+
#define USE_THE_REPOSITORY_VARIABLE
+
#include "builtin.h"
#include "attr.h"
@@ -178,10 +180,9 @@ static void list_vars(void)
if ((val = ptr->read(0))) {
if (ptr->multivalued && *val) {
struct string_list list = STRING_LIST_INIT_DUP;
- int i;
string_list_split(&list, val, '\n', -1);
- for (i = 0; i < list.nr; i++)
+ for (size_t i = 0; i < list.nr; i++)
printf("%s=%s\n", ptr->name, list.items[i].string);
string_list_clear(&list, 0);
} else {
diff --git a/builtin/worktree.c b/builtin/worktree.c
index 0186d60ab1..c043d4d523 100644
--- a/builtin/worktree.c
+++ b/builtin/worktree.c
@@ -1,4 +1,6 @@
#define USE_THE_REPOSITORY_VARIABLE
+#define DISABLE_SIGN_COMPARE_WARNINGS
+
#include "builtin.h"
#include "abspath.h"
#include "advice.h"
diff --git a/bulk-checkin.c b/bulk-checkin.c
index 2753d5bbe4..4a70a70a95 100644
--- a/bulk-checkin.c
+++ b/bulk-checkin.c
@@ -3,6 +3,7 @@
*/
#define USE_THE_REPOSITORY_VARIABLE
+#define DISABLE_SIGN_COMPARE_WARNINGS
#include "git-compat-util.h"
#include "bulk-checkin.h"
diff --git a/bundle-uri.c b/bundle-uri.c
index cdf9e4f9e1..744257c49c 100644
--- a/bundle-uri.c
+++ b/bundle-uri.c
@@ -1,4 +1,5 @@
#define USE_THE_REPOSITORY_VARIABLE
+#define DISABLE_SIGN_COMPARE_WARNINGS
#include "git-compat-util.h"
#include "bundle-uri.h"
diff --git a/bundle.c b/bundle.c
index 83c08e65cb..f18f98fec9 100644
--- a/bundle.c
+++ b/bundle.c
@@ -1,4 +1,5 @@
#define USE_THE_REPOSITORY_VARIABLE
+#define DISABLE_SIGN_COMPARE_WARNINGS
#include "git-compat-util.h"
#include "lockfile.h"
diff --git a/cache-tree.c b/cache-tree.c
index c595e86120..bcbcad3d61 100644
--- a/cache-tree.c
+++ b/cache-tree.c
@@ -1,4 +1,5 @@
#define USE_THE_REPOSITORY_VARIABLE
+#define DISABLE_SIGN_COMPARE_WARNINGS
#include "git-compat-util.h"
#include "gettext.h"
diff --git a/chunk-format.c b/chunk-format.c
index 2dde24e6a3..51b5a2c959 100644
--- a/chunk-format.c
+++ b/chunk-format.c
@@ -1,4 +1,5 @@
#define USE_THE_REPOSITORY_VARIABLE
+#define DISABLE_SIGN_COMPARE_WARNINGS
#include "git-compat-util.h"
#include "chunk-format.h"
diff --git a/color.c b/color.c
index 227a5ab2f4..7df8862c71 100644
--- a/color.c
+++ b/color.c
@@ -1,3 +1,5 @@
+#define DISABLE_SIGN_COMPARE_WARNINGS
+
#include "git-compat-util.h"
#include "config.h"
#include "color.h"
diff --git a/column.c b/column.c
index 50bbccc92e..93fae316b4 100644
--- a/column.c
+++ b/column.c
@@ -1,3 +1,5 @@
+#define DISABLE_SIGN_COMPARE_WARNINGS
+
#include "git-compat-util.h"
#include "config.h"
#include "column.h"
diff --git a/combine-diff.c b/combine-diff.c
index 33d0ed7097..641bc92dbd 100644
--- a/combine-diff.c
+++ b/combine-diff.c
@@ -1,4 +1,5 @@
#define USE_THE_REPOSITORY_VARIABLE
+#define DISABLE_SIGN_COMPARE_WARNINGS
#include "git-compat-util.h"
#include "object-store-ll.h"
diff --git a/commit-graph.c b/commit-graph.c
index e2e2083951..0df66e5a24 100644
--- a/commit-graph.c
+++ b/commit-graph.c
@@ -1,4 +1,5 @@
#define USE_THE_REPOSITORY_VARIABLE
+#define DISABLE_SIGN_COMPARE_WARNINGS
#include "git-compat-util.h"
#include "config.h"
diff --git a/commit-reach.c b/commit-reach.c
index c3518aa360..e3edd11995 100644
--- a/commit-reach.c
+++ b/commit-reach.c
@@ -1,4 +1,5 @@
#define USE_THE_REPOSITORY_VARIABLE
+#define DISABLE_SIGN_COMPARE_WARNINGS
#include "git-compat-util.h"
#include "commit.h"
diff --git a/commit.c b/commit.c
index 35ab9bead5..a127fe60c5 100644
--- a/commit.c
+++ b/commit.c
@@ -1765,7 +1765,6 @@ int commit_tree_extended(const char *msg, size_t msg_len,
{ &compat_sig, r->compat_hash_algo },
{ &sig, r->hash_algo },
};
- int i;
/*
* We write algorithms in the order they were implemented in
@@ -1779,7 +1778,7 @@ int commit_tree_extended(const char *msg, size_t msg_len,
* We traverse each algorithm in order, and apply the signature
* to each buffer.
*/
- for (i = 0; i < ARRAY_SIZE(bufs); i++) {
+ for (size_t i = 0; i < ARRAY_SIZE(bufs); i++) {
if (!bufs[i].algo)
continue;
add_header_signature(&buffer, bufs[i].sig, bufs[i].algo);
diff --git a/compat/fsmonitor/fsm-listen-darwin.c b/compat/fsmonitor/fsm-listen-darwin.c
index dfa551459d..43c3a915a0 100644
--- a/compat/fsmonitor/fsm-listen-darwin.c
+++ b/compat/fsmonitor/fsm-listen-darwin.c
@@ -208,13 +208,12 @@ static void fsevent_callback(ConstFSEventStreamRef streamRef UNUSED,
const char *slash;
char *resolved = NULL;
struct strbuf tmp = STRBUF_INIT;
- int k;
/*
* Build a list of all filesystem changes into a private/local
* list and without holding any locks.
*/
- for (k = 0; k < num_of_events; k++) {
+ for (size_t k = 0; k < num_of_events; k++) {
/*
* On Mac, we receive an array of absolute paths.
*/
diff --git a/compat/mingw.c b/compat/mingw.c
index 63f36c893b..408b1a3102 100644
--- a/compat/mingw.c
+++ b/compat/mingw.c
@@ -1,4 +1,5 @@
#define USE_THE_REPOSITORY_VARIABLE
+#define DISABLE_SIGN_COMPARE_WARNINGS
#include "../git-compat-util.h"
#include "win32.h"
diff --git a/compat/poll/poll.c b/compat/poll/poll.c
index afa6d24584..a2becd16cd 100644
--- a/compat/poll/poll.c
+++ b/compat/poll/poll.c
@@ -18,6 +18,8 @@
You should have received a copy of the GNU General Public License along
with this program; if not, see <http://www.gnu.org/licenses/>. */
+#define DISABLE_SIGN_COMPARE_WARNINGS
+
/* To bump the minimum Windows version to Windows Vista */
#include "git-compat-util.h"
diff --git a/compat/regex/regex.c b/compat/regex/regex.c
index e6f4a5d177..4b09cc4e14 100644
--- a/compat/regex/regex.c
+++ b/compat/regex/regex.c
@@ -17,6 +17,8 @@
License along with the GNU C Library; if not, see
<http://www.gnu.org/licenses/>. */
+#pragma GCC diagnostic ignored "-Wsign-compare"
+
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
diff --git a/compat/terminal.c b/compat/terminal.c
index d54efa1c5d..584f27bf7e 100644
--- a/compat/terminal.c
+++ b/compat/terminal.c
@@ -259,14 +259,13 @@ static DWORD cmode_in, cmode_out;
void restore_term(void)
{
if (use_stty) {
- int i;
struct child_process cp = CHILD_PROCESS_INIT;
if (stty_restore.nr == 0)
return;
strvec_push(&cp.args, "stty");
- for (i = 0; i < stty_restore.nr; i++)
+ for (size_t i = 0; i < stty_restore.nr; i++)
strvec_push(&cp.args, stty_restore.items[i].string);
run_command(&cp);
string_list_clear(&stty_restore, 0);
diff --git a/compat/win32/headless.c b/compat/win32/headless.c
index 11392a0b9a..a6eb116ddc 100644
--- a/compat/win32/headless.c
+++ b/compat/win32/headless.c
@@ -53,7 +53,8 @@ int WINAPI wWinMain(_In_ HINSTANCE instance,
wchar_t git_command_line[32768];
size_t size = sizeof(git_command_line) / sizeof(wchar_t);
const wchar_t *needs_quotes = L"";
- int slash = 0, i;
+ size_t slash = 0;
+ int len;
STARTUPINFO startup_info = {
.cb = sizeof(STARTUPINFO),
@@ -66,7 +67,7 @@ int WINAPI wWinMain(_In_ HINSTANCE instance,
DWORD exit_code;
/* First, determine the full path of argv[0] */
- for (i = 0; _wpgmptr[i]; i++)
+ for (size_t i = 0; _wpgmptr[i]; i++)
if (_wpgmptr[i] == L' ')
needs_quotes = L"\"";
else if (_wpgmptr[i] == L'\\')
@@ -79,16 +80,16 @@ int WINAPI wWinMain(_In_ HINSTANCE instance,
extend_path(_wpgmptr, slash);
/* Then, add the full path of `git.exe` as argv[0] */
- i = swprintf_s(git_command_line, size, L"%ls%.*ls\\git.exe%ls",
- needs_quotes, slash, _wpgmptr, needs_quotes);
- if (i < 0)
+ len = swprintf_s(git_command_line, size, L"%ls%.*ls\\git.exe%ls",
+ needs_quotes, (int) slash, _wpgmptr, needs_quotes);
+ if (len < 0)
return 127; /* Too long path */
if (*command_line) {
/* Now, append the command-line arguments */
- i = swprintf_s(git_command_line + i, size - i,
- L" %ls", command_line);
- if (i < 0)
+ len = swprintf_s(git_command_line + len, size - len,
+ L" %ls", command_line);
+ if (len < 0)
return 127;
}
diff --git a/compat/win32mmap.c b/compat/win32mmap.c
index a4ab4cb939..e951934316 100644
--- a/compat/win32mmap.c
+++ b/compat/win32mmap.c
@@ -1,3 +1,5 @@
+#define DISABLE_SIGN_COMPARE_WARNINGS
+
#include "../git-compat-util.h"
void *git_mmap(void *start, size_t length, int prot, int flags, int fd, off_t offset)
diff --git a/compat/winansi.c b/compat/winansi.c
index 1b3f916b9f..ac2ffb7869 100644
--- a/compat/winansi.c
+++ b/compat/winansi.c
@@ -4,6 +4,8 @@
#undef NOGDI
+#define DISABLE_SIGN_COMPARE_WARNINGS
+
#include "../git-compat-util.h"
#include <wingdi.h>
#include <winreg.h>
diff --git a/config.c b/config.c
index 2c295f7430..50f2d17b39 100644
--- a/config.c
+++ b/config.c
@@ -7,6 +7,7 @@
*/
#define USE_THE_REPOSITORY_VARIABLE
+#define DISABLE_SIGN_COMPARE_WARNINGS
#include "git-compat-util.h"
#include "abspath.h"
diff --git a/config.mak.dev b/config.mak.dev
index 8eca7fa228..0fd8cc4d35 100644
--- a/config.mak.dev
+++ b/config.mak.dev
@@ -53,7 +53,6 @@ ifeq ($(filter extra-all,$(DEVOPTS)),)
# These are disabled because we have these all over the place.
DEVELOPER_CFLAGS += -Wno-empty-body
DEVELOPER_CFLAGS += -Wno-missing-field-initializers
-DEVELOPER_CFLAGS += -Wno-sign-compare
endif
endif
diff --git a/connect.c b/connect.c
index 58f53d8dcb..10fad43e98 100644
--- a/connect.c
+++ b/connect.c
@@ -1,4 +1,5 @@
#define USE_THE_REPOSITORY_VARIABLE
+#define DISABLE_SIGN_COMPARE_WARNINGS
#include "git-compat-util.h"
#include "config.h"
diff --git a/convert.c b/convert.c
index c9a31eb4f0..9cc0ca20ca 100644
--- a/convert.c
+++ b/convert.c
@@ -1,4 +1,5 @@
#define USE_THE_REPOSITORY_VARIABLE
+#define DISABLE_SIGN_COMPARE_WARNINGS
#include "git-compat-util.h"
#include "advice.h"
diff --git a/credential.c b/credential.c
index 6dea3859ec..a995031c5f 100644
--- a/credential.c
+++ b/credential.c
@@ -1,4 +1,5 @@
#define USE_THE_REPOSITORY_VARIABLE
+#define DISABLE_SIGN_COMPARE_WARNINGS
#include "git-compat-util.h"
#include "abspath.h"
diff --git a/csum-file.c b/csum-file.c
index c203ebf11b..5716016e12 100644
--- a/csum-file.c
+++ b/csum-file.c
@@ -23,7 +23,7 @@ static void verify_buffer_or_die(struct hashfile *f,
if (ret < 0)
die_errno("%s: sha1 file read error", f->name);
- if (ret != count)
+ if ((size_t)ret != count)
die("%s: sha1 file truncated", f->name);
if (memcmp(buf, f->check_buffer, count))
die("sha1 file '%s' validation error", f->name);
diff --git a/daemon.c b/daemon.c
index 756c3f0b02..d1be61fd57 100644
--- a/daemon.c
+++ b/daemon.c
@@ -504,8 +504,7 @@ static struct daemon_service daemon_service[] = {
static void enable_service(const char *name, int ena)
{
- int i;
- for (i = 0; i < ARRAY_SIZE(daemon_service); i++) {
+ for (size_t i = 0; i < ARRAY_SIZE(daemon_service); i++) {
if (!strcmp(daemon_service[i].name, name)) {
daemon_service[i].enabled = ena;
return;
@@ -516,8 +515,7 @@ static void enable_service(const char *name, int ena)
static void make_service_overridable(const char *name, int ena)
{
- int i;
- for (i = 0; i < ARRAY_SIZE(daemon_service); i++) {
+ for (size_t i = 0; i < ARRAY_SIZE(daemon_service); i++) {
if (!strcmp(daemon_service[i].name, name)) {
daemon_service[i].overridable = ena;
return;
@@ -738,7 +736,7 @@ static void set_keep_alive(int sockfd)
static int execute(void)
{
char *line = packet_buffer;
- int pktlen, len, i;
+ int pktlen, len;
char *addr = getenv("REMOTE_ADDR"), *port = getenv("REMOTE_PORT");
struct hostinfo hi = HOSTINFO_INIT;
struct strvec env = STRVEC_INIT;
@@ -759,7 +757,7 @@ static int execute(void)
if (len != pktlen)
parse_extra_args(&hi, &env, line + len + 1, pktlen - len - 1);
- for (i = 0; i < ARRAY_SIZE(daemon_service); i++) {
+ for (size_t i = 0; i < ARRAY_SIZE(daemon_service); i++) {
struct daemon_service *s = &(daemon_service[i]);
const char *arg;
@@ -804,8 +802,7 @@ static int addrcmp(const struct sockaddr_storage *s1,
return 0;
}
-static int max_connections = 32;
-
+static unsigned int max_connections = 32;
static unsigned int live_children;
static struct child {
@@ -1109,8 +1106,8 @@ static void socksetup(struct string_list *listen_addr, int listen_port, struct s
if (!listen_addr->nr)
setup_named_sock(NULL, listen_port, socklist);
else {
- int i, socknum;
- for (i = 0; i < listen_addr->nr; i++) {
+ int socknum;
+ for (size_t i = 0; i < listen_addr->nr; i++) {
socknum = setup_named_sock(listen_addr->items[i].string,
listen_port, socklist);
@@ -1124,11 +1121,10 @@ static void socksetup(struct string_list *listen_addr, int listen_port, struct s
static int service_loop(struct socketlist *socklist)
{
struct pollfd *pfd;
- int i;
CALLOC_ARRAY(pfd, socklist->nr);
- for (i = 0; i < socklist->nr; i++) {
+ for (size_t i = 0; i < socklist->nr; i++) {
pfd[i].fd = socklist->list[i];
pfd[i].events = POLLIN;
}
@@ -1136,8 +1132,6 @@ static int service_loop(struct socketlist *socklist)
signal(SIGCHLD, child_handler);
for (;;) {
- int i;
-
check_dead_children();
if (poll(pfd, socklist->nr, -1) < 0) {
@@ -1149,7 +1143,7 @@ static int service_loop(struct socketlist *socklist)
continue;
}
- for (i = 0; i < socklist->nr; i++) {
+ for (size_t i = 0; i < socklist->nr; i++) {
if (pfd[i].revents & POLLIN) {
union {
struct sockaddr sa;
@@ -1321,10 +1315,11 @@ int cmd_main(int argc, const char **argv)
continue;
}
if (skip_prefix(arg, "--max-connections=", &v)) {
- if (strtol_i(v, 10, &max_connections))
+ int parsed_value;
+ if (strtol_i(v, 10, &parsed_value))
die(_("invalid max-connections '%s', expecting an integer"), v);
- if (max_connections < 0)
- max_connections = 0; /* unlimited */
+ /* A negative value indicates unlimited children. */
+ max_connections = parsed_value < 0 ? 0 : parsed_value;
continue;
}
if (!strcmp(arg, "--strict-paths")) {
diff --git a/date.c b/date.c
index bee9fe8f10..a1b26a8dce 100644
--- a/date.c
+++ b/date.c
@@ -4,6 +4,8 @@
* Copyright (C) Linus Torvalds, 2005
*/
+#define DISABLE_SIGN_COMPARE_WARNINGS
+
#include "git-compat-util.h"
#include "date.h"
#include "gettext.h"
diff --git a/decorate.c b/decorate.c
index 69aeb142b4..e161e13772 100644
--- a/decorate.c
+++ b/decorate.c
@@ -2,6 +2,9 @@
* decorate.c - decorate a git object with some arbitrary
* data.
*/
+
+#define DISABLE_SIGN_COMPARE_WARNINGS
+
#include "git-compat-util.h"
#include "object.h"
#include "decorate.h"
diff --git a/delta-islands.c b/delta-islands.c
index 8443551259..1c465a6041 100644
--- a/delta-islands.c
+++ b/delta-islands.c
@@ -1,4 +1,5 @@
#define USE_THE_REPOSITORY_VARIABLE
+#define DISABLE_SIGN_COMPARE_WARNINGS
#include "git-compat-util.h"
#include "object.h"
diff --git a/diagnose.c b/diagnose.c
index cc2d535b60..b11931df86 100644
--- a/diagnose.c
+++ b/diagnose.c
@@ -31,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) {
@@ -39,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;
@@ -186,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 },
@@ -239,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)) {
diff --git a/diff-delta.c b/diff-delta.c
index 77fea08dfb..a4faf73829 100644
--- a/diff-delta.c
+++ b/diff-delta.c
@@ -11,6 +11,8 @@
* published by the Free Software Foundation.
*/
+#define DISABLE_SIGN_COMPARE_WARNINGS
+
#include "git-compat-util.h"
#include "delta.h"
diff --git a/diff-lib.c b/diff-lib.c
index 3cf353946f..c6d3bc4d37 100644
--- a/diff-lib.c
+++ b/diff-lib.c
@@ -3,6 +3,7 @@
*/
#define USE_THE_REPOSITORY_VARIABLE
+#define DISABLE_SIGN_COMPARE_WARNINGS
#include "git-compat-util.h"
#include "commit.h"
diff --git a/diff-no-index.c b/diff-no-index.c
index c5fb06e6d1..6f277892d3 100644
--- a/diff-no-index.c
+++ b/diff-no-index.c
@@ -4,6 +4,8 @@
* Copyright (c) 2008 by Junio C Hamano
*/
+#define DISABLE_SIGN_COMPARE_WARNINGS
+
#include "git-compat-util.h"
#include "abspath.h"
#include "color.h"
diff --git a/diff.c b/diff.c
index 266ddf18e7..d28b4114c8 100644
--- a/diff.c
+++ b/diff.c
@@ -3,6 +3,7 @@
*/
#define USE_THE_REPOSITORY_VARIABLE
+#define DISABLE_SIGN_COMPARE_WARNINGS
#include "git-compat-util.h"
#include "abspath.h"
diff --git a/diff.h b/diff.h
index 5c8de79535..6e6007c17b 100644
--- a/diff.h
+++ b/diff.h
@@ -205,9 +205,8 @@ static inline void diff_flags_or(struct diff_flags *a,
{
char *tmp_a = (char *)a;
const char *tmp_b = (const char *)b;
- int i;
- for (i = 0; i < sizeof(struct diff_flags); i++)
+ for (size_t i = 0; i < sizeof(struct diff_flags); i++)
tmp_a[i] |= tmp_b[i];
}
diff --git a/diffcore-order.c b/diffcore-order.c
index 912513d3e6..f91ef22471 100644
--- a/diffcore-order.c
+++ b/diffcore-order.c
@@ -1,6 +1,7 @@
/*
* Copyright (C) 2005 Junio C Hamano
*/
+
#include "git-compat-util.h"
#include "gettext.h"
#include "diff.h"
diff --git a/diffcore-pickaxe.c b/diffcore-pickaxe.c
index 43fef8e8ba..a52d569911 100644
--- a/diffcore-pickaxe.c
+++ b/diffcore-pickaxe.c
@@ -2,6 +2,9 @@
* Copyright (C) 2005 Junio C Hamano
* Copyright (C) 2010 Google Inc.
*/
+
+#define DISABLE_SIGN_COMPARE_WARNINGS
+
#include "git-compat-util.h"
#include "diff.h"
#include "diffcore.h"
diff --git a/diffcore-rename.c b/diffcore-rename.c
index 1b1c1a6a1f..10bb0321b1 100644
--- a/diffcore-rename.c
+++ b/diffcore-rename.c
@@ -688,7 +688,6 @@ static void cleanup_dir_rename_info(struct dir_rename_info *info,
struct hashmap_iter iter;
struct strmap_entry *entry;
struct string_list to_remove = STRING_LIST_INIT_NODUP;
- int i;
if (!info->setup)
return;
@@ -734,7 +733,7 @@ static void cleanup_dir_rename_info(struct dir_rename_info *info,
if (strintmap_contains(counts, UNKNOWN_DIR))
strintmap_remove(counts, UNKNOWN_DIR);
}
- for (i = 0; i < to_remove.nr; ++i)
+ for (size_t i = 0; i < to_remove.nr; ++i)
strmap_remove(info->dir_rename_count,
to_remove.items[i].string, 1);
string_list_clear(&to_remove, 0);
diff --git a/diffcore-rotate.c b/diffcore-rotate.c
index 73ca20b331..67b591261a 100644
--- a/diffcore-rotate.c
+++ b/diffcore-rotate.c
@@ -2,6 +2,7 @@
* Copyright (C) 2021, Google LLC.
* Based on diffcore-order.c, which is Copyright (C) 2005, Junio C Hamano
*/
+
#include "git-compat-util.h"
#include "gettext.h"
#include "diff.h"
diff --git a/dir.c b/dir.c
index 7f35a3e317..5b2181e589 100644
--- a/dir.c
+++ b/dir.c
@@ -7,6 +7,7 @@
*/
#define USE_THE_REPOSITORY_VARIABLE
+#define DISABLE_SIGN_COMPARE_WARNINGS
#include "git-compat-util.h"
#include "abspath.h"
diff --git a/entry.c b/entry.c
index 3143b9996b..53a1c39358 100644
--- a/entry.c
+++ b/entry.c
@@ -441,7 +441,7 @@ static int check_path(const char *path, int len, struct stat *st, int skiplen)
static void mark_colliding_entries(const struct checkout *state,
struct cache_entry *ce, struct stat *st)
{
- int i, trust_ino = check_stat;
+ int trust_ino = check_stat;
#if defined(GIT_WINDOWS_NATIVE) || defined(__CYGWIN__)
trust_ino = 0;
@@ -451,7 +451,7 @@ static void mark_colliding_entries(const struct checkout *state,
/* TODO: audit for interaction with sparse-index. */
ensure_full_index(state->istate);
- for (i = 0; i < state->istate->cache_nr; i++) {
+ for (size_t i = 0; i < state->istate->cache_nr; i++) {
struct cache_entry *dup = state->istate->cache[i];
if (dup == ce) {
diff --git a/ewah/ewah_bitmap.c b/ewah/ewah_bitmap.c
index 8785cbc54a..67f8f588e0 100644
--- a/ewah/ewah_bitmap.c
+++ b/ewah/ewah_bitmap.c
@@ -16,6 +16,7 @@
* You should have received a copy of the GNU General Public License
* along with this program; if not, see <http://www.gnu.org/licenses/>.
*/
+
#include "git-compat-util.h"
#include "ewok.h"
#include "ewok_rlw.h"
@@ -255,10 +256,8 @@ void ewah_each_bit(struct ewah_bitmap *self, void (*callback)(size_t, void*), vo
++pointer;
for (k = 0; k < rlw_get_literal_words(word); ++k) {
- int c;
-
/* todo: zero count optimization */
- for (c = 0; c < BITS_IN_EWORD; ++c, ++pos) {
+ for (size_t c = 0; c < BITS_IN_EWORD; ++c, ++pos) {
if ((self->buffer[pointer] & ((eword_t)1 << c)) != 0)
callback(pos, payload);
}
diff --git a/ewah/ewah_io.c b/ewah/ewah_io.c
index 9035ee65ea..da005523b0 100644
--- a/ewah/ewah_io.c
+++ b/ewah/ewah_io.c
@@ -16,6 +16,9 @@
* You should have received a copy of the GNU General Public License
* along with this program; if not, see <http://www.gnu.org/licenses/>.
*/
+
+#define DISABLE_SIGN_COMPARE_WARNINGS
+
#include "git-compat-util.h"
#include "ewok.h"
#include "strbuf.h"
diff --git a/ewah/ewah_rlw.c b/ewah/ewah_rlw.c
index 5093d43e2f..76b4c6c19e 100644
--- a/ewah/ewah_rlw.c
+++ b/ewah/ewah_rlw.c
@@ -16,6 +16,9 @@
* You should have received a copy of the GNU General Public License
* along with this program; if not, see <http://www.gnu.org/licenses/>.
*/
+
+#define DISABLE_SIGN_COMPARE_WARNINGS
+
#include "git-compat-util.h"
#include "ewok.h"
#include "ewok_rlw.h"
diff --git a/fetch-pack.c b/fetch-pack.c
index c095f3a84b..3a227721ed 100644
--- a/fetch-pack.c
+++ b/fetch-pack.c
@@ -1,4 +1,5 @@
#define USE_THE_REPOSITORY_VARIABLE
+#define DISABLE_SIGN_COMPARE_WARNINGS
#include "git-compat-util.h"
#include "repository.h"
diff --git a/fmt-merge-msg.c b/fmt-merge-msg.c
index 6acb37b480..5b63c3b088 100644
--- a/fmt-merge-msg.c
+++ b/fmt-merge-msg.c
@@ -1,4 +1,5 @@
#define USE_THE_REPOSITORY_VARIABLE
+#define DISABLE_SIGN_COMPARE_WARNINGS
#include "git-compat-util.h"
#include "config.h"
diff --git a/fsmonitor.c b/fsmonitor.c
index 309a2541cb..98b2b476f0 100644
--- a/fsmonitor.c
+++ b/fsmonitor.c
@@ -1,4 +1,5 @@
#define USE_THE_REPOSITORY_VARIABLE
+#define DISABLE_SIGN_COMPARE_WARNINGS
#include "git-compat-util.h"
#include "config.h"
diff --git a/gettext.c b/gettext.c
index 57facbc21e..8d08a61f84 100644
--- a/gettext.c
+++ b/gettext.c
@@ -2,6 +2,8 @@
* Copyright (c) 2010 Ævar Arnfjörð Bjarmason
*/
+#define DISABLE_SIGN_COMPARE_WARNINGS
+
#include "git-compat-util.h"
#include "abspath.h"
#include "environment.h"
diff --git a/git-compat-util.h b/git-compat-util.h
index a06d4f3809..e283c46c6f 100644
--- a/git-compat-util.h
+++ b/git-compat-util.h
@@ -44,6 +44,16 @@ struct strbuf;
#define GIT_GNUC_PREREQ(maj, min) 0
#endif
+#if defined(__GNUC__) || defined(__clang__)
+# define PRAGMA(pragma) _Pragma(#pragma)
+# define DISABLE_WARNING(warning) PRAGMA(GCC diagnostic ignored #warning)
+#else
+# define DISABLE_WARNING(warning)
+#endif
+
+#ifdef DISABLE_SIGN_COMPARE_WARNINGS
+DISABLE_WARNING(-Wsign-compare)
+#endif
#ifndef FLEX_ARRAY
/*
diff --git a/git.c b/git.c
index 46b3c740c5..71d644dc1c 100644
--- a/git.c
+++ b/git.c
@@ -55,7 +55,7 @@ static void list_builtins(struct string_list *list, unsigned int exclude_option)
static void exclude_helpers_from_list(struct string_list *list)
{
- int i = 0;
+ size_t i = 0;
while (i < list->nr) {
if (strstr(list->items[i].string, "--"))
@@ -75,7 +75,6 @@ static int match_token(const char *spec, int len, const char *token)
static int list_cmds(const char *spec)
{
struct string_list list = STRING_LIST_INIT_DUP;
- int i;
int nongit;
/*
@@ -113,7 +112,7 @@ static int list_cmds(const char *spec)
if (*spec == ',')
spec++;
}
- for (i = 0; i < list.nr; i++)
+ for (size_t i = 0; i < list.nr; i++)
puts(list.items[i].string);
string_list_clear(&list, 0);
return 0;
@@ -322,10 +321,9 @@ static int handle_options(const char ***argv, int *argc, int *envchanged)
trace2_cmd_name("_query_");
if (!strcmp(cmd, "parseopt")) {
struct string_list list = STRING_LIST_INIT_DUP;
- int i;
list_builtins(&list, NO_PARSEOPT);
- for (i = 0; i < list.nr; i++)
+ for (size_t i = 0; i < list.nr; i++)
printf("%s ", list.items[i].string);
string_list_clear(&list, 0);
exit(0);
@@ -651,8 +649,7 @@ static struct cmd_struct commands[] = {
static struct cmd_struct *get_builtin(const char *s)
{
- int i;
- for (i = 0; i < ARRAY_SIZE(commands); i++) {
+ for (size_t i = 0; i < ARRAY_SIZE(commands); i++) {
struct cmd_struct *p = commands + i;
if (!strcmp(s, p->cmd))
return p;
@@ -667,8 +664,7 @@ int is_builtin(const char *s)
static void list_builtins(struct string_list *out, unsigned int exclude_option)
{
- int i;
- for (i = 0; i < ARRAY_SIZE(commands); i++) {
+ for (size_t i = 0; i < ARRAY_SIZE(commands); i++) {
if (exclude_option &&
(commands[i].option & exclude_option))
continue;
@@ -679,7 +675,6 @@ static void list_builtins(struct string_list *out, unsigned int exclude_option)
void load_builtin_commands(const char *prefix, struct cmdnames *cmds)
{
const char *name;
- int i;
/*
* Callers can ask for a subset of the commands based on a certain
@@ -690,7 +685,7 @@ void load_builtin_commands(const char *prefix, struct cmdnames *cmds)
if (!skip_prefix(prefix, "git-", &prefix))
BUG("prefix '%s' must start with 'git-'", prefix);
- for (i = 0; i < ARRAY_SIZE(commands); i++)
+ for (size_t i = 0; i < ARRAY_SIZE(commands); i++)
if (skip_prefix(commands[i].cmd, prefix, &name))
add_cmdname(cmds, name, strlen(name));
}
@@ -812,7 +807,7 @@ static int run_argv(struct strvec *args)
handle_builtin(args);
else if (get_builtin(args->v[0])) {
struct child_process cmd = CHILD_PROCESS_INIT;
- int i;
+ int err;
/*
* The current process is committed to launching a
@@ -826,7 +821,7 @@ static int run_argv(struct strvec *args)
commit_pager_choice();
strvec_push(&cmd.args, "git");
- for (i = 0; i < args->nr; i++)
+ for (size_t i = 0; i < args->nr; i++)
strvec_push(&cmd.args, args->v[i]);
trace_argv_printf(cmd.args.v, "trace: exec:");
@@ -839,9 +834,9 @@ static int run_argv(struct strvec *args)
cmd.clean_on_exit = 1;
cmd.wait_after_clean = 1;
cmd.trace2_child_class = "git_alias";
- i = run_command(&cmd);
- if (i >= 0 || errno != ENOENT)
- exit(i);
+ err = run_command(&cmd);
+ if (err >= 0 || errno != ENOENT)
+ exit(err);
die("could not execute builtin %s", args->v[0]);
}
@@ -850,9 +845,8 @@ static int run_argv(struct strvec *args)
seen = unsorted_string_list_lookup(&cmd_list, args->v[0]);
if (seen) {
- int i;
struct strbuf sb = STRBUF_INIT;
- for (i = 0; i < cmd_list.nr; i++) {
+ for (size_t i = 0; i < cmd_list.nr; i++) {
struct string_list_item *item = &cmd_list.items[i];
strbuf_addf(&sb, "\n %s", item->string);
@@ -946,7 +940,7 @@ int cmd_main(int argc, const char **argv)
*/
setup_path();
- for (size_t i = 0; i < argc; i++)
+ for (int i = 0; i < argc; i++)
strvec_push(&args, argv[i]);
while (1) {
diff --git a/gpg-interface.c b/gpg-interface.c
index 07335987a6..0896458de5 100644
--- a/gpg-interface.c
+++ b/gpg-interface.c
@@ -127,9 +127,7 @@ static struct gpg_format *use_format = &gpg_format[0];
static struct gpg_format *get_format_by_name(const char *str)
{
- int i;
-
- for (i = 0; i < ARRAY_SIZE(gpg_format); i++)
+ for (size_t i = 0; i < ARRAY_SIZE(gpg_format); i++)
if (!strcmp(gpg_format[i].name, str))
return gpg_format + i;
return NULL;
@@ -137,9 +135,9 @@ static struct gpg_format *get_format_by_name(const char *str)
static struct gpg_format *get_format_by_sig(const char *sig)
{
- int i, j;
+ int j;
- for (i = 0; i < ARRAY_SIZE(gpg_format); i++)
+ for (size_t i = 0; i < ARRAY_SIZE(gpg_format); i++)
for (j = 0; gpg_format[i].sigs[j]; j++)
if (starts_with(sig, gpg_format[i].sigs[j]))
return gpg_format + i;
@@ -227,7 +225,7 @@ static void parse_gpg_output(struct signature_check *sigc)
{
const char *buf = sigc->gpg_status;
const char *line, *next;
- int i, j;
+ int j;
int seen_exclusive_status = 0;
/* Iterate over all lines */
@@ -242,7 +240,7 @@ static void parse_gpg_output(struct signature_check *sigc)
continue;
/* Iterate over all search strings */
- for (i = 0; i < ARRAY_SIZE(sigcheck_gpg_status); i++) {
+ for (size_t i = 0; i < ARRAY_SIZE(sigcheck_gpg_status); i++) {
if (skip_prefix(line, sigcheck_gpg_status[i].check, &line)) {
/*
* GOODSIG, BADSIG etc. can occur only once for
@@ -699,7 +697,7 @@ size_t parse_signed_buffer(const char *buf, size_t size)
match = len;
eol = memchr(buf + len, '\n', size - len);
- len += eol ? eol - (buf + len) + 1 : size - len;
+ len += eol ? (size_t) (eol - (buf + len) + 1) : size - len;
}
return match;
}
diff --git a/graph.c b/graph.c
index bf000fdbe1..52205f75c3 100644
--- a/graph.c
+++ b/graph.c
@@ -1,4 +1,5 @@
#define USE_THE_REPOSITORY_VARIABLE
+#define DISABLE_SIGN_COMPARE_WARNINGS
#include "git-compat-util.h"
#include "gettext.h"
diff --git a/grep.c b/grep.c
index e95cded414..4e155ee9e6 100644
--- a/grep.c
+++ b/grep.c
@@ -1,3 +1,5 @@
+#define DISABLE_SIGN_COMPARE_WARNINGS
+
#include "git-compat-util.h"
#include "config.h"
#include "gettext.h"
diff --git a/help.c b/help.c
index 8a830ba35c..5483ea8fd2 100644
--- a/help.c
+++ b/help.c
@@ -1,4 +1,5 @@
#define USE_THE_REPOSITORY_VARIABLE
+#define DISABLE_SIGN_COMPARE_WARNINGS
#include "git-compat-util.h"
#include "config.h"
diff --git a/help.h b/help.h
index 67207b3073..c54bf0977d 100644
--- a/help.h
+++ b/help.h
@@ -60,8 +60,7 @@ static inline void list_config_item(struct string_list *list,
#define define_list_config_array(array) \
void list_config_##array(struct string_list *list, const char *prefix) \
{ \
- int i; \
- for (i = 0; i < ARRAY_SIZE(array); i++) \
+ for (size_t i = 0; i < ARRAY_SIZE(array); i++) \
if (array[i]) \
list_config_item(list, prefix, array[i]); \
} \
@@ -70,11 +69,10 @@ struct string_list
#define define_list_config_array_extra(array, values) \
void list_config_##array(struct string_list *list, const char *prefix) \
{ \
- int i; \
static const char *extra[] = values; \
- for (i = 0; i < ARRAY_SIZE(extra); i++) \
+ for (size_t i = 0; i < ARRAY_SIZE(extra); i++) \
list_config_item(list, prefix, extra[i]); \
- for (i = 0; i < ARRAY_SIZE(array); i++) \
+ for (size_t i = 0; i < ARRAY_SIZE(array); i++) \
if (array[i]) \
list_config_item(list, prefix, array[i]); \
} \
diff --git a/hex.c b/hex.c
index 5ca78a7744..865a232167 100644
--- a/hex.c
+++ b/hex.c
@@ -7,8 +7,7 @@
static int get_hash_hex_algop(const char *hex, unsigned char *hash,
const struct git_hash_algo *algop)
{
- int i;
- for (i = 0; i < algop->rawsz; i++) {
+ for (size_t i = 0; i < algop->rawsz; i++) {
int val = hex2chr(hex);
if (val < 0)
return -1;
@@ -83,7 +82,6 @@ char *hash_to_hex_algop_r(char *buffer, const unsigned char *hash,
{
static const char hex[] = "0123456789abcdef";
char *buf = buffer;
- int i;
/*
* Our struct object_id has been memset to 0, so default to printing
@@ -92,7 +90,7 @@ char *hash_to_hex_algop_r(char *buffer, const unsigned char *hash,
if (algop == &hash_algos[0])
algop = the_hash_algo;
- for (i = 0; i < algop->rawsz; i++) {
+ for (size_t i = 0; i < algop->rawsz; i++) {
unsigned int val = *hash++;
*buf++ = hex[val >> 4];
*buf++ = hex[val & 0xf];
diff --git a/http-backend.c b/http-backend.c
index 73eec4ea3d..33cf378282 100644
--- a/http-backend.c
+++ b/http-backend.c
@@ -1,4 +1,5 @@
#define USE_THE_REPOSITORY_VARIABLE
+#define DISABLE_SIGN_COMPARE_WARNINGS
#include "git-compat-util.h"
#include "config.h"
diff --git a/http-push.c b/http-push.c
index 4d24e6b8d4..43da1c7cd3 100644
--- a/http-push.c
+++ b/http-push.c
@@ -1338,7 +1338,6 @@ static struct object_list **process_tree(struct tree *tree,
static int get_delta(struct rev_info *revs, struct remote_lock *lock)
{
- int i;
struct commit *commit;
struct object_list **p = &objects;
int count = 0;
@@ -1351,7 +1350,7 @@ static int get_delta(struct rev_info *revs, struct remote_lock *lock)
count += add_send_request(&commit->object, lock);
}
- for (i = 0; i < revs->pending.nr; i++) {
+ for (size_t i = 0; i < revs->pending.nr; i++) {
struct object_array_entry *entry = revs->pending.objects + i;
struct object *obj = entry->item;
const char *name = entry->name;
diff --git a/http-walker.c b/http-walker.c
index 43cde0ebe5..7918ddc096 100644
--- a/http-walker.c
+++ b/http-walker.c
@@ -1,4 +1,5 @@
#define USE_THE_REPOSITORY_VARIABLE
+#define DISABLE_SIGN_COMPARE_WARNINGS
#include "git-compat-util.h"
#include "repository.h"
diff --git a/http.c b/http.c
index c7a55ae9cd..c8fc15aa11 100644
--- a/http.c
+++ b/http.c
@@ -1,4 +1,5 @@
#define USE_THE_REPOSITORY_VARIABLE
+#define DISABLE_SIGN_COMPARE_WARNINGS
#include "git-compat-util.h"
#include "git-curl-compat.h"
diff --git a/imap-send.c b/imap-send.c
index 25c68fd90d..68ab1aea83 100644
--- a/imap-send.c
+++ b/imap-send.c
@@ -22,6 +22,7 @@
*/
#define USE_THE_REPOSITORY_VARIABLE
+#define DISABLE_SIGN_COMPARE_WARNINGS
#include "git-compat-util.h"
#include "config.h"
diff --git a/json-writer.c b/json-writer.c
index 25b9201f9c..8c5187e9fd 100644
--- a/json-writer.c
+++ b/json-writer.c
@@ -1,3 +1,5 @@
+#define DISABLE_SIGN_COMPARE_WARNINGS
+
#include "git-compat-util.h"
#include "json-writer.h"
diff --git a/kwset.c b/kwset.c
index 695e47b7cc..1714eada60 100644
--- a/kwset.c
+++ b/kwset.c
@@ -32,6 +32,8 @@
String Matching: An Aid to Bibliographic Search," CACM June 1975,
Vol. 18, No. 6, which describes the failure function used below. */
+#define DISABLE_SIGN_COMPARE_WARNINGS
+
#include "git-compat-util.h"
#include "kwset.h"
diff --git a/line-log.c b/line-log.c
index bc67b75d10..628e3fe3ae 100644
--- a/line-log.c
+++ b/line-log.c
@@ -1,3 +1,5 @@
+#define DISABLE_SIGN_COMPARE_WARNINGS
+
#include "git-compat-util.h"
#include "diffcore.h"
#include "line-range.h"
diff --git a/list-objects-filter-options.c b/list-objects-filter-options.c
index fa72e81e4a..948376d42d 100644
--- a/list-objects-filter-options.c
+++ b/list-objects-filter-options.c
@@ -394,8 +394,6 @@ void list_objects_filter_copy(
struct list_objects_filter_options *dest,
const struct list_objects_filter_options *src)
{
- int i;
-
/* Copy everything. We will overwrite the pointers shortly. */
memcpy(dest, src, sizeof(struct list_objects_filter_options));
@@ -404,7 +402,7 @@ void list_objects_filter_copy(
dest->sparse_oid_name = xstrdup_or_null(src->sparse_oid_name);
ALLOC_ARRAY(dest->sub, dest->sub_alloc);
- for (i = 0; i < src->sub_nr; i++)
+ for (size_t i = 0; i < src->sub_nr; i++)
list_objects_filter_copy(&dest->sub[i], &src->sub[i]);
}
diff --git a/list-objects.c b/list-objects.c
index d11a389b3a..943e62e868 100644
--- a/list-objects.c
+++ b/list-objects.c
@@ -284,7 +284,6 @@ void mark_edges_uninteresting(struct rev_info *revs,
int sparse)
{
struct commit_list *list;
- int i;
if (sparse) {
struct oidset set;
@@ -321,7 +320,7 @@ void mark_edges_uninteresting(struct rev_info *revs,
}
if (revs->edge_hint_aggressive) {
- for (i = 0; i < revs->cmdline.nr; i++) {
+ for (size_t i = 0; i < revs->cmdline.nr; i++) {
struct object *obj = revs->cmdline.rev[i].item;
struct commit *commit = (struct commit *)obj;
if (obj->type != OBJ_COMMIT || !(obj->flags & UNINTERESTING))
@@ -344,11 +343,9 @@ static void add_pending_tree(struct rev_info *revs, struct tree *tree)
static void traverse_non_commits(struct traversal_context *ctx,
struct strbuf *base)
{
- int i;
-
assert(base->len == 0);
- for (i = 0; i < ctx->revs->pending.nr; i++) {
+ for (size_t i = 0; i < ctx->revs->pending.nr; i++) {
struct object_array_entry *pending = ctx->revs->pending.objects + i;
struct object *obj = pending->item;
const char *name = pending->name;
diff --git a/log-tree.c b/log-tree.c
index 83cc4b1cfb..d08eb672a9 100644
--- a/log-tree.c
+++ b/log-tree.c
@@ -1,4 +1,5 @@
#define USE_THE_REPOSITORY_VARIABLE
+#define DISABLE_SIGN_COMPARE_WARNINGS
#include "git-compat-util.h"
#include "commit-reach.h"
diff --git a/ls-refs.c b/ls-refs.c
index c824aea714..e28c841375 100644
--- a/ls-refs.c
+++ b/ls-refs.c
@@ -53,12 +53,10 @@ static enum {
*/
static int ref_match(const struct strvec *prefixes, const char *refname)
{
- int i;
-
if (!prefixes->nr)
return 1; /* no restriction */
- for (i = 0; i < prefixes->nr; i++) {
+ for (size_t i = 0; i < prefixes->nr; i++) {
const char *prefix = prefixes->v[i];
if (starts_with(refname, prefix))
diff --git a/mailinfo.c b/mailinfo.c
index d1f42bd7e3..aa263bf490 100644
--- a/mailinfo.c
+++ b/mailinfo.c
@@ -1,4 +1,5 @@
#define USE_THE_REPOSITORY_VARIABLE
+#define DISABLE_SIGN_COMPARE_WARNINGS
#include "git-compat-util.h"
#include "config.h"
diff --git a/mailmap.c b/mailmap.c
index 9f9fa3199a..f35d20ed7f 100644
--- a/mailmap.c
+++ b/mailmap.c
@@ -1,4 +1,5 @@
#define USE_THE_REPOSITORY_VARIABLE
+#define DISABLE_SIGN_COMPARE_WARNINGS
#include "git-compat-util.h"
#include "environment.h"
diff --git a/match-trees.c b/match-trees.c
index 147b03abf1..a1c8b91eae 100644
--- a/match-trees.c
+++ b/match-trees.c
@@ -1,4 +1,5 @@
#define USE_THE_REPOSITORY_VARIABLE
+#define DISABLE_SIGN_COMPARE_WARNINGS
#include "git-compat-util.h"
#include "hex.h"
diff --git a/mem-pool.c b/mem-pool.c
index a3ba38831d..62441dcc71 100644
--- a/mem-pool.c
+++ b/mem-pool.c
@@ -2,6 +2,8 @@
* Memory Pool implementation logic.
*/
+#define DISABLE_SIGN_COMPARE_WARNINGS
+
#include "git-compat-util.h"
#include "mem-pool.h"
#include "gettext.h"
diff --git a/merge-ll.c b/merge-ll.c
index 62fc625552..b2dc26da4f 100644
--- a/merge-ll.c
+++ b/merge-ll.c
@@ -5,6 +5,7 @@
*/
#define USE_THE_REPOSITORY_VARIABLE
+#define DISABLE_SIGN_COMPARE_WARNINGS
#include "git-compat-util.h"
#include "config.h"
diff --git a/merge-ort.c b/merge-ort.c
index 11029c10be..46e78c3ffa 100644
--- a/merge-ort.c
+++ b/merge-ort.c
@@ -15,6 +15,7 @@
*/
#define USE_THE_REPOSITORY_VARIABLE
+#define DISABLE_SIGN_COMPARE_WARNINGS
#include "git-compat-util.h"
#include "merge-ort.h"
diff --git a/merge-recursive.c b/merge-recursive.c
index ed64a4c537..5dfaf32b2c 100644
--- a/merge-recursive.c
+++ b/merge-recursive.c
@@ -5,6 +5,7 @@
*/
#define USE_THE_REPOSITORY_VARIABLE
+#define DISABLE_SIGN_COMPARE_WARNINGS
#include "git-compat-util.h"
#include "merge-recursive.h"
diff --git a/merge.c b/merge.c
index fe3efa4b24..5ecaf508e4 100644
--- a/merge.c
+++ b/merge.c
@@ -25,11 +25,11 @@ int try_merge_command(struct repository *r,
const char *head_arg, struct commit_list *remotes)
{
struct child_process cmd = CHILD_PROCESS_INIT;
- int i, ret;
+ int ret;
struct commit_list *j;
strvec_pushf(&cmd.args, "merge-%s", strategy);
- for (i = 0; i < xopts_nr; i++)
+ for (size_t i = 0; i < xopts_nr; i++)
strvec_pushf(&cmd.args, "--%s", xopts[i]);
for (j = common; j; j = j->next)
strvec_push(&cmd.args, merge_argument(j->item));
diff --git a/midx-write.c b/midx-write.c
index bcd1d50eb0..0066594fa6 100644
--- a/midx-write.c
+++ b/midx-write.c
@@ -1,3 +1,5 @@
+#define DISABLE_SIGN_COMPARE_WARNINGS
+
#include "git-compat-util.h"
#include "abspath.h"
#include "config.h"
diff --git a/midx.c b/midx.c
index e0eae1c25e..f8a75cafd4 100644
--- a/midx.c
+++ b/midx.c
@@ -1,3 +1,5 @@
+#define DISABLE_SIGN_COMPARE_WARNINGS
+
#include "git-compat-util.h"
#include "config.h"
#include "dir.h"
diff --git a/name-hash.c b/name-hash.c
index 95528e3bcd..d66de1cdfd 100644
--- a/name-hash.c
+++ b/name-hash.c
@@ -7,6 +7,7 @@
*/
#define USE_THE_REPOSITORY_VARIABLE
+#define DISABLE_SIGN_COMPARE_WARNINGS
#include "git-compat-util.h"
#include "environment.h"
diff --git a/notes-merge.c b/notes-merge.c
index dadbbabf86..8d701ed428 100644
--- a/notes-merge.c
+++ b/notes-merge.c
@@ -1,4 +1,5 @@
#define USE_THE_REPOSITORY_VARIABLE
+#define DISABLE_SIGN_COMPARE_WARNINGS
#include "git-compat-util.h"
#include "advice.h"
diff --git a/notes.c b/notes.c
index f4f18daf07..f534423050 100644
--- a/notes.c
+++ b/notes.c
@@ -1,4 +1,5 @@
#define USE_THE_REPOSITORY_VARIABLE
+#define DISABLE_SIGN_COMPARE_WARNINGS
#include "git-compat-util.h"
#include "config.h"
diff --git a/object-file-convert.c b/object-file-convert.c
index 3887d6d57b..eba71955cf 100644
--- a/object-file-convert.c
+++ b/object-file-convert.c
@@ -1,4 +1,5 @@
#define USE_THE_REPOSITORY_VARIABLE
+#define DISABLE_SIGN_COMPARE_WARNINGS
#include "git-compat-util.h"
#include "gettext.h"
diff --git a/object-file.c b/object-file.c
index 891eaa2b4b..5b792b3dd4 100644
--- a/object-file.c
+++ b/object-file.c
@@ -8,6 +8,7 @@
*/
#define USE_THE_REPOSITORY_VARIABLE
+#define DISABLE_SIGN_COMPARE_WARNINGS
#include "git-compat-util.h"
#include "abspath.h"
diff --git a/object-name.c b/object-name.c
index a563635a8c..88d1313028 100644
--- a/object-name.c
+++ b/object-name.c
@@ -1,4 +1,5 @@
#define USE_THE_REPOSITORY_VARIABLE
+#define DISABLE_SIGN_COMPARE_WARNINGS
#include "git-compat-util.h"
#include "object-name.h"
diff --git a/object.c b/object.c
index 94ea8fb8d2..100bf9b8d1 100644
--- a/object.c
+++ b/object.c
@@ -1,4 +1,5 @@
#define USE_THE_REPOSITORY_VARIABLE
+#define DISABLE_SIGN_COMPARE_WARNINGS
#include "git-compat-util.h"
#include "gettext.h"
diff --git a/oss-fuzz/fuzz-parse-attr-line.c b/oss-fuzz/fuzz-parse-attr-line.c
index 45a4c4e53c..e0e4bc6358 100644
--- a/oss-fuzz/fuzz-parse-attr-line.c
+++ b/oss-fuzz/fuzz-parse-attr-line.c
@@ -1,3 +1,5 @@
+#define DISABLE_SIGN_COMPARE_WARNINGS
+
#include "git-compat-util.h"
#include <stddef.h>
#include <stdlib.h>
diff --git a/pack-bitmap-write.c b/pack-bitmap-write.c
index 49758e2525..4f8be53c2b 100644
--- a/pack-bitmap-write.c
+++ b/pack-bitmap-write.c
@@ -1,4 +1,5 @@
#define USE_THE_REPOSITORY_VARIABLE
+#define DISABLE_SIGN_COMPARE_WARNINGS
#include "git-compat-util.h"
#include "environment.h"
diff --git a/pack-bitmap.c b/pack-bitmap.c
index 7aa2410d9b..bceb6da042 100644
--- a/pack-bitmap.c
+++ b/pack-bitmap.c
@@ -1,3 +1,5 @@
+#define DISABLE_SIGN_COMPARE_WARNINGS
+
#include "git-compat-util.h"
#include "commit.h"
#include "gettext.h"
diff --git a/pack-check.c b/pack-check.c
index e883dae3f2..8d9f6da7ce 100644
--- a/pack-check.c
+++ b/pack-check.c
@@ -1,4 +1,5 @@
#define USE_THE_REPOSITORY_VARIABLE
+#define DISABLE_SIGN_COMPARE_WARNINGS
#include "git-compat-util.h"
#include "environment.h"
diff --git a/packfile.c b/packfile.c
index 9c4bd81a8c..cc7ab6403a 100644
--- a/packfile.c
+++ b/packfile.c
@@ -1,3 +1,4 @@
+#define DISABLE_SIGN_COMPARE_WARNINGS
#include "git-compat-util.h"
#include "environment.h"
diff --git a/parallel-checkout.c b/parallel-checkout.c
index 01736f1352..7cc6b30528 100644
--- a/parallel-checkout.c
+++ b/parallel-checkout.c
@@ -1,4 +1,5 @@
#define USE_THE_REPOSITORY_VARIABLE
+#define DISABLE_SIGN_COMPARE_WARNINGS
#include "git-compat-util.h"
#include "config.h"
diff --git a/path.c b/path.c
index 4dcf3c8d40..07964f5d32 100644
--- a/path.c
+++ b/path.c
@@ -1142,12 +1142,12 @@ int strbuf_normalize_path(struct strbuf *src)
*/
int longest_ancestor_length(const char *path, struct string_list *prefixes)
{
- int i, max_len = -1;
+ int max_len = -1;
if (!strcmp(path, "/"))
return -1;
- for (i = 0; i < prefixes->nr; i++) {
+ for (size_t i = 0; i < prefixes->nr; i++) {
const char *ceil = prefixes->items[i].string;
int len = strlen(ceil);
diff --git a/pathspec.c b/pathspec.c
index 0fc6f84a6e..89663645e1 100644
--- a/pathspec.c
+++ b/pathspec.c
@@ -1,4 +1,5 @@
#define USE_THE_REPOSITORY_VARIABLE
+#define DISABLE_SIGN_COMPARE_WARNINGS
#include "git-compat-util.h"
#include "abspath.h"
diff --git a/pkt-line.c b/pkt-line.c
index 24479eae4d..a5bcbc96fb 100644
--- a/pkt-line.c
+++ b/pkt-line.c
@@ -39,7 +39,6 @@ static int packet_trace_pack(const char *buf, unsigned int len, int sideband)
static void packet_trace(const char *buf, unsigned int len, int write)
{
- int i;
struct strbuf out;
static int in_pack, sideband;
@@ -72,7 +71,7 @@ static void packet_trace(const char *buf, unsigned int len, int write)
get_trace_prefix(), write ? '>' : '<');
/* XXX we should really handle printable utf8 */
- for (i = 0; i < len; i++) {
+ for (unsigned int i = 0; i < len; i++) {
/* suppress newlines */
if (buf[i] == '\n')
continue;
@@ -338,30 +337,32 @@ int write_packetized_from_buf_no_flush_count(const char *src_in, size_t len,
}
static int get_packet_data(int fd, char **src_buf, size_t *src_size,
- void *dst, unsigned size, int options)
+ void *dst, size_t size, int options)
{
- ssize_t ret;
+ size_t bytes_read;
if (fd >= 0 && src_buf && *src_buf)
BUG("multiple sources given to packet_read");
/* Read up to "size" bytes from our source, whatever it is. */
if (src_buf && *src_buf) {
- ret = size < *src_size ? size : *src_size;
- memcpy(dst, *src_buf, ret);
- *src_buf += ret;
- *src_size -= ret;
+ bytes_read = size < *src_size ? size : *src_size;
+ memcpy(dst, *src_buf, bytes_read);
+ *src_buf += bytes_read;
+ *src_size -= bytes_read;
} else {
- ret = read_in_full(fd, dst, size);
+ ssize_t ret = read_in_full(fd, dst, size);
if (ret < 0) {
if (options & PACKET_READ_GENTLE_ON_READ_ERROR)
return error_errno(_("read error"));
die_errno(_("read error"));
}
+
+ bytes_read = (size_t) ret;
}
/* And complain if we didn't get enough bytes to satisfy the read. */
- if (ret != size) {
+ if (bytes_read != size) {
if (options & PACKET_READ_GENTLE_ON_EOF)
return -1;
@@ -370,7 +371,7 @@ static int get_packet_data(int fd, char **src_buf, size_t *src_size,
die(_("the remote end hung up unexpectedly"));
}
- return ret;
+ return 0;
}
int packet_length(const char lenbuf_hex[4], size_t size)
diff --git a/preload-index.c b/preload-index.c
index 7926eb09a6..ab94d6f399 100644
--- a/preload-index.c
+++ b/preload-index.c
@@ -3,6 +3,7 @@
*/
#define USE_THE_REPOSITORY_VARIABLE
+#define DISABLE_SIGN_COMPARE_WARNINGS
#include "git-compat-util.h"
#include "pathspec.h"
diff --git a/pretty.c b/pretty.c
index 098378720a..0bc8ad8a9a 100644
--- a/pretty.c
+++ b/pretty.c
@@ -1,4 +1,5 @@
#define USE_THE_REPOSITORY_VARIABLE
+#define DISABLE_SIGN_COMPARE_WARNINGS
#include "git-compat-util.h"
#include "config.h"
diff --git a/progress.c b/progress.c
index 0d44c18edc..a8fdfceb5c 100644
--- a/progress.c
+++ b/progress.c
@@ -10,6 +10,7 @@
#define GIT_TEST_PROGRESS_ONLY
#define USE_THE_REPOSITORY_VARIABLE
+#define DISABLE_SIGN_COMPARE_WARNINGS
#include "git-compat-util.h"
#include "pager.h"
diff --git a/pseudo-merge.c b/pseudo-merge.c
index bb59965ed2..971f54cfe1 100644
--- a/pseudo-merge.c
+++ b/pseudo-merge.c
@@ -1,4 +1,5 @@
#define USE_THE_REPOSITORY_VARIABLE
+#define DISABLE_SIGN_COMPARE_WARNINGS
#include "git-compat-util.h"
#include "pseudo-merge.h"
diff --git a/quote.c b/quote.c
index 3c05194496..b9f6bdc775 100644
--- a/quote.c
+++ b/quote.c
@@ -1,3 +1,5 @@
+#define DISABLE_SIGN_COMPARE_WARNINGS
+
#include "git-compat-util.h"
#include "path.h"
#include "quote.h"
diff --git a/range-diff.c b/range-diff.c
index 10885ba301..eea172bcc9 100644
--- a/range-diff.c
+++ b/range-diff.c
@@ -1,4 +1,5 @@
#define USE_THE_REPOSITORY_VARIABLE
+#define DISABLE_SIGN_COMPARE_WARNINGS
#include "git-compat-util.h"
#include "environment.h"
diff --git a/read-cache.c b/read-cache.c
index 01d0b3ad22..15d79839c2 100644
--- a/read-cache.c
+++ b/read-cache.c
@@ -5,6 +5,7 @@
*/
#define USE_THE_REPOSITORY_VARIABLE
+#define DISABLE_SIGN_COMPARE_WARNINGS
#include "git-compat-util.h"
#include "bulk-checkin.h"
diff --git a/ref-filter.c b/ref-filter.c
index 84c6036107..23054694c2 100644
--- a/ref-filter.c
+++ b/ref-filter.c
@@ -1,4 +1,5 @@
#define USE_THE_REPOSITORY_VARIABLE
+#define DISABLE_SIGN_COMPARE_WARNINGS
#include "git-compat-util.h"
#include "environment.h"
diff --git a/reflog.c b/reflog.c
index aeab78c9b7..1b5f031f6d 100644
--- a/reflog.c
+++ b/reflog.c
@@ -1,4 +1,5 @@
#define USE_THE_REPOSITORY_VARIABLE
+#define DISABLE_SIGN_COMPARE_WARNINGS
#include "git-compat-util.h"
#include "gettext.h"
diff --git a/refs.c b/refs.c
index bc0a60c186..7dd5e9fa33 100644
--- a/refs.c
+++ b/refs.c
@@ -3,6 +3,7 @@
*/
#define USE_THE_REPOSITORY_VARIABLE
+#define DISABLE_SIGN_COMPARE_WARNINGS
#include "git-compat-util.h"
#include "advice.h"
diff --git a/refs/debug.c b/refs/debug.c
index a893ae0c90..fbc4df08b4 100644
--- a/refs/debug.c
+++ b/refs/debug.c
@@ -83,9 +83,8 @@ static void print_update(int i, const char *refname,
static void print_transaction(struct ref_transaction *transaction)
{
- int i;
trace_printf_key(&trace_refs, "transaction {\n");
- for (i = 0; i < transaction->nr; i++) {
+ for (size_t i = 0; i < transaction->nr; i++) {
struct ref_update *u = transaction->updates[i];
print_update(i, u->refname, &u->old_oid, &u->new_oid, u->flags,
u->type, u->msg);
diff --git a/refs/files-backend.c b/refs/files-backend.c
index 4e3545de49..467fe347fa 100644
--- a/refs/files-backend.c
+++ b/refs/files-backend.c
@@ -1,4 +1,5 @@
#define USE_THE_REPOSITORY_VARIABLE
+#define DISABLE_SIGN_COMPARE_WARNINGS
#include "../git-compat-util.h"
#include "../abspath.h"
diff --git a/refs/iterator.c b/refs/iterator.c
index 8e999d81fc..d25e568bf0 100644
--- a/refs/iterator.c
+++ b/refs/iterator.c
@@ -3,6 +3,8 @@
* documentation about the design and use of reference iterators.
*/
+#define DISABLE_SIGN_COMPARE_WARNINGS
+
#include "git-compat-util.h"
#include "refs.h"
#include "refs/refs-internal.h"
diff --git a/refs/packed-backend.c b/refs/packed-backend.c
index 3406f1e71d..a7b6f74b6e 100644
--- a/refs/packed-backend.c
+++ b/refs/packed-backend.c
@@ -1,4 +1,5 @@
#define USE_THE_REPOSITORY_VARIABLE
+#define DISABLE_SIGN_COMPARE_WARNINGS
#include "../git-compat-util.h"
#include "../config.h"
diff --git a/refspec.c b/refspec.c
index 994901f55b..6d86e04442 100644
--- a/refspec.c
+++ b/refspec.c
@@ -1,4 +1,5 @@
#define USE_THE_REPOSITORY_VARIABLE
+#define DISABLE_SIGN_COMPARE_WARNINGS
#include "git-compat-util.h"
#include "gettext.h"
diff --git a/reftable/system.h b/reftable/system.h
index 7d5f803eeb..5274eca1d0 100644
--- a/reftable/system.h
+++ b/reftable/system.h
@@ -11,6 +11,8 @@ https://developers.google.com/open-source/licenses/bsd
/* This header glues the reftable library to the rest of Git */
+#define DISABLE_SIGN_COMPARE_WARNINGS
+
#include "git-compat-util.h"
/*
diff --git a/remote-curl.c b/remote-curl.c
index 9a71e04301..a24e3a8b9a 100644
--- a/remote-curl.c
+++ b/remote-curl.c
@@ -1,4 +1,5 @@
#define USE_THE_REPOSITORY_VARIABLE
+#define DISABLE_SIGN_COMPARE_WARNINGS
#include "git-compat-util.h"
#include "git-curl-compat.h"
diff --git a/remote.c b/remote.c
index 4ec5d3f47b..b80e810a90 100644
--- a/remote.c
+++ b/remote.c
@@ -1,4 +1,5 @@
#define USE_THE_REPOSITORY_VARIABLE
+#define DISABLE_SIGN_COMPARE_WARNINGS
#include "git-compat-util.h"
#include "abspath.h"
diff --git a/rerere.c b/rerere.c
index d01e98bf65..e7fa6426b3 100644
--- a/rerere.c
+++ b/rerere.c
@@ -1,4 +1,5 @@
#define USE_THE_REPOSITORY_VARIABLE
+#define DISABLE_SIGN_COMPARE_WARNINGS
#include "git-compat-util.h"
#include "abspath.h"
diff --git a/resolve-undo.c b/resolve-undo.c
index 8c9911affb..b5a9dfb4ac 100644
--- a/resolve-undo.c
+++ b/resolve-undo.c
@@ -1,4 +1,5 @@
#define USE_THE_REPOSITORY_VARIABLE
+#define DISABLE_SIGN_COMPARE_WARNINGS
#include "git-compat-util.h"
#include "dir.h"
diff --git a/revision.c b/revision.c
index 57ca521c55..474fa1e767 100644
--- a/revision.c
+++ b/revision.c
@@ -1,4 +1,5 @@
#define USE_THE_REPOSITORY_VARIABLE
+#define DISABLE_SIGN_COMPARE_WARNINGS
#include "git-compat-util.h"
#include "config.h"
diff --git a/run-command.c b/run-command.c
index 94f2f3079f..402138b8b5 100644
--- a/run-command.c
+++ b/run-command.c
@@ -1,4 +1,5 @@
#define USE_THE_REPOSITORY_VARIABLE
+#define DISABLE_SIGN_COMPARE_WARNINGS
#include "git-compat-util.h"
#include "run-command.h"
diff --git a/scalar.c b/scalar.c
index ac0cb579d3..f24bcd0169 100644
--- a/scalar.c
+++ b/scalar.c
@@ -379,7 +379,7 @@ static int delete_enlistment(struct strbuf *enlistment)
offset = offset_1st_component(enlistment->buf);
path_sep = find_last_dir_sep(enlistment->buf + offset);
strbuf_add(&parent, enlistment->buf,
- path_sep ? path_sep - enlistment->buf : offset);
+ path_sep ? (size_t) (path_sep - enlistment->buf) : offset);
if (chdir(parent.buf) < 0) {
int res = error_errno(_("could not switch to '%s'"), parent.buf);
strbuf_release(&parent);
@@ -654,7 +654,7 @@ static int cmd_reconfigure(int argc, const char **argv)
NULL
};
struct string_list scalar_repos = STRING_LIST_INIT_DUP;
- int i, res = 0;
+ int res = 0;
struct strbuf commondir = STRBUF_INIT, gitdir = STRBUF_INIT;
argc = parse_options(argc, argv, NULL, options,
@@ -672,7 +672,7 @@ static int cmd_reconfigure(int argc, const char **argv)
git_config(get_scalar_repos, &scalar_repos);
- for (i = 0; i < scalar_repos.nr; i++) {
+ for (size_t i = 0; i < scalar_repos.nr; i++) {
int succeeded = 0;
struct repository *old_repo, r = { NULL };
const char *dir = scalar_repos.items[i].string;
diff --git a/send-pack.c b/send-pack.c
index 6677c44e8a..7e83213683 100644
--- a/send-pack.c
+++ b/send-pack.c
@@ -72,7 +72,6 @@ static int pack_objects(int fd, struct ref *refs, struct oid_array *advertised,
*/
struct child_process po = CHILD_PROCESS_INIT;
FILE *po_in;
- int i;
int rc;
trace2_region_enter("send_pack", "pack_objects", the_repository);
@@ -104,9 +103,9 @@ static int pack_objects(int fd, struct ref *refs, struct oid_array *advertised,
* parameters by writing to the pipe.
*/
po_in = xfdopen(po.in, "w");
- for (i = 0; i < advertised->nr; i++)
+ for (size_t i = 0; i < advertised->nr; i++)
feed_object(&advertised->oid[i], po_in, 1);
- for (i = 0; i < negotiated->nr; i++)
+ for (size_t i = 0; i < negotiated->nr; i++)
feed_object(&negotiated->oid[i], po_in, 1);
while (refs) {
diff --git a/sequencer.c b/sequencer.c
index 459066e43b..407ee4e90f 100644
--- a/sequencer.c
+++ b/sequencer.c
@@ -1,4 +1,5 @@
#define USE_THE_REPOSITORY_VARIABLE
+#define DISABLE_SIGN_COMPARE_WARNINGS
#include "git-compat-util.h"
#include "abspath.h"
diff --git a/serve.c b/serve.c
index d674764a25..c8694e3751 100644
--- a/serve.c
+++ b/serve.c
@@ -163,12 +163,11 @@ void protocol_v2_advertise_capabilities(void)
{
struct strbuf capability = STRBUF_INIT;
struct strbuf value = STRBUF_INIT;
- int i;
/* serve by default supports v2 */
packet_write_fmt(1, "version 2\n");
- for (i = 0; i < ARRAY_SIZE(capabilities); i++) {
+ for (size_t i = 0; i < ARRAY_SIZE(capabilities); i++) {
struct protocol_capability *c = &capabilities[i];
if (c->advertise(the_repository, &value)) {
@@ -194,12 +193,10 @@ void protocol_v2_advertise_capabilities(void)
static struct protocol_capability *get_capability(const char *key, const char **value)
{
- int i;
-
if (!key)
return NULL;
- for (i = 0; i < ARRAY_SIZE(capabilities); i++) {
+ for (size_t i = 0; i < ARRAY_SIZE(capabilities); i++) {
struct protocol_capability *c = &capabilities[i];
const char *out;
if (!skip_prefix(key, c->name, &out))
diff --git a/server-info.c b/server-info.c
index c5af4cd98a..ef2f3f4b5c 100644
--- a/server-info.c
+++ b/server-info.c
@@ -1,4 +1,5 @@
#define USE_THE_REPOSITORY_VARIABLE
+#define DISABLE_SIGN_COMPARE_WARNINGS
#include "git-compat-util.h"
#include "dir.h"
diff --git a/setup.c b/setup.c
index 39ff48d9dc..8a488f3e7c 100644
--- a/setup.c
+++ b/setup.c
@@ -1,4 +1,5 @@
#define USE_THE_REPOSITORY_VARIABLE
+#define DISABLE_SIGN_COMPARE_WARNINGS
#include "git-compat-util.h"
#include "abspath.h"
diff --git a/shallow.c b/shallow.c
index 4bb1518dbc..82a8da3d73 100644
--- a/shallow.c
+++ b/shallow.c
@@ -1,4 +1,5 @@
#define USE_THE_REPOSITORY_VARIABLE
+#define DISABLE_SIGN_COMPARE_WARNINGS
#include "git-compat-util.h"
#include "hex.h"
diff --git a/sideband.c b/sideband.c
index 02805573fa..251e9615ed 100644
--- a/sideband.c
+++ b/sideband.c
@@ -1,4 +1,5 @@
#define USE_THE_REPOSITORY_VARIABLE
+#define DISABLE_SIGN_COMPARE_WARNINGS
#include "git-compat-util.h"
#include "color.h"
diff --git a/sparse-index.c b/sparse-index.c
index 2107840bfc..5634abafaa 100644
--- a/sparse-index.c
+++ b/sparse-index.c
@@ -1,4 +1,5 @@
#define USE_THE_REPOSITORY_VARIABLE
+#define DISABLE_SIGN_COMPARE_WARNINGS
#include "git-compat-util.h"
#include "environment.h"
diff --git a/split-index.c b/split-index.c
index cfbc773e6c..4c74c4adda 100644
--- a/split-index.c
+++ b/split-index.c
@@ -1,4 +1,5 @@
#define USE_THE_REPOSITORY_VARIABLE
+#define DISABLE_SIGN_COMPARE_WARNINGS
#include "git-compat-util.h"
#include "gettext.h"
diff --git a/strbuf.c b/strbuf.c
index 3d2189a7f6..8ddd4b06c5 100644
--- a/strbuf.c
+++ b/strbuf.c
@@ -1,3 +1,5 @@
+#define DISABLE_SIGN_COMPARE_WARNINGS
+
#include "git-compat-util.h"
#include "gettext.h"
#include "hex-ll.h"
diff --git a/string-list.c b/string-list.c
index 954569f381..bf061fec56 100644
--- a/string-list.c
+++ b/string-list.c
@@ -1,3 +1,5 @@
+#define DISABLE_SIGN_COMPARE_WARNINGS
+
#include "git-compat-util.h"
#include "string-list.h"
diff --git a/strvec.c b/strvec.c
index d67596e571..f8de79f557 100644
--- a/strvec.c
+++ b/strvec.c
@@ -130,8 +130,7 @@ void strvec_split(struct strvec *array, const char *to_split)
void strvec_clear(struct strvec *array)
{
if (array->v != empty_strvec) {
- int i;
- for (i = 0; i < array->nr; i++)
+ for (size_t i = 0; i < array->nr; i++)
free((char *)array->v[i]);
free(array->v);
}
diff --git a/submodule-config.c b/submodule-config.c
index 9c8c37b259..a25059ed7f 100644
--- a/submodule-config.c
+++ b/submodule-config.c
@@ -1,4 +1,5 @@
#define USE_THE_REPOSITORY_VARIABLE
+#define DISABLE_SIGN_COMPARE_WARNINGS
#include "git-compat-util.h"
#include "dir.h"
diff --git a/submodule.c b/submodule.c
index 7ec564854d..ed1441923d 100644
--- a/submodule.c
+++ b/submodule.c
@@ -1,4 +1,5 @@
#define USE_THE_REPOSITORY_VARIABLE
+#define DISABLE_SIGN_COMPARE_WARNINGS
#include "git-compat-util.h"
#include "abspath.h"
diff --git a/symlinks.c b/symlinks.c
index b29e340c2d..9cc090d42c 100644
--- a/symlinks.c
+++ b/symlinks.c
@@ -1,3 +1,5 @@
+#define DISABLE_SIGN_COMPARE_WARNINGS
+
#include "git-compat-util.h"
#include "gettext.h"
#include "setup.h"
diff --git a/t/helper/test-bloom.c b/t/helper/test-bloom.c
index 97541daf71..14e075c1a1 100644
--- a/t/helper/test-bloom.c
+++ b/t/helper/test-bloom.c
@@ -11,30 +11,25 @@ static struct bloom_filter_settings settings = DEFAULT_BLOOM_FILTER_SETTINGS;
static void add_string_to_filter(const char *data, struct bloom_filter *filter) {
struct bloom_key key;
- int i;
fill_bloom_key(data, strlen(data), &key, &settings);
printf("Hashes:");
- for (i = 0; i < settings.num_hashes; i++){
+ for (size_t i = 0; i < settings.num_hashes; i++)
printf("0x%08x|", key.hashes[i]);
- }
printf("\n");
add_key_to_filter(&key, filter, &settings);
clear_bloom_key(&key);
}
static void print_bloom_filter(struct bloom_filter *filter) {
- int i;
-
if (!filter) {
printf("No filter.\n");
return;
}
printf("Filter_Length:%d\n", (int)filter->len);
printf("Filter_Data:");
- for (i = 0; i < filter->len; i++) {
+ for (size_t i = 0; i < filter->len; i++)
printf("%02x|", filter->data[i]);
- }
printf("\n");
}
diff --git a/t/helper/test-cache-tree.c b/t/helper/test-cache-tree.c
index 5cdef3ebef..3ae45cec3b 100644
--- a/t/helper/test-cache-tree.c
+++ b/t/helper/test-cache-tree.c
@@ -1,4 +1,5 @@
#define USE_THE_REPOSITORY_VARIABLE
+#define DISABLE_SIGN_COMPARE_WARNINGS
#include "test-tool.h"
#include "gettext.h"
diff --git a/t/helper/test-config.c b/t/helper/test-config.c
index 33247f0e92..75e028ab2a 100644
--- a/t/helper/test-config.c
+++ b/t/helper/test-config.c
@@ -1,4 +1,5 @@
#define USE_THE_REPOSITORY_VARIABLE
+#define DISABLE_SIGN_COMPARE_WARNINGS
#include "test-tool.h"
#include "config.h"
diff --git a/t/helper/test-csprng.c b/t/helper/test-csprng.c
index 65d14973c5..a4a0aca617 100644
--- a/t/helper/test-csprng.c
+++ b/t/helper/test-csprng.c
@@ -1,7 +1,6 @@
#include "test-tool.h"
#include "git-compat-util.h"
-
int cmd__csprng(int argc, const char **argv)
{
unsigned long count;
@@ -12,7 +11,7 @@ int cmd__csprng(int argc, const char **argv)
return 2;
}
- count = (argc == 2) ? strtoul(argv[1], NULL, 0) : -1L;
+ count = (argc == 2) ? strtoul(argv[1], NULL, 0) : ULONG_MAX;
while (count) {
unsigned long chunk = count < sizeof(buf) ? count : sizeof(buf);
diff --git a/t/helper/test-drop-caches.c b/t/helper/test-drop-caches.c
index 73e551cfc2..7055d94354 100644
--- a/t/helper/test-drop-caches.c
+++ b/t/helper/test-drop-caches.c
@@ -1,3 +1,5 @@
+#define DISABLE_SIGN_COMPARE_WARNINGS
+
#include "test-tool.h"
#include "git-compat-util.h"
diff --git a/t/helper/test-dump-fsmonitor.c b/t/helper/test-dump-fsmonitor.c
index 1b7f37a84f..efd017ca35 100644
--- a/t/helper/test-dump-fsmonitor.c
+++ b/t/helper/test-dump-fsmonitor.c
@@ -8,7 +8,6 @@
int cmd__dump_fsmonitor(int ac UNUSED, const char **av UNUSED)
{
struct index_state *istate = the_repository->index;
- int i;
setup_git_directory();
if (do_read_index(istate, the_repository->index_file, 0) < 0)
@@ -19,7 +18,7 @@ int cmd__dump_fsmonitor(int ac UNUSED, const char **av UNUSED)
}
printf("fsmonitor last update %s\n", istate->fsmonitor_last_update);
- for (i = 0; i < istate->cache_nr; i++)
+ for (size_t i = 0; i < istate->cache_nr; i++)
printf((istate->cache[i]->ce_flags & CE_FSMONITOR_VALID) ? "+" : "-");
return 0;
diff --git a/t/helper/test-dump-split-index.c b/t/helper/test-dump-split-index.c
index a6720faf9c..f855a3862c 100644
--- a/t/helper/test-dump-split-index.c
+++ b/t/helper/test-dump-split-index.c
@@ -16,7 +16,6 @@ static void show_bit(size_t pos, void *data UNUSED)
int cmd__dump_split_index(int ac UNUSED, const char **av)
{
struct split_index *si;
- int i;
setup_git_directory();
@@ -28,7 +27,7 @@ int cmd__dump_split_index(int ac UNUSED, const char **av)
return 0;
}
printf("base %s\n", oid_to_hex(&si->base_oid));
- for (i = 0; i < the_repository->index->cache_nr; i++) {
+ for (size_t i = 0; i < the_repository->index->cache_nr; i++) {
struct cache_entry *ce = the_repository->index->cache[i];
printf("%06o %s %d\t%s\n", ce->ce_mode,
oid_to_hex(&ce->oid), ce_stage(ce), ce->name);
diff --git a/t/helper/test-dump-untracked-cache.c b/t/helper/test-dump-untracked-cache.c
index b2e70837a9..01a109496b 100644
--- a/t/helper/test-dump-untracked-cache.c
+++ b/t/helper/test-dump-untracked-cache.c
@@ -23,7 +23,7 @@ static int compare_dir(const void *a_, const void *b_)
static void dump(struct untracked_cache_dir *ucd, struct strbuf *base)
{
- int i, len;
+ int len;
QSORT(ucd->untracked, ucd->untracked_nr, compare_untracked);
QSORT(ucd->dirs, ucd->dirs_nr, compare_dir);
len = base->len;
@@ -37,9 +37,9 @@ static void dump(struct untracked_cache_dir *ucd, struct strbuf *base)
if (ucd->valid)
fputs(" valid", stdout);
printf("\n");
- for (i = 0; i < ucd->untracked_nr; i++)
+ for (size_t i = 0; i < ucd->untracked_nr; i++)
printf("%s\n", ucd->untracked[i]);
- for (i = 0; i < ucd->dirs_nr; i++)
+ for (size_t i = 0; i < ucd->dirs_nr; i++)
dump(ucd->dirs[i], base);
strbuf_setlen(base, len);
}
diff --git a/t/helper/test-genrandom.c b/t/helper/test-genrandom.c
index 99b8dc1e2d..51b67f2f87 100644
--- a/t/helper/test-genrandom.c
+++ b/t/helper/test-genrandom.c
@@ -22,7 +22,7 @@ int cmd__genrandom(int argc, const char **argv)
next = next * 11 + *c;
} while (*c++);
- count = (argc == 3) ? strtoul(argv[2], NULL, 0) : -1L;
+ count = (argc == 3) ? strtoul(argv[2], NULL, 0) : ULONG_MAX;
while (count--) {
next = next * 1103515245 + 12345;
diff --git a/t/helper/test-genzeros.c b/t/helper/test-genzeros.c
index 47af843b68..b895436a32 100644
--- a/t/helper/test-genzeros.c
+++ b/t/helper/test-genzeros.c
@@ -1,3 +1,5 @@
+#define DISABLE_SIGN_COMPARE_WARNINGS
+
#include "test-tool.h"
#include "git-compat-util.h"
diff --git a/t/helper/test-hash-speed.c b/t/helper/test-hash-speed.c
index 7de822af51..80df1aae66 100644
--- a/t/helper/test-hash-speed.c
+++ b/t/helper/test-hash-speed.c
@@ -16,12 +16,11 @@ int cmd__hash_speed(int ac, const char **av)
unsigned char hash[GIT_MAX_RAWSZ];
clock_t initial, start, end;
unsigned bufsizes[] = { 64, 256, 1024, 8192, 16384 };
- int i;
void *p;
const struct git_hash_algo *algo = NULL;
if (ac == 2) {
- for (i = 1; i < GIT_HASH_NALGOS; i++) {
+ for (size_t i = 1; i < GIT_HASH_NALGOS; i++) {
if (!strcmp(av[1], hash_algos[i].name)) {
algo = &hash_algos[i];
break;
@@ -36,7 +35,7 @@ int cmd__hash_speed(int ac, const char **av)
printf("algo: %s\n", algo->name);
- for (i = 0; i < ARRAY_SIZE(bufsizes); i++) {
+ for (size_t i = 0; i < ARRAY_SIZE(bufsizes); i++) {
unsigned long j, kb;
double kb_per_sec;
p = xcalloc(1, bufsizes[i]);
diff --git a/t/helper/test-mergesort.c b/t/helper/test-mergesort.c
index 328bfe2977..791e128793 100644
--- a/t/helper/test-mergesort.c
+++ b/t/helper/test-mergesort.c
@@ -1,3 +1,5 @@
+#define DISABLE_SIGN_COMPARE_WARNINGS
+
#include "test-tool.h"
#include "mem-pool.h"
#include "mergesort.h"
diff --git a/t/helper/test-parse-options.c b/t/helper/test-parse-options.c
index 5da359486c..bfe45ec68b 100644
--- a/t/helper/test-parse-options.c
+++ b/t/helper/test-parse-options.c
@@ -174,7 +174,6 @@ int cmd__parse_options(int argc, const char **argv)
OPT_ALIAS('Z', "alias-target", "alias-source"),
OPT_END(),
};
- int i;
int ret = 0;
trace2_cmd_name("_parse_");
@@ -198,10 +197,10 @@ int cmd__parse_options(int argc, const char **argv)
show(&expect, &ret, "dry run: %s", dry_run ? "yes" : "no");
show(&expect, &ret, "file: %s", file ? file : "(not set)");
- for (i = 0; i < list.nr; i++)
+ for (size_t i = 0; i < list.nr; i++)
show(&expect, &ret, "list: %s", list.items[i].string);
- for (i = 0; i < argc; i++)
+ for (int i = 0; i < argc; i++)
show(&expect, &ret, "arg %02d: %s", i, argv[i]);
expect.strdup_strings = 1;
diff --git a/t/helper/test-path-utils.c b/t/helper/test-path-utils.c
index 3129aa28fd..72ac8d1b1b 100644
--- a/t/helper/test-path-utils.c
+++ b/t/helper/test-path-utils.c
@@ -1,4 +1,5 @@
#define USE_THE_REPOSITORY_VARIABLE
+#define DISABLE_SIGN_COMPARE_WARNINGS
#include "test-tool.h"
#include "abspath.h"
diff --git a/t/helper/test-reach.c b/t/helper/test-reach.c
index 84deee604a..01cf77ae65 100644
--- a/t/helper/test-reach.c
+++ b/t/helper/test-reach.c
@@ -13,7 +13,6 @@
static void print_sorted_commit_ids(struct commit_list *list)
{
- int i;
struct string_list s = STRING_LIST_INIT_DUP;
while (list) {
@@ -23,7 +22,7 @@ static void print_sorted_commit_ids(struct commit_list *list)
string_list_sort(&s);
- for (i = 0; i < s.nr; i++)
+ for (size_t i = 0; i < s.nr; i++)
printf("%s\n", s.items[i].string);
string_list_clear(&s, 0);
diff --git a/t/helper/test-ref-store.c b/t/helper/test-ref-store.c
index 240f6fc29d..1cc05f043a 100644
--- a/t/helper/test-ref-store.c
+++ b/t/helper/test-ref-store.c
@@ -24,14 +24,13 @@ struct flag_definition {
static unsigned int parse_flags(const char *str, struct flag_definition *defs)
{
struct string_list masks = STRING_LIST_INIT_DUP;
- int i = 0;
unsigned int result = 0;
if (!strcmp(str, "0"))
return 0;
string_list_split(&masks, str, ',', 64);
- for (; i < masks.nr; i++) {
+ for (size_t i = 0; i < masks.nr; i++) {
const char *name = masks.items[i].string;
struct flag_definition *def = defs;
int found = 0;
diff --git a/t/helper/test-run-command.c b/t/helper/test-run-command.c
index 61eb1175fe..3719f23cc2 100644
--- a/t/helper/test-run-command.c
+++ b/t/helper/test-run-command.c
@@ -8,6 +8,8 @@
* published by the Free Software Foundation.
*/
+#define DISABLE_SIGN_COMPARE_WARNINGS
+
#include "test-tool.h"
#include "run-command.h"
#include "strvec.h"
diff --git a/t/helper/test-string-list.c b/t/helper/test-string-list.c
index e2aad611d1..6f10c5a435 100644
--- a/t/helper/test-string-list.c
+++ b/t/helper/test-string-list.c
@@ -1,3 +1,5 @@
+#define DISABLE_SIGN_COMPARE_WARNINGS
+
#include "test-tool.h"
#include "strbuf.h"
#include "string-list.h"
diff --git a/t/helper/test-tool.c b/t/helper/test-tool.c
index 1ebb69a5dc..4a7aa993ba 100644
--- a/t/helper/test-tool.c
+++ b/t/helper/test-tool.c
@@ -101,7 +101,6 @@ static NORETURN void die_usage(void)
int cmd_main(int argc, const char **argv)
{
- int i;
const char *working_directory = NULL;
struct option options[] = {
OPT_STRING('C', NULL, &working_directory, "directory",
@@ -120,7 +119,7 @@ int cmd_main(int argc, const char **argv)
if (working_directory && chdir(working_directory) < 0)
die("Could not cd to '%s'", working_directory);
- for (i = 0; i < ARRAY_SIZE(cmds); i++) {
+ for (size_t i = 0; i < ARRAY_SIZE(cmds); i++) {
if (!strcmp(cmds[i].name, argv[1])) {
argv++;
argc--;
diff --git a/t/helper/test-trace2.c b/t/helper/test-trace2.c
index c588c273ce..415df078c1 100644
--- a/t/helper/test-trace2.c
+++ b/t/helper/test-trace2.c
@@ -1,4 +1,5 @@
#define USE_THE_REPOSITORY_VARIABLE
+#define DISABLE_SIGN_COMPARE_WARNINGS
#include "test-tool.h"
#include "strvec.h"
diff --git a/t/unit-tests/lib-reftable.c b/t/unit-tests/lib-reftable.c
index d795dfb7c9..8a69612266 100644
--- a/t/unit-tests/lib-reftable.c
+++ b/t/unit-tests/lib-reftable.c
@@ -1,3 +1,5 @@
+#define DISABLE_SIGN_COMPARE_WARNINGS
+
#include "lib-reftable.h"
#include "test-lib.h"
#include "reftable/constants.h"
diff --git a/t/unit-tests/t-example-decorate.c b/t/unit-tests/t-example-decorate.c
index 8bf0709c41..bfc776e223 100644
--- a/t/unit-tests/t-example-decorate.c
+++ b/t/unit-tests/t-example-decorate.c
@@ -42,9 +42,9 @@ static void t_lookup(struct test_vars *vars)
static void t_loop(struct test_vars *vars)
{
- int i, objects_noticed = 0;
+ int objects_noticed = 0;
- for (i = 0; i < vars->n.size; i++) {
+ for (size_t i = 0; i < vars->n.size; i++) {
if (vars->n.entries[i].base)
objects_noticed++;
}
diff --git a/t/unit-tests/t-prio-queue.c b/t/unit-tests/t-prio-queue.c
index fe6ae37935..a053635000 100644
--- a/t/unit-tests/t-prio-queue.c
+++ b/t/unit-tests/t-prio-queue.c
@@ -25,7 +25,7 @@ static void test_prio_queue(int *input, size_t input_size,
struct prio_queue pq = { intcmp };
int j = 0;
- for (int i = 0; i < input_size; i++) {
+ for (size_t i = 0; i < input_size; i++) {
void *peek, *get;
switch(input[i]) {
case GET:
diff --git a/t/unit-tests/t-reftable-readwrite.c b/t/unit-tests/t-reftable-readwrite.c
index 8c4161f365..6b75a419b9 100644
--- a/t/unit-tests/t-reftable-readwrite.c
+++ b/t/unit-tests/t-reftable-readwrite.c
@@ -6,6 +6,8 @@ license that can be found in the LICENSE file or at
https://developers.google.com/open-source/licenses/bsd
*/
+#define DISABLE_SIGN_COMPARE_WARNINGS
+
#include "test-lib.h"
#include "lib-reftable.h"
#include "reftable/basics.h"
diff --git a/t/unit-tests/t-reftable-stack.c b/t/unit-tests/t-reftable-stack.c
index e208e156f0..aeec195b2b 100644
--- a/t/unit-tests/t-reftable-stack.c
+++ b/t/unit-tests/t-reftable-stack.c
@@ -6,6 +6,8 @@ license that can be found in the LICENSE file or at
https://developers.google.com/open-source/licenses/bsd
*/
+#define DISABLE_SIGN_COMPARE_WARNINGS
+
#include "test-lib.h"
#include "lib-reftable.h"
#include "dir.h"
diff --git a/t/unit-tests/t-trailer.c b/t/unit-tests/t-trailer.c
index e1c6ad7461..184593e73d 100644
--- a/t/unit-tests/t-trailer.c
+++ b/t/unit-tests/t-trailer.c
@@ -1,3 +1,5 @@
+#define DISABLE_SIGN_COMPARE_WARNINGS
+
#include "test-lib.h"
#include "trailer.h"
diff --git a/t/unit-tests/test-lib.c b/t/unit-tests/test-lib.c
index fa1f95965c..87e1f5c201 100644
--- a/t/unit-tests/test-lib.c
+++ b/t/unit-tests/test-lib.c
@@ -1,3 +1,5 @@
+#define DISABLE_SIGN_COMPARE_WARNINGS
+
#include "test-lib.h"
enum result {
diff --git a/tag.c b/tag.c
index beef9571b5..8d9e9e2930 100644
--- a/tag.c
+++ b/tag.c
@@ -1,4 +1,5 @@
#define USE_THE_REPOSITORY_VARIABLE
+#define DISABLE_SIGN_COMPARE_WARNINGS
#include "git-compat-util.h"
#include "environment.h"
diff --git a/tmp-objdir.c b/tmp-objdir.c
index 9da0071cba..659fcdcc29 100644
--- a/tmp-objdir.c
+++ b/tmp-objdir.c
@@ -237,7 +237,6 @@ static int migrate_paths(struct strbuf *src, struct strbuf *dst,
{
size_t src_len = src->len, dst_len = dst->len;
struct string_list paths = STRING_LIST_INIT_DUP;
- int i;
int ret = 0;
if (read_dir_paths(&paths, src->buf) < 0)
@@ -245,7 +244,7 @@ static int migrate_paths(struct strbuf *src, struct strbuf *dst,
paths.cmp = pack_copy_cmp;
string_list_sort(&paths);
- for (i = 0; i < paths.nr; i++) {
+ for (size_t i = 0; i < paths.nr; i++) {
const char *name = paths.items[i].string;
enum finalize_object_file_flags flags_copy = flags;
diff --git a/trace.c b/trace.c
index d8c43773ae..2cfd25942e 100644
--- a/trace.c
+++ b/trace.c
@@ -22,6 +22,7 @@
*/
#define USE_THE_REPOSITORY_VARIABLE
+#define DISABLE_SIGN_COMPARE_WARNINGS
#include "git-compat-util.h"
#include "abspath.h"
diff --git a/trace2.c b/trace2.c
index f894532d05..82d16e2783 100644
--- a/trace2.c
+++ b/trace2.c
@@ -1,3 +1,5 @@
+#define DISABLE_SIGN_COMPARE_WARNINGS
+
#include "git-compat-util.h"
#include "config.h"
#include "repository.h"
diff --git a/trace2/tr2_sysenv.c b/trace2/tr2_sysenv.c
index 048cdd5438..01379c5cad 100644
--- a/trace2/tr2_sysenv.c
+++ b/trace2/tr2_sysenv.c
@@ -1,3 +1,5 @@
+#define DISABLE_SIGN_COMPARE_WARNINGS
+
#include "git-compat-util.h"
#include "config.h"
#include "dir.h"
diff --git a/trace2/tr2_tgt_event.c b/trace2/tr2_tgt_event.c
index 45b0850a5e..69ee40449f 100644
--- a/trace2/tr2_tgt_event.c
+++ b/trace2/tr2_tgt_event.c
@@ -1,3 +1,5 @@
+#define DISABLE_SIGN_COMPARE_WARNINGS
+
#include "git-compat-util.h"
#include "config.h"
#include "json-writer.h"
diff --git a/trace2/tr2_tgt_perf.c b/trace2/tr2_tgt_perf.c
index a6f9a8a193..298ae27f9d 100644
--- a/trace2/tr2_tgt_perf.c
+++ b/trace2/tr2_tgt_perf.c
@@ -1,3 +1,5 @@
+#define DISABLE_SIGN_COMPARE_WARNINGS
+
#include "git-compat-util.h"
#include "config.h"
#include "repository.h"
diff --git a/trailer.c b/trailer.c
index 46f0e4610b..310cf582dc 100644
--- a/trailer.c
+++ b/trailer.c
@@ -522,7 +522,6 @@ static int git_trailer_config(const char *conf_key, const char *value,
struct conf_info *conf;
char *name = NULL;
enum trailer_info_type type;
- int i;
if (!skip_prefix(conf_key, "trailer.", &trailer_item))
return 0;
@@ -532,7 +531,7 @@ static int git_trailer_config(const char *conf_key, const char *value,
return 0;
variable_name++;
- for (i = 0; i < ARRAY_SIZE(trailer_config_items); i++) {
+ for (size_t i = 0; i < ARRAY_SIZE(trailer_config_items); i++) {
if (strcmp(trailer_config_items[i].name, variable_name))
continue;
name = xstrndup(trailer_item, variable_name - trailer_item - 1);
diff --git a/transport-helper.c b/transport-helper.c
index bc27653cde..d457b42550 100644
--- a/transport-helper.c
+++ b/transport-helper.c
@@ -313,9 +313,9 @@ static int string_list_set_helper_option(struct helper_data *data,
struct string_list *list)
{
struct strbuf buf = STRBUF_INIT;
- int i, ret = 0;
+ int ret = 0;
- for (i = 0; i < list->nr; i++) {
+ for (size_t i = 0; i < list->nr; i++) {
strbuf_addf(&buf, "option %s ", name);
quote_c_style(list->items[i].string, &buf, NULL, 0);
strbuf_addch(&buf, '\n');
@@ -333,7 +333,7 @@ static int set_helper_option(struct transport *transport,
{
struct helper_data *data = transport->data;
struct strbuf buf = STRBUF_INIT;
- int i, ret, is_bool = 0;
+ int ret, is_bool = 0;
get_helper(transport);
@@ -344,12 +344,12 @@ static int set_helper_option(struct transport *transport,
return string_list_set_helper_option(data, name,
(struct string_list *)value);
- for (i = 0; i < ARRAY_SIZE(unsupported_options); i++) {
+ for (size_t i = 0; i < ARRAY_SIZE(unsupported_options); i++) {
if (!strcmp(name, unsupported_options[i]))
return 1;
}
- for (i = 0; i < ARRAY_SIZE(boolean_options); i++) {
+ for (size_t i = 0; i < ARRAY_SIZE(boolean_options); i++) {
if (!strcmp(name, boolean_options[i])) {
is_bool = 1;
break;
@@ -481,7 +481,6 @@ static int get_exporter(struct transport *transport,
{
struct helper_data *data = transport->data;
struct child_process *helper = get_helper(transport);
- int i;
child_process_init(fastexport);
@@ -497,7 +496,7 @@ static int get_exporter(struct transport *transport,
if (data->import_marks)
strvec_pushf(&fastexport->args, "--import-marks=%s", data->import_marks);
- for (i = 0; i < revlist_args->nr; i++)
+ for (size_t i = 0; i < revlist_args->nr; i++)
strvec_push(&fastexport->args, revlist_args->items[i].string);
fastexport->git_cmd = 1;
diff --git a/transport.c b/transport.c
index 6966df51a8..10d820c333 100644
--- a/transport.c
+++ b/transport.c
@@ -48,7 +48,6 @@ static int transport_color_config(void)
"color.transport.rejected"
}, *key = "color.transport";
char *value;
- int i;
static int initialized;
if (initialized)
@@ -61,7 +60,7 @@ static int transport_color_config(void)
if (!want_color_stderr(transport_use_color))
return 0;
- for (i = 0; i < ARRAY_SIZE(keys); i++)
+ for (size_t i = 0; i < ARRAY_SIZE(keys); i++)
if (!git_config_get_string(keys[i], &value)) {
if (!value)
return config_error_nonbool(keys[i]);
@@ -154,14 +153,13 @@ static struct ref *get_refs_from_bundle(struct transport *transport,
{
struct bundle_transport_data *data = transport->data;
struct ref *result = NULL;
- int i;
if (for_push)
return NULL;
get_refs_from_bundle_inner(transport);
- for (i = 0; i < data->header.references.nr; i++) {
+ for (size_t i = 0; i < data->header.references.nr; i++) {
struct string_list_item *e = data->header.references.items + i;
const char *name = e->string;
struct ref *ref = alloc_ref(name);
@@ -1303,11 +1301,9 @@ void transport_set_verbosity(struct transport *transport, int verbosity,
static void die_with_unpushed_submodules(struct string_list *needs_pushing)
{
- int i;
-
fprintf(stderr, _("The following submodule paths contain changes that can\n"
"not be found on any remote:\n"));
- for (i = 0; i < needs_pushing->nr; i++)
+ for (size_t i = 0; i < needs_pushing->nr; i++)
fprintf(stderr, " %s\n", needs_pushing->items[i].string);
fprintf(stderr, _("\nPlease try\n\n"
" git push --recurse-submodules=on-demand\n\n"
@@ -1623,9 +1619,8 @@ int transport_get_remote_bundle_uri(struct transport *transport)
void transport_unlock_pack(struct transport *transport, unsigned int flags)
{
int in_signal_handler = !!(flags & TRANSPORT_UNLOCK_PACK_IN_SIGNAL_HANDLER);
- int i;
- for (i = 0; i < transport->pack_lockfiles.nr; i++)
+ for (size_t i = 0; i < transport->pack_lockfiles.nr; i++)
if (in_signal_handler)
unlink(transport->pack_lockfiles.items[i].string);
else
diff --git a/tree-diff.c b/tree-diff.c
index 5eab8af631..d9237ffd9b 100644
--- a/tree-diff.c
+++ b/tree-diff.c
@@ -3,6 +3,7 @@
*/
#define USE_THE_REPOSITORY_VARIABLE
+#define DISABLE_SIGN_COMPARE_WARNINGS
#include "git-compat-util.h"
#include "diff.h"
diff --git a/unix-socket.c b/unix-socket.c
index 79800d8063..483c9c448c 100644
--- a/unix-socket.c
+++ b/unix-socket.c
@@ -1,3 +1,5 @@
+#define DISABLE_SIGN_COMPARE_WARNINGS
+
#include "git-compat-util.h"
#include "strbuf.h"
#include "unix-socket.h"
diff --git a/unpack-trees.c b/unpack-trees.c
index e10a9d1209..b3be5d542f 100644
--- a/unpack-trees.c
+++ b/unpack-trees.c
@@ -1,4 +1,5 @@
#define USE_THE_REPOSITORY_VARIABLE
+#define DISABLE_SIGN_COMPARE_WARNINGS
#include "git-compat-util.h"
#include "advice.h"
diff --git a/upload-pack.c b/upload-pack.c
index 43006c0614..728b2477fc 100644
--- a/upload-pack.c
+++ b/upload-pack.c
@@ -1,4 +1,5 @@
#define USE_THE_REPOSITORY_VARIABLE
+#define DISABLE_SIGN_COMPARE_WARNINGS
#include "git-compat-util.h"
#include "config.h"
diff --git a/urlmatch.c b/urlmatch.c
index 1d0254abac..eea8300489 100644
--- a/urlmatch.c
+++ b/urlmatch.c
@@ -1,3 +1,5 @@
+#define DISABLE_SIGN_COMPARE_WARNINGS
+
#include "git-compat-util.h"
#include "gettext.h"
#include "hex-ll.h"
diff --git a/usage.c b/usage.c
index 29a9725784..47709006c1 100644
--- a/usage.c
+++ b/usage.c
@@ -3,6 +3,7 @@
*
* Copyright (C) Linus Torvalds, 2005
*/
+
#include "git-compat-util.h"
#include "gettext.h"
#include "trace2.h"
@@ -189,7 +190,7 @@ void NORETURN die(const char *err, ...)
static const char *fmt_with_err(char *buf, int n, const char *fmt)
{
char str_error[256], *err;
- int i, j;
+ size_t i, j;
err = strerror(errno);
for (i = j = 0; err[i] && j < sizeof(str_error) - 1; ) {
diff --git a/userdiff.c b/userdiff.c
index d43d8360d1..340c4eb4f7 100644
--- a/userdiff.c
+++ b/userdiff.c
@@ -1,4 +1,5 @@
#define USE_THE_REPOSITORY_VARIABLE
+#define DISABLE_SIGN_COMPARE_WARNINGS
#include "git-compat-util.h"
#include "config.h"
diff --git a/utf8.c b/utf8.c
index 6bfaefa28e..35a0251939 100644
--- a/utf8.c
+++ b/utf8.c
@@ -1,3 +1,5 @@
+#define DISABLE_SIGN_COMPARE_WARNINGS
+
#include "git-compat-util.h"
#include "strbuf.h"
#include "utf8.h"
diff --git a/version.c b/version.c
index 7adc4d51ff..4d763ab48d 100644
--- a/version.c
+++ b/version.c
@@ -25,11 +25,10 @@ const char *git_user_agent_sanitized(void)
if (!agent) {
struct strbuf buf = STRBUF_INIT;
- int i;
strbuf_addstr(&buf, git_user_agent());
strbuf_trim(&buf);
- for (i = 0; i < buf.len; i++) {
+ for (size_t i = 0; i < buf.len; i++) {
if (buf.buf[i] <= 32 || buf.buf[i] >= 127)
buf.buf[i] = '.';
}
diff --git a/versioncmp.c b/versioncmp.c
index e3b2a6e330..b6eebdb989 100644
--- a/versioncmp.c
+++ b/versioncmp.c
@@ -77,11 +77,10 @@ static int swap_prereleases(const char *s1,
int off,
int *diff)
{
- int i;
struct suffix_match match1 = { -1, off, -1 };
struct suffix_match match2 = { -1, off, -1 };
- for (i = 0; i < prereleases->nr; i++) {
+ for (size_t i = 0; i < prereleases->nr; i++) {
const char *suffix = prereleases->items[i].string;
int start, suffix_len = strlen(suffix);
if (suffix_len < off)
diff --git a/worktree.c b/worktree.c
index af68b24f9d..248bbb39d4 100644
--- a/worktree.c
+++ b/worktree.c
@@ -1,4 +1,5 @@
#define USE_THE_REPOSITORY_VARIABLE
+#define DISABLE_SIGN_COMPARE_WARNINGS
#include "git-compat-util.h"
#include "abspath.h"
diff --git a/wrapper.c b/wrapper.c
index f87d90bf57..fa79fd6ec9 100644
--- a/wrapper.c
+++ b/wrapper.c
@@ -1,6 +1,9 @@
/*
* Various trivial helper wrappers around standard functions
*/
+
+#define DISABLE_SIGN_COMPARE_WARNINGS
+
#include "git-compat-util.h"
#include "abspath.h"
#include "parse.h"
diff --git a/ws.c b/ws.c
index 9456e2fdbe..70acee3337 100644
--- a/ws.c
+++ b/ws.c
@@ -3,6 +3,9 @@
*
* Copyright (c) 2007 Junio C Hamano
*/
+
+#define DISABLE_SIGN_COMPARE_WARNINGS
+
#include "git-compat-util.h"
#include "attr.h"
#include "strbuf.h"
diff --git a/wt-status.c b/wt-status.c
index 6a8c05d1cf..3ee9181764 100644
--- a/wt-status.c
+++ b/wt-status.c
@@ -1,4 +1,5 @@
#define USE_THE_REPOSITORY_VARIABLE
+#define DISABLE_SIGN_COMPARE_WARNINGS
#include "git-compat-util.h"
#include "advice.h"
diff --git a/xdiff-interface.c b/xdiff-interface.c
index d5dc88661e..3bd61f26e9 100644
--- a/xdiff-interface.c
+++ b/xdiff-interface.c
@@ -1,4 +1,5 @@
#define USE_THE_REPOSITORY_VARIABLE
+#define DISABLE_SIGN_COMPARE_WARNINGS
#include "git-compat-util.h"
#include "gettext.h"
diff --git a/xdiff/xdiffi.c b/xdiff/xdiffi.c
index 344c2dfc3e..4685ba6137 100644
--- a/xdiff/xdiffi.c
+++ b/xdiff/xdiffi.c
@@ -19,6 +19,7 @@
* Davide Libenzi <davidel@xmailserver.org>
*
*/
+#define DISABLE_SIGN_COMPARE_WARNINGS
#include "xinclude.h"
diff --git a/xdiff/xinclude.h b/xdiff/xinclude.h
index a4285ac0eb..7e56542526 100644
--- a/xdiff/xinclude.h
+++ b/xdiff/xinclude.h
@@ -23,6 +23,8 @@
#if !defined(XINCLUDE_H)
#define XINCLUDE_H
+#define DISABLE_SIGN_COMPARE_WARNINGS
+
#include "git-compat-util.h"
#include "xmacros.h"
#include "xdiff.h"