There are a couple of trivial "-Wsign-compare" warnings in "hash.c". Fix them. Signed-off-by: Patrick Steinhardt <ps@xxxxxx> --- hash.c | 12 ++++-------- hash.h | 2 +- 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/hash.c b/hash.c index dd5ac9d0eb2..4d9f98f72c2 100644 --- a/hash.c +++ b/hash.c @@ -1,5 +1,4 @@ #define USE_THE_REPOSITORY_VARIABLE -#define DISABLE_SIGN_COMPARE_WARNINGS #include "git-compat-util.h" #include "hash.h" @@ -246,10 +245,9 @@ const char *empty_tree_oid_hex(const struct git_hash_algo *algop) int hash_algo_by_name(const char *name) { - int i; if (!name) return GIT_HASH_UNKNOWN; - for (i = 1; i < GIT_HASH_NALGOS; i++) + for (size_t i = 1; i < GIT_HASH_NALGOS; i++) if (!strcmp(name, hash_algos[i].name)) return i; return GIT_HASH_UNKNOWN; @@ -257,17 +255,15 @@ int hash_algo_by_name(const char *name) int hash_algo_by_id(uint32_t format_id) { - int i; - for (i = 1; i < GIT_HASH_NALGOS; i++) + for (size_t i = 1; i < GIT_HASH_NALGOS; i++) if (format_id == hash_algos[i].format_id) return i; return GIT_HASH_UNKNOWN; } -int hash_algo_by_length(int len) +int hash_algo_by_length(size_t len) { - int i; - for (i = 1; i < GIT_HASH_NALGOS; i++) + for (size_t i = 1; i < GIT_HASH_NALGOS; i++) if (len == hash_algos[i].rawsz) return i; return GIT_HASH_UNKNOWN; diff --git a/hash.h b/hash.h index 4367acfec50..55d67ed83f3 100644 --- a/hash.h +++ b/hash.h @@ -325,7 +325,7 @@ int hash_algo_by_name(const char *name); /* Identical, except based on the format ID. */ int hash_algo_by_id(uint32_t format_id); /* Identical, except based on the length. */ -int hash_algo_by_length(int len); +int hash_algo_by_length(size_t len); /* Identical, except for a pointer to struct git_hash_algo. */ static inline int hash_algo_by_ptr(const struct git_hash_algo *p) { -- 2.49.0.rc0.375.gae4b89d849.dirty