Module Name:    src
Committed By:   lukem
Date:           Mon Apr  6 12:18:19 UTC 2009

Modified Files:
        src/sbin/fdisk: fdisk.c

Log Message:
fix sign-compare issues


To generate a diff of this commit:
cvs rdiff -u -r1.117 -r1.118 src/sbin/fdisk/fdisk.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sbin/fdisk/fdisk.c
diff -u src/sbin/fdisk/fdisk.c:1.117 src/sbin/fdisk/fdisk.c:1.118
--- src/sbin/fdisk/fdisk.c:1.117	Sun Jan 18 21:15:14 2009
+++ src/sbin/fdisk/fdisk.c	Mon Apr  6 12:18:19 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: fdisk.c,v 1.117 2009/01/18 21:15:14 apb Exp $ */
+/*	$NetBSD: fdisk.c,v 1.118 2009/04/06 12:18:19 lukem Exp $ */
 
 /*
  * Mach Operating System
@@ -39,7 +39,7 @@
 #include <sys/cdefs.h>
 
 #ifndef lint
-__RCSID("$NetBSD: fdisk.c,v 1.117 2009/01/18 21:15:14 apb Exp $");
+__RCSID("$NetBSD: fdisk.c,v 1.118 2009/04/06 12:18:19 lukem Exp $");
 #endif /* not lint */
 
 #define MBRPTYPENAMES
@@ -1451,7 +1451,8 @@
 void
 intuit_translated_geometry(void)
 {
-	int xcylinders = -1, xheads = -1, xsectors = -1, i, j;
+	uint32_t xcylinders;
+	int xheads = -1, xsectors = -1, i, j;
 	unsigned int c1, h1, s1, c2, h2, s2;
 	unsigned long a1, a2;
 	uint64_t num, denom;
@@ -1471,9 +1472,9 @@
 		if (dl != NULL) {
 			/* BIOS may use 256 heads or 1024 cylinders */
 			for (i = 0; i < dl->dl_nbiosdisks; i++) {
-				if (h1 < dl->dl_biosdisks[i].bi_head)
+				if (h1 < (unsigned int)dl->dl_biosdisks[i].bi_head)
 					h1 = dl->dl_biosdisks[i].bi_head;
-				if (c1 < dl->dl_biosdisks[i].bi_cyl)
+				if (c1 < (unsigned int)dl->dl_biosdisks[i].bi_cyl)
 					c1 = dl->dl_biosdisks[i].bi_cyl;
 			}
 		}
@@ -1511,6 +1512,11 @@
 		return;
 	}
 
+	if (xsectors == -1) {
+		warnx("Cannot determine the number of sectors");
+		return;
+	}
+
 	/* Estimate the number of cylinders. */
 	xcylinders = disklabel.d_secperunit / xheads / xsectors;
 	if (disklabel.d_secperunit > xcylinders * xheads * xsectors)
@@ -2442,7 +2448,7 @@
 {
 	unsigned int key = mbs->mbrbs_defkey;
 	unsigned int tmo;
-	int i;
+	size_t i;
 
 	if (v_flag)
 		return 0;

Reply via email to