summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorShawn O. Pearce <spearce@spearce.org>2006-12-26 04:40:58 (GMT)
committerJunio C Hamano <junkio@cox.net>2006-12-29 19:36:45 (GMT)
commit5fe5c8300da67a07bd430a33c474ef1498cb1d4b (patch)
tree32095369127577331d5b669106c68ae43b721360
parentc4712e4553f13d87d655325a57538f299402d457 (diff)
downloadgit-5fe5c8300da67a07bd430a33c474ef1498cb1d4b.zip
git-5fe5c8300da67a07bd430a33c474ef1498cb1d4b.tar.gz
git-5fe5c8300da67a07bd430a33c474ef1498cb1d4b.tar.bz2
Cleanup read_cache_from error handling.
When I converted the mmap() call to xmmap() I failed to cleanup the way this routine handles errors and left some crufty code behind. This is a small cleanup, suggested by Johannes. Signed-off-by: Shawn O. Pearce <spearce@spearce.org> Signed-off-by: Junio C Hamano <junkio@cox.net>
-rw-r--r--read-cache.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/read-cache.c b/read-cache.c
index ca3efbb..29cf9ab 100644
--- a/read-cache.c
+++ b/read-cache.c
@@ -793,16 +793,16 @@ int read_cache_from(const char *path)
die("index file open failed (%s)", strerror(errno));
}
- cache_mmap = MAP_FAILED;
if (!fstat(fd, &st)) {
cache_mmap_size = st.st_size;
errno = EINVAL;
if (cache_mmap_size >= sizeof(struct cache_header) + 20)
cache_mmap = xmmap(NULL, cache_mmap_size, PROT_READ | PROT_WRITE, MAP_PRIVATE, fd, 0);
- }
+ else
+ die("index file smaller than expected");
+ } else
+ die("cannot stat the open index (%s)", strerror(errno));
close(fd);
- if (cache_mmap == MAP_FAILED)
- die("index file mmap failed (%s)", strerror(errno));
hdr = cache_mmap;
if (verify_hdr(hdr, cache_mmap_size) < 0)