summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--cache.h2
-rw-r--r--fsck-cache.c2
-rw-r--r--read-cache.c3
3 files changed, 4 insertions, 3 deletions
diff --git a/cache.h b/cache.h
index 864f70b..900824a 100644
--- a/cache.h
+++ b/cache.h
@@ -56,7 +56,7 @@ struct cache_entry {
unsigned int st_size;
unsigned char sha1[20];
unsigned short namelen;
- unsigned char name[0];
+ char name[0];
};
const char *sha1_file_directory;
diff --git a/fsck-cache.c b/fsck-cache.c
index 0a97566..a01513e 100644
--- a/fsck-cache.c
+++ b/fsck-cache.c
@@ -30,6 +30,7 @@ static int fsck_tree(unsigned char *sha1, void *data, unsigned long size)
size -= len + 20;
mark_needs_sha1(sha1, "blob", file_sha1);
}
+ return 0;
}
static int fsck_commit(unsigned char *sha1, void *data, unsigned long size)
@@ -49,6 +50,7 @@ static int fsck_commit(unsigned char *sha1, void *data, unsigned long size)
mark_needs_sha1(sha1, "commit", parent_sha1);
data += 7 + 40 + 1; /* "parent " + <hex sha1> + '\n' */
}
+ return 0;
}
static int fsck_entry(unsigned char *sha1, char *tag, void *data, unsigned long size)
diff --git a/read-cache.c b/read-cache.c
index 2ede67d..50d0be3 100644
--- a/read-cache.c
+++ b/read-cache.c
@@ -264,10 +264,9 @@ int read_cache(void)
size = 0; // avoid gcc warning
map = (void *)-1;
if (!fstat(fd, &st)) {
- map = NULL;
size = st.st_size;
errno = EINVAL;
- if (size > sizeof(struct cache_header))
+ if (size >= sizeof(struct cache_header))
map = mmap(NULL, size, PROT_READ, MAP_PRIVATE, fd, 0);
}
close(fd);