summaryrefslogtreecommitdiff
path: root/read-cache.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@ppc970.osdl.org>2005-04-09 07:25:22 (GMT)
committerLinus Torvalds <torvalds@ppc970.osdl.org>2005-04-09 07:25:22 (GMT)
commit59c1e249808c6ba38194733fa00efddb9e0eb488 (patch)
tree8bd5667ce5588ab02c103c9aa8d8f1c6e90da56f /read-cache.c
parent1ea34e365b1ea233be332245bc34a8df415a7d61 (diff)
downloadgit-59c1e249808c6ba38194733fa00efddb9e0eb488.zip
git-59c1e249808c6ba38194733fa00efddb9e0eb488.tar.gz
git-59c1e249808c6ba38194733fa00efddb9e0eb488.tar.bz2
Fix missing return values and some error tests for empty index files
Patches from Dave Jones and Ingo Molnar, but since I don't have any infrastructure in place to use the old patch applicator scripts I am trying to build up, I ended up fixing the thing by hand instead. Credit where credit is due, though. Nice to see that people are taking a look at the project even in this early stage.
Diffstat (limited to 'read-cache.c')
-rw-r--r--read-cache.c3
1 files changed, 1 insertions, 2 deletions
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);