lib/deltas: Use pread() instead of lseek()+read()
authorColin Walters <walters@verbum.org>
Sat, 14 Oct 2017 00:51:39 +0000 (20:51 -0400)
committerAtomic Bot <atomic-devel@projectatomic.io>
Tue, 17 Oct 2017 15:20:08 +0000 (15:20 +0000)
That's why the syscall was invented, so let's use it. Just noticed while reading
the code while working on another patch.

Closes: #1270
Approved by: jlebon

src/libostree/ostree-repo-static-delta-processing.c

index 6596da8955eda52ff20ea3a73a171fa5824d7948..fac377ec6f86206e4de89401993dd4a9d38b3745 100644 (file)
@@ -719,15 +719,13 @@ dispatch_write (OstreeRepo                 *repo,
     {
       if (state->read_source_fd != -1)
         {
-          if (lseek (state->read_source_fd, content_offset, SEEK_SET) == -1)
-            return glnx_throw_errno_prefix (error, "lseek");
           while (content_size > 0)
             {
               char buf[4096];
               gssize bytes_read;
 
               do
-                bytes_read = read (state->read_source_fd, buf, MIN(sizeof(buf), content_size));
+                bytes_read = pread (state->read_source_fd, buf, MIN(sizeof(buf), content_size), content_offset);
               while (G_UNLIKELY (bytes_read == -1 && errno == EINTR));
               if (bytes_read == -1)
                 return glnx_throw_errno_prefix (error, "read");