threads / patch / 6312

patchRe: [PATCH] Replacing the system call pread() with lseek()/xread()/lseek() sequence.

Subject: Re: [PATCH] Replacing the system call pread() with lseek()/xread()/lseek() sequence.

## tl;dr

One message between Jan 9, 2007 and Jan 9, 2007. Diffs are folded; open one to read it.

replies: 0people: 1as markdown or json

Nicolas Pitre· Jan 9, 2007, 19:48 UTC · lore
On Tue, 9 Jan 2007, Stefan-W. Hahn wrote:
Show 11 quoted lines
> --- /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.
Show 5 quoted lines
> +
> +        ssize_t rc=xread(fd, buf, count);
> +
> +        if (current_offset != lseek(fd, current_offset, SEEK_SET))
> +                return EINVAL;
Ditto here.
> +        return rc;
> +}
Nicolas

← back to recent threads