diff mbox series

[12/32] kpartx: minor fixes to make coverity happy

Message ID 1533157038-3924-13-git-send-email-bmarzins@redhat.com (mailing list archive)
State Not Applicable, archived
Delegated to: christophe varoqui
Headers show
Series Misc Multipath patches | expand

Commit Message

Benjamin Marzinski Aug. 1, 2018, 8:56 p.m. UTC
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 | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
diff mbox series

Patch

diff --git a/kpartx/dasd.c b/kpartx/dasd.c
index e418d5a..94ae81b 100644
--- a/kpartx/dasd.c
+++ b/kpartx/dasd.c
@@ -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