From: Nicolas Pitre Date: Tue, 09 Jan 2007 19:48:12 GMT Subject: Re: [PATCH] Replacing the system call pread() with lseek()/xread()/lseek() sequence. Message-ID: In-Reply-To: <11683687161239-git-send-email-@videotron.ca> On Tue, 9 Jan 2007, Stefan-W. Hahn wrote: > --- /dev/null > +++ b/compat/pread.c > @@ -0,0 +1,15 @@ > +#include "../git-compat-util.h" > + > +ssize_t git_pread(int fd,void *buf,size_t count,off_t offset) > +{ > + off_t current_offset = lseek(fd, 0, SEEK_CUR); > + > + if (lseek(fd, offset, SEEK_SET) < 0) > + return EINVAL; You certainly wanted to return -1 here. > + > + ssize_t rc=xread(fd, buf, count); > + > + if (current_offset != lseek(fd, current_offset, SEEK_SET)) > + return EINVAL; Ditto here. > + return rc; > +} Nicolas