Module Name: src
Committed By: lukem
Date: Sat Apr 11 07:20:09 UTC 2009
Modified Files:
src/sbin/newfs: mkfs.c newfs.c
Log Message:
fix sign-compare issues
To generate a diff of this commit:
cvs rdiff -u -r1.104 -r1.105 src/sbin/newfs/mkfs.c
cvs rdiff -u -r1.103 -r1.104 src/sbin/newfs/newfs.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/newfs/mkfs.c
diff -u src/sbin/newfs/mkfs.c:1.104 src/sbin/newfs/mkfs.c:1.105
--- src/sbin/newfs/mkfs.c:1.104 Sat Dec 8 21:40:23 2007
+++ src/sbin/newfs/mkfs.c Sat Apr 11 07:20:09 2009
@@ -1,4 +1,4 @@
-/* $NetBSD: mkfs.c,v 1.104 2007/12/08 21:40:23 jnemeth Exp $ */
+/* $NetBSD: mkfs.c,v 1.105 2009/04/11 07:20:09 lukem Exp $ */
/*
* Copyright (c) 1980, 1989, 1993
@@ -73,7 +73,7 @@
#if 0
static char sccsid[] = "@(#)mkfs.c 8.11 (Berkeley) 5/3/95";
#else
-__RCSID("$NetBSD: mkfs.c,v 1.104 2007/12/08 21:40:23 jnemeth Exp $");
+__RCSID("$NetBSD: mkfs.c,v 1.105 2009/04/11 07:20:09 lukem Exp $");
#endif
#endif /* not lint */
@@ -161,7 +161,7 @@
mkfs(const char *fsys, int fi, int fo,
mode_t mfsmode, uid_t mfsuid, gid_t mfsgid)
{
- uint fragsperinodeblk, ncg;
+ uint fragsperinodeblk, ncg, u;
uint cgzero;
uint64_t inodeblks, cgall;
int32_t cylno, i, csfrags;
@@ -177,7 +177,7 @@
#ifdef MFS
if (mfs && !Nflag) {
calc_memfree();
- if (fssize * sectorsize > memleft)
+ if ((uint64_t)fssize * sectorsize > memleft)
fssize = memleft / sectorsize;
if ((membase = mkfs_malloc(fssize * sectorsize)) == NULL)
exit(12);
@@ -287,7 +287,7 @@
sblock.fs_fsbtodb = ilog2(sblock.fs_fsize / sectorsize);
sblock.fs_size = dbtofsb(&sblock, fssize);
if (Oflag <= 1) {
- if (sblock.fs_size >= 1ull << 31) {
+ if ((uint64_t)sblock.fs_size >= 1ull << 31) {
printf("Too many fragments (0x%" PRIx64
") for a UFS1 filesystem\n", sblock.fs_size);
exit(22);
@@ -370,7 +370,7 @@
if (inodeblks == 0)
inodeblks = 1;
/* Ensure that there are at least 2 data blocks (or we fail below) */
- if (inodeblks > (sblock.fs_size - sblock.fs_iblkno)/sblock.fs_frag - 2)
+ if (inodeblks > (uint64_t)(sblock.fs_size - sblock.fs_iblkno)/sblock.fs_frag - 2)
inodeblks = (sblock.fs_size-sblock.fs_iblkno)/sblock.fs_frag-2;
/* Even UFS2 limits number of inodes to 2^31 (fs_ipg is int32_t) */
if (inodeblks * INOPB(&sblock) >= 1ull << 31)
@@ -388,10 +388,10 @@
* but for small file sytems (especially ones with a lot
* of inodes) this is not desirable (or possible).
*/
- i = sblock.fs_size / 2 / (sblock.fs_iblkno +
+ u = sblock.fs_size / 2 / (sblock.fs_iblkno +
inodeblks * sblock.fs_frag);
- if (i > ncg)
- ncg = i;
+ if (u > ncg)
+ ncg = u;
if (ncg > MINCYLGRPS)
ncg = MINCYLGRPS;
if (ncg > inodeblks)
@@ -417,7 +417,7 @@
}
sblock.fs_ipg = inodes_per_cg;
/* Sanity check on our sums... */
- if (CGSIZE(&sblock) > sblock.fs_bsize) {
+ if ((int)CGSIZE(&sblock) > sblock.fs_bsize) {
printf("CGSIZE miscalculated %d > %d\n",
(int)CGSIZE(&sblock), sblock.fs_bsize);
exit(24);
@@ -735,6 +735,7 @@
{
daddr_t cbase, dmax;
int32_t i, d, dlower, dupper, blkno;
+ uint32_t u;
struct ufs1_dinode *dp1;
struct ufs2_dinode *dp2;
int start;
@@ -812,8 +813,8 @@
}
acg.cg_cs.cs_nifree += sblock.fs_ipg;
if (cylno == 0)
- for (i = 0; i < ROOTINO; i++) {
- setbit(cg_inosused(&acg, 0), i);
+ for (u = 0; u < ROOTINO; u++) {
+ setbit(cg_inosused(&acg, 0), u);
acg.cg_cs.cs_nifree--;
}
if (cylno > 0) {
@@ -1237,7 +1238,7 @@
wtfs(fsbtodb(&sblock, cgtod(&sblock, 0)), sblock.fs_cgsize, &acg);
sblock.fs_cstotal.cs_nifree--;
fscs_0->cs_nifree--;
- if (ino >= sblock.fs_ipg * sblock.fs_ncg) {
+ if (ino >= (ino_t)(sblock.fs_ipg * sblock.fs_ncg)) {
printf("fsinit: inode value out of range (%llu).\n",
(unsigned long long)ino);
exit(32);
Index: src/sbin/newfs/newfs.c
diff -u src/sbin/newfs/newfs.c:1.103 src/sbin/newfs/newfs.c:1.104
--- src/sbin/newfs/newfs.c:1.103 Fri Apr 3 13:22:05 2009
+++ src/sbin/newfs/newfs.c Sat Apr 11 07:20:09 2009
@@ -1,4 +1,4 @@
-/* $NetBSD: newfs.c,v 1.103 2009/04/03 13:22:05 pooka Exp $ */
+/* $NetBSD: newfs.c,v 1.104 2009/04/11 07:20:09 lukem Exp $ */
/*
* Copyright (c) 1983, 1989, 1993, 1994
@@ -78,7 +78,7 @@
#if 0
static char sccsid[] = "@(#)newfs.c 8.13 (Berkeley) 5/1/95";
#else
-__RCSID("$NetBSD: newfs.c,v 1.103 2009/04/03 13:22:05 pooka Exp $");
+__RCSID("$NetBSD: newfs.c,v 1.104 2009/04/11 07:20:09 lukem Exp $");
#endif
#endif /* not lint */
@@ -551,7 +551,7 @@
errx(1, "Unable to determine file system size");
}
- if (dkw.dkw_parent[0] && fssize > dkw.dkw_size)
+ if (dkw.dkw_parent[0] && (uint64_t)fssize > dkw.dkw_size)
errx(1, "size %" PRIu64 " exceeds maximum file system size on "
"`%s' of %" PRIu64 " sectors",
fssize, special, dkw.dkw_size);
@@ -723,7 +723,7 @@
if (!(gp = getgrnam(gname)) && !isdigit((unsigned char)*gname))
errx(1, "unknown gname %s", gname);
- return gp ? gp->gr_gid : atoi(gname);
+ return gp ? gp->gr_gid : (gid_t)atoi(gname);
}
static uid_t
@@ -733,7 +733,7 @@
if (!(pp = getpwnam(uname)) && !isdigit((unsigned char)*uname))
errx(1, "unknown user %s", uname);
- return pp ? pp->pw_uid : atoi(uname);
+ return pp ? pp->pw_uid : (uid_t)atoi(uname);
}
static int64_t