Skip to content

Commit 80e7f52

Browse files
pks-tgitster
authored andcommitted
object-file: fix -Wsign-compare warnings
There are some trivial -Wsign-compare warnings in "object-file.c". Fix them and drop the preprocessor define that disables those warnings. Signed-off-by: Patrick Steinhardt <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 7cafb9a commit 80e7f52

File tree

1 file changed

+6
-9
lines changed

1 file changed

+6
-9
lines changed

object-file.c

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
*/
99

1010
#define USE_THE_REPOSITORY_VARIABLE
11-
#define DISABLE_SIGN_COMPARE_WARNINGS
1211

1312
#include "git-compat-util.h"
1413
#include "bulk-checkin.h"
@@ -44,8 +43,7 @@ static int get_conv_flags(unsigned flags)
4443

4544
static void fill_loose_path(struct strbuf *buf, const struct object_id *oid)
4645
{
47-
int i;
48-
for (i = 0; i < the_hash_algo->rawsz; i++) {
46+
for (size_t i = 0; i < the_hash_algo->rawsz; i++) {
4947
static char hex[] = "0123456789abcdef";
5048
unsigned int val = oid->hash[i];
5149
strbuf_addch(buf, hex[val >> 4]);
@@ -327,9 +325,8 @@ static void *unpack_loose_rest(git_zstream *stream,
327325
void *buffer, unsigned long size,
328326
const struct object_id *oid)
329327
{
330-
int bytes = strlen(buffer) + 1;
328+
size_t bytes = strlen(buffer) + 1, n;
331329
unsigned char *buf = xmallocz(size);
332-
unsigned long n;
333330
int status = Z_OK;
334331

335332
n = stream->total_out - bytes;
@@ -596,7 +593,7 @@ static int check_collision(const char *source, const char *dest)
596593
goto out;
597594
}
598595

599-
if (sz_a < sizeof(buf_source))
596+
if ((size_t) sz_a < sizeof(buf_source))
600597
break;
601598
}
602599

@@ -1240,7 +1237,7 @@ static int index_core(struct index_state *istate,
12401237
if (read_result < 0)
12411238
ret = error_errno(_("read error while indexing %s"),
12421239
path ? path : "<unknown>");
1243-
else if (read_result != size)
1240+
else if ((size_t) read_result != size)
12441241
ret = error(_("short read while indexing %s"),
12451242
path ? path : "<unknown>");
12461243
else
@@ -1268,7 +1265,7 @@ int index_fd(struct index_state *istate, struct object_id *oid,
12681265
ret = index_stream_convert_blob(istate, oid, fd, path, flags);
12691266
else if (!S_ISREG(st->st_mode))
12701267
ret = index_pipe(istate, oid, fd, type, path, flags);
1271-
else if (st->st_size <= repo_settings_get_big_file_threshold(the_repository) ||
1268+
else if ((st->st_size >= 0 && (size_t) st->st_size <= repo_settings_get_big_file_threshold(the_repository)) ||
12721269
type != OBJ_BLOB ||
12731270
(path && would_convert_to_git(istate, path)))
12741271
ret = index_core(istate, oid, fd, xsize_t(st->st_size),
@@ -1472,7 +1469,7 @@ struct oidtree *odb_loose_cache(struct odb_source *source,
14721469
uint32_t *bitmap;
14731470

14741471
if (subdir_nr < 0 ||
1475-
subdir_nr >= bitsizeof(source->loose_objects_subdir_seen))
1472+
(size_t) subdir_nr >= bitsizeof(source->loose_objects_subdir_seen))
14761473
BUG("subdir_nr out of range");
14771474

14781475
bitmap = &source->loose_objects_subdir_seen[word_index];

0 commit comments

Comments
 (0)