]> granicus.if.org Git - xz/commitdiff
xz: Cleanup io_seek_src() a bit.
authorLasse Collin <lasse.collin@tukaani.org>
Sun, 23 Jun 2019 22:24:17 +0000 (01:24 +0300)
committerLasse Collin <lasse.collin@tukaani.org>
Sun, 23 Jun 2019 22:24:17 +0000 (01:24 +0300)
lseek() returns -1 on error and checking for -1 is nicer.

src/xz/file_io.c

index 2d1f8a916d806da39f7d3682f03ca7ec9564441b..d86b36e714c39c62befbbeb508da08baaacb3698 100644 (file)
@@ -1180,9 +1180,7 @@ io_seek_src(file_pair *pair, uint64_t pos)
        if (pos > (uint64_t)(pair->src_st.st_size))
                message_bug();
 
-       const off_t offset = (off_t)pos;
-
-       if (lseek(pair->src_fd, offset, SEEK_SET) != offset) {
+       if (lseek(pair->src_fd, (off_t)(pos), SEEK_SET) == -1) {
                message_error(_("%s: Error seeking the file: %s"),
                                pair->src_name, strerror(errno));
                return true;