]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
mkswap: cast before lseek [lgtm scan]
authorKarel Zak <kzak@redhat.com>
Fri, 20 Sep 2019 13:47:55 +0000 (15:47 +0200)
committerKarel Zak <kzak@redhat.com>
Fri, 20 Sep 2019 13:47:55 +0000 (15:47 +0200)
Signed-off-by: Karel Zak <kzak@redhat.com>
disk-utils/mkswap.c

index 659ebf0d712d1f07883a5992ab37a571a87b959a..c6aaaf5f1b6348a6f0815f838746e3ca0453a0d2 100644 (file)
@@ -191,9 +191,9 @@ static void check_blocks(struct mkswap_control *ctl)
        buffer = xmalloc(ctl->pagesize);
        while (current_page < ctl->npages) {
                ssize_t rc;
+               off_t offset = (off_t) current_page * ctl->pagesize;
 
-               if (do_seek && lseek(ctl->fd, current_page * ctl->pagesize, SEEK_SET) !=
-                   current_page * ctl->pagesize)
+               if (do_seek && lseek(ctl->fd, offset, SEEK_SET) != offset)
                        errx(EXIT_FAILURE, _("seek failed in check_blocks"));
 
                rc = read(ctl->fd, buffer, ctl->pagesize);