From cefb0777ded508a29d8bb741271a05e680f4b286 Mon Sep 17 00:00:00 2001 From: lukem Date: Sat, 11 Apr 2009 06:48:36 +0000 Subject: [PATCH] fix sign-compare issues --- sbin/fsck/partutil.c | 7 ++++--- sbin/fsck/progress.c | 6 +++--- sbin/fsdb/fsdb.c | 10 +++++----- sbin/fsdb/fsdb.h | 6 +++--- sbin/fsdb/fsdbutil.c | 6 +++--- sbin/ping/ping.c | 15 ++++++++------- sbin/scan_ffs/scan_ffs.c | 8 ++++---- 7 files changed, 30 insertions(+), 28 deletions(-) diff --git a/sbin/fsck/partutil.c b/sbin/fsck/partutil.c index eb04ad37fa2f..4646e6c17e34 100644 --- a/sbin/fsck/partutil.c +++ b/sbin/fsck/partutil.c @@ -1,4 +1,4 @@ -/* $NetBSD: partutil.c,v 1.3 2008/04/28 20:23:08 martin Exp $ */ +/* $NetBSD: partutil.c,v 1.4 2009/04/11 06:48:36 lukem Exp $ */ /*- * Copyright (c) 2006 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include -__RCSID("$NetBSD: partutil.c,v 1.3 2008/04/28 20:23:08 martin Exp $"); +__RCSID("$NetBSD: partutil.c,v 1.4 2009/04/11 06:48:36 lukem Exp $"); #include #include @@ -75,7 +75,8 @@ part2wedge(struct dkwedge_info *dkw, const struct disklabel *lp, const char *s) return; ptn = strchr(s, '\0')[-1] - 'a'; - if (ptn >= lp->d_npartitions || ptn != DISKPART(sb.st_rdev)) + if ((unsigned)ptn >= lp->d_npartitions || + (devminor_t)ptn != DISKPART(sb.st_rdev)) return; pp = &lp->d_partitions[ptn]; diff --git a/sbin/fsck/progress.c b/sbin/fsck/progress.c index 87c317a430dc..9c137a06d1e5 100644 --- a/sbin/fsck/progress.c +++ b/sbin/fsck/progress.c @@ -1,4 +1,4 @@ -/* $NetBSD: progress.c,v 1.4 2008/04/28 20:23:08 martin Exp $ */ +/* $NetBSD: progress.c,v 1.5 2009/04/11 06:48:36 lukem Exp $ */ /*- * Copyright (c) 1997-2004 The NetBSD Foundation, Inc. @@ -31,7 +31,7 @@ #ifndef SMALL #include -__RCSID("$NetBSD: progress.c,v 1.4 2008/04/28 20:23:08 martin Exp $"); +__RCSID("$NetBSD: progress.c,v 1.5 2009/04/11 06:48:36 lukem Exp $"); /* * File system independent fsck progress bar routines. @@ -47,7 +47,7 @@ __RCSID("$NetBSD: progress.c,v 1.4 2008/04/28 20:23:08 martin Exp $"); #include "progress.h" -static int ttywidth = 80; +static size_t ttywidth = 80; static int progress_onoff; static int progress_lowlim; diff --git a/sbin/fsdb/fsdb.c b/sbin/fsdb/fsdb.c index f0121d1edcbe..c3d0188ad3ed 100644 --- a/sbin/fsdb/fsdb.c +++ b/sbin/fsdb/fsdb.c @@ -1,4 +1,4 @@ -/* $NetBSD: fsdb.c,v 1.38 2008/08/30 10:46:16 bouyer Exp $ */ +/* $NetBSD: fsdb.c,v 1.39 2009/04/11 06:53:53 lukem Exp $ */ /*- * Copyright (c) 1996 The NetBSD Foundation, Inc. @@ -31,7 +31,7 @@ #include #ifndef lint -__RCSID("$NetBSD: fsdb.c,v 1.38 2008/08/30 10:46:16 bouyer Exp $"); +__RCSID("$NetBSD: fsdb.c,v 1.39 2009/04/11 06:53:53 lukem Exp $"); #endif /* not lint */ #include @@ -566,7 +566,7 @@ CMDFUNCSTART(findblk) { uint64_t size = iswap64(DIP(curinode, size)); if (size > 0 && - size < sblock->fs_maxsymlinklen && + size < (uint64_t)sblock->fs_maxsymlinklen && DIP(curinode, blocks) == 0) continue; else @@ -672,7 +672,7 @@ find_indirblks32(uint32_t blk, int ind_level, uint32_t *wantedblk) { #define MAXNINDIR (MAXBSIZE / sizeof(uint32_t)) uint32_t idblk[MAXNINDIR]; - int i; + size_t i; bread(fsreadfd, (char *)idblk, fsbtodb(sblock, blk), (int)sblock->fs_bsize); @@ -718,7 +718,7 @@ find_indirblks64(uint64_t blk, int ind_level, uint64_t *wantedblk) { #define MAXNINDIR (MAXBSIZE / sizeof(uint64_t)) uint64_t idblk[MAXNINDIR]; - int i; + size_t i; bread(fsreadfd, (char *)idblk, fsbtodb(sblock, blk), (int)sblock->fs_bsize); diff --git a/sbin/fsdb/fsdb.h b/sbin/fsdb/fsdb.h index 369294840c4a..08595d679830 100644 --- a/sbin/fsdb/fsdb.h +++ b/sbin/fsdb/fsdb.h @@ -1,4 +1,4 @@ -/* $NetBSD: fsdb.h,v 1.10 2008/04/28 20:23:08 martin Exp $ */ +/* $NetBSD: fsdb.h,v 1.11 2009/04/11 06:53:53 lukem Exp $ */ /*- * Copyright (c) 1996 The NetBSD Foundation, Inc. @@ -42,8 +42,8 @@ extern int markclean; struct cmdtable { const char *cmd; const char *helptxt; - unsigned int minargc; - unsigned int maxargc; + int minargc; + int maxargc; int (*handler)(int argc, char *argv[]); }; extern union dinode *curinode; diff --git a/sbin/fsdb/fsdbutil.c b/sbin/fsdb/fsdbutil.c index 3e659374ac6d..10820ea1fd48 100644 --- a/sbin/fsdb/fsdbutil.c +++ b/sbin/fsdb/fsdbutil.c @@ -1,4 +1,4 @@ -/* $NetBSD: fsdbutil.c,v 1.21 2008/12/29 20:02:30 mlelstv Exp $ */ +/* $NetBSD: fsdbutil.c,v 1.22 2009/04/11 06:53:53 lukem Exp $ */ /*- * Copyright (c) 1996 The NetBSD Foundation, Inc. @@ -31,7 +31,7 @@ #include #ifndef lint -__RCSID("$NetBSD: fsdbutil.c,v 1.21 2008/12/29 20:02:30 mlelstv Exp $"); +__RCSID("$NetBSD: fsdbutil.c,v 1.22 2009/04/11 06:53:53 lukem Exp $"); #endif /* not lint */ #include @@ -124,7 +124,7 @@ printstat(const char *cp, ino_t inum, union dinode *dp) break; case IFLNK: fputs("symlink", stdout); - if (size > 0 && size < sblock->fs_maxsymlinklen && + if (size > 0 && size < (uint64_t)sblock->fs_maxsymlinklen && DIP(dp, blocks) == 0) { p = is_ufs2 ? (char *)dp->dp2.di_db : (char *)dp->dp1.di_db; diff --git a/sbin/ping/ping.c b/sbin/ping/ping.c index cc6359807813..c51a9e557062 100644 --- a/sbin/ping/ping.c +++ b/sbin/ping/ping.c @@ -1,4 +1,4 @@ -/* $NetBSD: ping.c,v 1.88 2009/03/31 19:51:11 christos Exp $ */ +/* $NetBSD: ping.c,v 1.89 2009/04/11 06:49:50 lukem Exp $ */ /* * Copyright (c) 1989, 1993 @@ -58,7 +58,7 @@ #include #ifndef lint -__RCSID("$NetBSD: ping.c,v 1.88 2009/03/31 19:51:11 christos Exp $"); +__RCSID("$NetBSD: ping.c,v 1.89 2009/04/11 06:49:50 lukem Exp $"); #endif #include @@ -344,11 +344,12 @@ main(int argc, char *argv[]) options |= SO_DONTROUTE; break; case 's': /* size of packet to send */ - datalen = strtol(optarg, &p, 0); - if (*p != '\0' || datalen < 0) + l = strtol(optarg, &p, 0); + if (*p != '\0' || l < 0) errx(1, "Bad/invalid packet size %s", optarg); - if (datalen > MAXPACKET) + if (l > MAXPACKET) errx(1, "packet size is too large"); + datalen = (int)l; break; case 'v': pingflags |= F_VERBOSE; @@ -453,7 +454,7 @@ main(int argc, char *argv[]) loc_addr.sin_len = sizeof(struct sockaddr_in); loc_addr.sin_addr.s_addr = htonl((127<<24)+1); - if (datalen >= PHDR_LEN) /* can we time them? */ + if (datalen >= (int)PHDR_LEN) /* can we time them? */ pingflags |= F_TIMING; packlen = datalen + 60 + 76; /* MAXIP + MAXICMP */ if ((packet = (u_char *)malloc(packlen)) == NULL) @@ -1070,7 +1071,7 @@ pr_pack(u_char *buf, PR_PACK_SUB(); /* check the data */ - if (datalen > PHDR_LEN + if (datalen > (int)PHDR_LEN && !(pingflags & F_PING_RANDOM) && memcmp(&icp->icmp_data[PHDR_LEN], &opack_icmp.icmp_data[PHDR_LEN], diff --git a/sbin/scan_ffs/scan_ffs.c b/sbin/scan_ffs/scan_ffs.c index 2aabf69512a4..66d55f64db6c 100644 --- a/sbin/scan_ffs/scan_ffs.c +++ b/sbin/scan_ffs/scan_ffs.c @@ -1,4 +1,4 @@ -/* $NetBSD: scan_ffs.c,v 1.20 2007/12/15 19:44:47 perry Exp $ */ +/* $NetBSD: scan_ffs.c,v 1.21 2009/04/11 06:52:59 lukem Exp $ */ /* * Copyright (c) 2005-2007 Juan Romero Pardines @@ -33,7 +33,7 @@ #include #ifndef lint -__RCSID("$NetBSD: scan_ffs.c,v 1.20 2007/12/15 19:44:47 perry Exp $"); +__RCSID("$NetBSD: scan_ffs.c,v 1.21 2009/04/11 06:52:59 lukem Exp $"); #endif /* not lint */ #include @@ -273,7 +273,7 @@ ffs_scan(struct sblockinfo *sbi, int n) * Really enough for now. */ for (i = 1; i < 16; i <<= 1) - if ((BLK_CNT - lastblk) == (i * SBLOCKSIZE / 512)) { + if ((BLK_CNT - lastblk) == (daddr_t)(i * SBLOCKSIZE / 512)) { if (flags & LABELS) ffs_printpart(sbi, LABELS, i, n); else @@ -348,7 +348,7 @@ lfs_scan(struct sblockinfo *sbi, int n) */ case FIRST_SBLOCK_ADDRESS: /* copy partition offset */ - if (sbi->lfs_off != lastblk) + if ((daddr_t)sbi->lfs_off != lastblk) sbi->lfs_off = BLK_CNT - (LFS_LABELPAD / 512); break; case SECOND_SBLOCK_ADDRESS: