Skip to content

Commit d0ae7e2

Browse files
committed
Merge branch 'nd/index-errno'
Assignments to errno before calling system functions that used to matter in the old code were left behind after the code structure changed sufficiently to make them useless. * nd/index-errno: read_index_from: remove bogus errno assignments
2 parents c90f06e + 57d84f8 commit d0ae7e2

File tree

1 file changed

+1
-5
lines changed

1 file changed

+1
-5
lines changed

read-cache.c

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1414,11 +1414,9 @@ int read_index_from(struct index_state *istate, const char *path)
14141414
size_t mmap_size;
14151415
struct strbuf previous_name_buf = STRBUF_INIT, *previous_name;
14161416

1417-
errno = EBUSY;
14181417
if (istate->initialized)
14191418
return istate->cache_nr;
14201419

1421-
errno = ENOENT;
14221420
istate->timestamp.sec = 0;
14231421
istate->timestamp.nsec = 0;
14241422
fd = open(path, O_RDONLY);
@@ -1431,15 +1429,14 @@ int read_index_from(struct index_state *istate, const char *path)
14311429
if (fstat(fd, &st))
14321430
die_errno("cannot stat the open index");
14331431

1434-
errno = EINVAL;
14351432
mmap_size = xsize_t(st.st_size);
14361433
if (mmap_size < sizeof(struct cache_header) + 20)
14371434
die("index file smaller than expected");
14381435

14391436
mmap = xmmap(NULL, mmap_size, PROT_READ | PROT_WRITE, MAP_PRIVATE, fd, 0);
1440-
close(fd);
14411437
if (mmap == MAP_FAILED)
14421438
die_errno("unable to map index file");
1439+
close(fd);
14431440

14441441
hdr = mmap;
14451442
if (verify_hdr(hdr, mmap_size) < 0)
@@ -1495,7 +1492,6 @@ int read_index_from(struct index_state *istate, const char *path)
14951492

14961493
unmap:
14971494
munmap(mmap, mmap_size);
1498-
errno = EINVAL;
14991495
die("index file corrupt");
15001496
}
15011497

0 commit comments

Comments
 (0)