packfile: replace lseek+read with pread
We already have pread emulation for portability, so there's there's no reason to make two syscalls where one suffices. Furthermore, readers of the packfile will be using mmap (or pread to emulate mmap), anyways, so the file description offset does not matter in this case. Signed-off-by: Eric Wong <e@80x24.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
parent
280738c36e
commit
4e61b2214d
@ -555,9 +555,8 @@ static int open_packed_git_1(struct packed_git *p)
|
|||||||
" while index indicates %"PRIu32" objects",
|
" while index indicates %"PRIu32" objects",
|
||||||
p->pack_name, ntohl(hdr.hdr_entries),
|
p->pack_name, ntohl(hdr.hdr_entries),
|
||||||
p->num_objects);
|
p->num_objects);
|
||||||
if (lseek(p->pack_fd, p->pack_size - hashsz, SEEK_SET) == -1)
|
read_result = pread_in_full(p->pack_fd, hash, hashsz,
|
||||||
return error("end of packfile %s is unavailable", p->pack_name);
|
p->pack_size - hashsz);
|
||||||
read_result = read_in_full(p->pack_fd, hash, hashsz);
|
|
||||||
if (read_result < 0)
|
if (read_result < 0)
|
||||||
return error_errno("error reading from %s", p->pack_name);
|
return error_errno("error reading from %s", p->pack_name);
|
||||||
if (read_result != hashsz)
|
if (read_result != hashsz)
|
||||||
|
Loading…
Reference in New Issue
Block a user