Skip to content

Commit 8ca9fa6

Browse files
pks-tgitster
authored andcommitted
hash: fix "-Wsign-compare" warnings
There are a couple of trivial "-Wsign-compare" warnings in "hash.c". Fix them. Signed-off-by: Patrick Steinhardt <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 172d0f6 commit 8ca9fa6

File tree

2 files changed

+5
-9
lines changed

2 files changed

+5
-9
lines changed

hash.c

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
#define USE_THE_REPOSITORY_VARIABLE
2-
#define DISABLE_SIGN_COMPARE_WARNINGS
32

43
#include "git-compat-util.h"
54
#include "hash.h"
@@ -246,28 +245,25 @@ const char *empty_tree_oid_hex(const struct git_hash_algo *algop)
246245

247246
int hash_algo_by_name(const char *name)
248247
{
249-
int i;
250248
if (!name)
251249
return GIT_HASH_UNKNOWN;
252-
for (i = 1; i < GIT_HASH_NALGOS; i++)
250+
for (size_t i = 1; i < GIT_HASH_NALGOS; i++)
253251
if (!strcmp(name, hash_algos[i].name))
254252
return i;
255253
return GIT_HASH_UNKNOWN;
256254
}
257255

258256
int hash_algo_by_id(uint32_t format_id)
259257
{
260-
int i;
261-
for (i = 1; i < GIT_HASH_NALGOS; i++)
258+
for (size_t i = 1; i < GIT_HASH_NALGOS; i++)
262259
if (format_id == hash_algos[i].format_id)
263260
return i;
264261
return GIT_HASH_UNKNOWN;
265262
}
266263

267-
int hash_algo_by_length(int len)
264+
int hash_algo_by_length(size_t len)
268265
{
269-
int i;
270-
for (i = 1; i < GIT_HASH_NALGOS; i++)
266+
for (size_t i = 1; i < GIT_HASH_NALGOS; i++)
271267
if (len == hash_algos[i].rawsz)
272268
return i;
273269
return GIT_HASH_UNKNOWN;

hash.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,7 @@ int hash_algo_by_name(const char *name);
325325
/* Identical, except based on the format ID. */
326326
int hash_algo_by_id(uint32_t format_id);
327327
/* Identical, except based on the length. */
328-
int hash_algo_by_length(int len);
328+
int hash_algo_by_length(size_t len);
329329
/* Identical, except for a pointer to struct git_hash_algo. */
330330
static inline int hash_algo_by_ptr(const struct git_hash_algo *p)
331331
{

0 commit comments

Comments
 (0)