{"thread":{"id":"6312","subject":"Re: [PATCH] Replacing the system call pread() with lseek()/xread()/lseek() sequence.","startedAt":"2007-01-09T19:48:12Z","lastAt":"2007-01-09T19:48:12Z","messageCount":1,"participants":["Nicolas Pitre"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"31272","messageId":"Pine.LNX.4.64.0701091446150.4964@xanadu.home","threadId":"6312","inReplyTo":"11683687161239-git-send-email-@videotron.ca","subject":"Re: [PATCH] Replacing the system call pread() with lseek()/xread()/lseek() sequence.","fromName":"Nicolas Pitre","fromEmail":"nico@cam.org","sentAt":"2007-01-09T19:48:12Z","receivedAt":"2007-01-09T19:48:12Z","isPatch":true,"sender":{"key":"nico@fluxnic.net","avatar":"https://avatars.githubusercontent.com/u/702790?v=4"},"body":"On Tue, 9 Jan 2007, Stefan-W. Hahn wrote:\n\n> --- /dev/null\n> +++ b/compat/pread.c\n> @@ -0,0 +1,15 @@\n> +#include \"../git-compat-util.h\"\n> +\n> +ssize_t git_pread(int fd,void *buf,size_t count,off_t offset)\n> +{\n> +        off_t current_offset = lseek(fd, 0, SEEK_CUR);\n> +\n> +        if (lseek(fd, offset, SEEK_SET) < 0)\n> +                return EINVAL;\n\nYou certainly wanted to return -1 here.\n\n> +\n> +        ssize_t rc=xread(fd, buf, count);\n> +\n> +        if (current_offset != lseek(fd, current_offset, SEEK_SET))\n> +                return EINVAL;\n\nDitto here.\n\n> +        return rc;\n> +}\n\n\nNicolas\n"}]}