kpartx: minor fixes to make coverity happy
authorBenjamin Marzinski <bmarzins@redhat.com>
Wed, 1 Aug 2018 20:56:58 +0000 (15:56 -0500)
committerChristophe Varoqui <christophe.varoqui@opensvc.com>
Tue, 7 Aug 2018 13:30:23 +0000 (15:30 +0200)
an open() failure for fd_dasd will return -1, not 0. Also, cast blocksize
to a uint64_t to keep coverity from complaining about sign extension issues.

Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
kpartx/dasd.c

index e418d5a..94ae81b 100644 (file)
@@ -129,7 +129,7 @@ read_dasd_pt(int fd, struct slice all, struct slice *sp, int ns)
                         */
                        unlink(pathname);
                }
-               if (!fd_dasd) {
+               if (fd_dasd < 0) {
                        /* Couldn't open the device */
                        return -1;
                }
@@ -157,7 +157,8 @@ read_dasd_pt(int fd, struct slice all, struct slice *sp, int ns)
 
                geo.heads = 15;
                geo.sectors = recs_per_track(blocksize);
-               cyl = disksize / (blocksize * geo.heads * geo.sectors);
+               cyl = disksize / ((uint64_t)blocksize * geo.heads *
+                                 geo.sectors);
                if (cyl < LV_COMPAT_CYL)
                        geo.cylinders = cyl;
                else