diff options
author | Nguyễn Thái Ngọc Duy <pclouds@gmail.com> | 2012-08-06 18:27:09 +0700 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2012-08-06 10:01:21 -0700 |
commit | 57d84f8d93a0e0818fc403c5b1a2ba73ce0eca5a (patch) | |
tree | dc69a0cce751d965655e9270969feb88cdbb28e7 /read-cache.c | |
parent | f174a2583c9f42315b60205890fa67a79a1f1669 (diff) | |
download | git-57d84f8d93a0e0818fc403c5b1a2ba73ce0eca5a.tar.gz |
read_index_from: remove bogus errno assignments
These assignments comes from the very first commit e83c516 (Initial
revision of "git", the information manager from hell - 2005-04-07).
Back then we did not die() when errors happened so correct errno was
required.
Since 5d1a5c0 ([PATCH] Better error reporting for "git status" -
2005-10-01), read_index_from() learned to die rather than just return
-1 and these assignments became irrelevant. Remove them.
While at it, move die_errno() next to xmmap() call because it's the
mmap's error code that we care about. Otherwise if close(fd); fails,
it could overwrite mmap's errno.
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'read-cache.c')
-rw-r--r-- | read-cache.c | 6 |
1 files changed, 1 insertions, 5 deletions
diff --git a/read-cache.c b/read-cache.c index 0a641034ce..5a78d6b05f 100644 --- a/read-cache.c +++ b/read-cache.c @@ -1274,11 +1274,9 @@ int read_index_from(struct index_state *istate, const char *path) void *mmap; size_t mmap_size; - errno = EBUSY; if (istate->initialized) return istate->cache_nr; - errno = ENOENT; istate->timestamp.sec = 0; istate->timestamp.nsec = 0; fd = open(path, O_RDONLY); @@ -1291,15 +1289,14 @@ int read_index_from(struct index_state *istate, const char *path) if (fstat(fd, &st)) die_errno("cannot stat the open index"); - errno = EINVAL; mmap_size = xsize_t(st.st_size); if (mmap_size < sizeof(struct cache_header) + 20) die("index file smaller than expected"); mmap = xmmap(NULL, mmap_size, PROT_READ | PROT_WRITE, MAP_PRIVATE, fd, 0); - close(fd); if (mmap == MAP_FAILED) die_errno("unable to map index file"); + close(fd); hdr = mmap; if (verify_hdr(hdr, mmap_size) < 0) @@ -1358,7 +1355,6 @@ int read_index_from(struct index_state *istate, const char *path) unmap: munmap(mmap, mmap_size); - errno = EINVAL; die("index file corrupt"); } |