Skip to content

Commit

Permalink
fix -Wsign-compare issues
Browse files Browse the repository at this point in the history
  • Loading branch information
lukem committed Jan 18, 2009
1 parent 9d0f724 commit c37aa81
Show file tree
Hide file tree
Showing 14 changed files with 63 additions and 63 deletions.
6 changes: 3 additions & 3 deletions bin/df/df.c
@@ -1,4 +1,4 @@
/* $NetBSD: df.c,v 1.83 2008/07/20 00:52:39 lukem Exp $ */
/* $NetBSD: df.c,v 1.84 2009/01/18 00:30:17 lukem Exp $ */

/*
* Copyright (c) 1980, 1990, 1993, 1994
Expand Down Expand Up @@ -45,7 +45,7 @@ __COPYRIGHT(
#if 0
static char sccsid[] = "@(#)df.c 8.7 (Berkeley) 4/2/94";
#else
__RCSID("$NetBSD: df.c,v 1.83 2008/07/20 00:52:39 lukem Exp $");
__RCSID("$NetBSD: df.c,v 1.84 2009/01/18 00:30:17 lukem Exp $");
#endif
#endif /* not lint */

Expand Down Expand Up @@ -352,7 +352,7 @@ prthuman(struct statvfs *sfsp, int64_t used, int64_t bavail)
* Attempts to avoid overflow for large filesystems.
*/
#define fsbtoblk(num, fsbs, bs) \
(((fsbs) != 0 && (fsbs) < (bs)) ? \
(((fsbs) != 0 && (uint64_t)(fsbs) < (uint64_t)(bs)) ? \
(int64_t)(num) / (int64_t)((bs) / (fsbs)) : \
(int64_t)(num) * ((fsbs) / (bs)))

Expand Down
6 changes: 3 additions & 3 deletions bin/sh/expand.c
@@ -1,4 +1,4 @@
/* $NetBSD: expand.c,v 1.81 2008/12/21 17:15:09 christos Exp $ */
/* $NetBSD: expand.c,v 1.82 2009/01/18 00:30:54 lukem Exp $ */

/*-
* Copyright (c) 1991, 1993
Expand Down Expand Up @@ -37,7 +37,7 @@
#if 0
static char sccsid[] = "@(#)expand.c 8.5 (Berkeley) 5/15/95";
#else
__RCSID("$NetBSD: expand.c,v 1.81 2008/12/21 17:15:09 christos Exp $");
__RCSID("$NetBSD: expand.c,v 1.82 2009/01/18 00:30:54 lukem Exp $");
#endif
#endif /* not lint */

Expand Down Expand Up @@ -372,7 +372,7 @@ expari(int flag)
*/
/* SPACE_NEEDED is enough for all digits, plus possible "-", plus 2 (why?) */
#define SPACE_NEEDED ((sizeof(intmax_t) * CHAR_BIT + 2) / 3 + 1 + 2)
CHECKSTRSPACE(SPACE_NEEDED - 2, expdest);
CHECKSTRSPACE((int)(SPACE_NEEDED - 2), expdest);
USTPUTC('\0', expdest);
start = stackblock();
p = expdest - 1;
Expand Down
6 changes: 3 additions & 3 deletions bin/sh/main.c
@@ -1,4 +1,4 @@
/* $NetBSD: main.c,v 1.52 2008/10/16 14:55:28 dholland Exp $ */
/* $NetBSD: main.c,v 1.53 2009/01/18 00:30:54 lukem Exp $ */

/*-
* Copyright (c) 1991, 1993
Expand Down Expand Up @@ -42,7 +42,7 @@ __COPYRIGHT("@(#) Copyright (c) 1991, 1993\
#if 0
static char sccsid[] = "@(#)main.c 8.7 (Berkeley) 7/19/95";
#else
__RCSID("$NetBSD: main.c,v 1.52 2008/10/16 14:55:28 dholland Exp $");
__RCSID("$NetBSD: main.c,v 1.53 2009/01/18 00:30:54 lukem Exp $");
#endif
#endif /* not lint */

Expand Down Expand Up @@ -201,7 +201,7 @@ main(int argc, char **argv)
SIGPIPE
};
#define SIGSSIZE (sizeof(sigs)/sizeof(sigs[0]))
int i;
size_t i;

for (i = 0; i < SIGSSIZE; i++)
setsignal(sigs[i], 0);
Expand Down
14 changes: 7 additions & 7 deletions bin/sh/options.c
@@ -1,4 +1,4 @@
/* $NetBSD: options.c,v 1.40 2005/12/13 17:44:18 dsl Exp $ */
/* $NetBSD: options.c,v 1.41 2009/01/18 00:30:54 lukem Exp $ */

/*-
* Copyright (c) 1991, 1993
Expand Down Expand Up @@ -37,7 +37,7 @@
#if 0
static char sccsid[] = "@(#)options.c 8.2 (Berkeley) 5/4/95";
#else
__RCSID("$NetBSD: options.c,v 1.40 2005/12/13 17:44:18 dsl Exp $");
__RCSID("$NetBSD: options.c,v 1.41 2009/01/18 00:30:54 lukem Exp $");
#endif
#endif /* not lint */

Expand Down Expand Up @@ -86,7 +86,7 @@ STATIC int getopts(char *, char *, char **, char ***, char **);
void
procargs(int argc, char **argv)
{
int i;
size_t i;

argptr = argv;
if (argc > 0)
Expand Down Expand Up @@ -197,9 +197,9 @@ options(int cmdline)
}

static void
set_opt_val(int i, int val)
set_opt_val(size_t i, int val)
{
int j;
size_t j;
int flag;

if (val && (flag = optlist[i].opt_set)) {
Expand All @@ -218,7 +218,7 @@ set_opt_val(int i, int val)
STATIC void
minus_o(char *name, int val)
{
int i;
size_t i;

if (name == NULL) {
if (val) {
Expand Down Expand Up @@ -249,7 +249,7 @@ minus_o(char *name, int val)
STATIC void
setoption(int flag, int val)
{
int i;
size_t i;

for (i = 0; i < NOPTS; i++)
if (optlist[i].letter == flag) {
Expand Down
6 changes: 3 additions & 3 deletions bin/sh/parser.c
@@ -1,4 +1,4 @@
/* $NetBSD: parser.c,v 1.73 2008/11/08 00:14:05 christos Exp $ */
/* $NetBSD: parser.c,v 1.74 2009/01/18 00:30:54 lukem Exp $ */

/*-
* Copyright (c) 1991, 1993
Expand Down Expand Up @@ -37,7 +37,7 @@
#if 0
static char sccsid[] = "@(#)parser.c 8.7 (Berkeley) 5/16/95";
#else
__RCSID("$NetBSD: parser.c,v 1.73 2008/11/08 00:14:05 christos Exp $");
__RCSID("$NetBSD: parser.c,v 1.74 2009/01/18 00:30:54 lukem Exp $");
#endif
#endif /* not lint */

Expand Down Expand Up @@ -924,7 +924,7 @@ readtoken1(int firstc, char const *syn, char *eofmark, int striptabs)
int * volatile dblquotep = NULL;
volatile size_t maxnest = 32;
volatile int dblquote;
volatile int varnest; /* levels of variables expansion */
volatile size_t varnest; /* levels of variables expansion */
volatile int arinest; /* levels of arithmetic expansion */
volatile int parenlevel; /* levels of parens in arithmetic */
volatile int oldstyle;
Expand Down
4 changes: 2 additions & 2 deletions games/hack/extern.h
@@ -1,4 +1,4 @@
/* $NetBSD: extern.h,v 1.8 2008/04/28 20:22:54 martin Exp $ */
/* $NetBSD: extern.h,v 1.9 2009/01/18 00:34:03 lukem Exp $ */

/*-
* Copyright (c) 1997 The NetBSD Foundation, Inc.
Expand Down Expand Up @@ -236,7 +236,7 @@ int dosuspend(void);

/* hack.lev.c */
void savelev(int, xchar);
void bwrite(int, const void *, unsigned);
void bwrite(int, const void *, size_t);
void saveobjchn(int, struct obj *);
void savemonchn(int, struct monst *);
void savegoldchn(int, struct gold *);
Expand Down
8 changes: 4 additions & 4 deletions games/hack/hack.lev.c
@@ -1,4 +1,4 @@
/* $NetBSD: hack.lev.c,v 1.7 2008/01/28 06:55:41 dholland Exp $ */
/* $NetBSD: hack.lev.c,v 1.8 2009/01/18 00:34:03 lukem Exp $ */

/*
* Copyright (c) 1985, Stichting Centrum voor Wiskunde en Informatica,
Expand Down Expand Up @@ -63,7 +63,7 @@

#include <sys/cdefs.h>
#ifndef lint
__RCSID("$NetBSD: hack.lev.c,v 1.7 2008/01/28 06:55:41 dholland Exp $");
__RCSID("$NetBSD: hack.lev.c,v 1.8 2009/01/18 00:34:03 lukem Exp $");
#endif /* not lint */

#include <stdlib.h>
Expand Down Expand Up @@ -133,10 +133,10 @@ void
bwrite(fd, loc, num)
int fd;
const void *loc;
unsigned num;
size_t num;
{
/* lint wants the 3rd arg of write to be an int; lint -p an unsigned */
if (write(fd, loc, (int) num) != num)
if ((size_t)write(fd, loc, num) != num)
panic("cannot write %u bytes to file #%d", num, fd);
}

Expand Down
6 changes: 3 additions & 3 deletions games/hack/hack.o_init.c
@@ -1,4 +1,4 @@
/* $NetBSD: hack.o_init.c,v 1.7 2003/04/02 18:36:38 jsm Exp $ */
/* $NetBSD: hack.o_init.c,v 1.8 2009/01/18 00:34:03 lukem Exp $ */

/*
* Copyright (c) 1985, Stichting Centrum voor Wiskunde en Informatica,
Expand Down Expand Up @@ -63,7 +63,7 @@

#include <sys/cdefs.h>
#ifndef lint
__RCSID("$NetBSD: hack.o_init.c,v 1.7 2003/04/02 18:36:38 jsm Exp $");
__RCSID("$NetBSD: hack.o_init.c,v 1.8 2009/01/18 00:34:03 lukem Exp $");
#endif /* not lint */

#include <string.h>
Expand Down Expand Up @@ -180,7 +180,7 @@ savenames(fd)
int fd;
{
int i;
unsigned len;
size_t len;
bwrite(fd, (char *) bases, sizeof bases);
bwrite(fd, (char *) objects, sizeof objects);
/*
Expand Down
15 changes: 8 additions & 7 deletions sbin/bioctl/bioctl.c
@@ -1,4 +1,4 @@
/* $NetBSD: bioctl.c,v 1.11 2008/03/03 16:10:48 xtraeme Exp $ */
/* $NetBSD: bioctl.c,v 1.12 2009/01/18 00:27:59 lukem Exp $ */
/* $OpenBSD: bioctl.c,v 1.52 2007/03/20 15:26:06 jmc Exp $ */

/*
Expand Down Expand Up @@ -31,7 +31,7 @@
#include <sys/cdefs.h>

#ifndef lint
__RCSID("$NetBSD: bioctl.c,v 1.11 2008/03/03 16:10:48 xtraeme Exp $");
__RCSID("$NetBSD: bioctl.c,v 1.12 2009/01/18 00:27:59 lukem Exp $");
#endif

#include <sys/types.h>
Expand Down Expand Up @@ -733,7 +733,8 @@ bio_volops_create(int fd, int argc, char **argv)
errx(EXIT_FAILURE, "Invalid Volume ID value");

if (argc == 7)
if (dehumanize_number(argv[3], &volsize) == -1)
if (dehumanize_number(argv[3], &volsize) == -1
|| volsize < 0)
errx(EXIT_FAILURE, "Invalid SIZE value");

bc.bc_stripe = (unsigned int)strtoul(stripe, &endptr, 10);
Expand Down Expand Up @@ -798,7 +799,7 @@ bio_volops_create(int fd, int argc, char **argv)
switch (bc.bc_level) {
case 0: /* RAID 0 requires at least one disk */
if (argc == 7) {
if (volsize > (disksize * user_disks))
if ((uint64_t)volsize > (disksize * user_disks))
errx(EXIT_FAILURE, "volume size specified "
"is larger than available on free disks");
bc.bc_size = (uint64_t)volsize;
Expand All @@ -816,7 +817,7 @@ bio_volops_create(int fd, int argc, char **argv)
bc.bc_level = BIOC_SVOL_RAID10;

if (argc == 7) {
if (volsize > ((disksize * user_disks) / 2))
if ((uint64_t)volsize > ((disksize * user_disks) / 2))
errx(EXIT_FAILURE, "volume size specified "
"is larger than available on free disks");
bc.bc_size = (uint64_t)volsize;
Expand All @@ -831,7 +832,7 @@ bio_volops_create(int fd, int argc, char **argv)
"this RAID level");

if (argc == 7) {
if (volsize > (disksize * (user_disks - 1)))
if ((uint64_t)volsize > (disksize * (user_disks - 1)))
errx(EXIT_FAILURE, "volume size specified "
"is larger than available on free disks");
bc.bc_size = (uint64_t)volsize;
Expand All @@ -845,7 +846,7 @@ bio_volops_create(int fd, int argc, char **argv)
"this RAID level");

if (argc == 7) {
if (volsize >
if ((uint64_t)volsize >
((disksize * user_disks) - (disksize * 2)))
err(EXIT_FAILURE, "volume size specified "
"is larger than available on free disks");
Expand Down
18 changes: 8 additions & 10 deletions sbin/ifconfig/ieee80211.c
@@ -1,4 +1,4 @@
/* $NetBSD: ieee80211.c,v 1.22 2008/07/15 21:27:58 dyoung Exp $ */
/* $NetBSD: ieee80211.c,v 1.23 2009/01/18 00:24:29 lukem Exp $ */

/*
* Copyright (c) 1983, 1993
Expand Down Expand Up @@ -31,7 +31,7 @@

#include <sys/cdefs.h>
#ifndef lint
__RCSID("$NetBSD: ieee80211.c,v 1.22 2008/07/15 21:27:58 dyoung Exp $");
__RCSID("$NetBSD: ieee80211.c,v 1.23 2009/01/18 00:24:29 lukem Exp $");
#endif /* not lint */

#include <sys/param.h>
Expand Down Expand Up @@ -93,7 +93,6 @@ static int setifrts(prop_dictionary_t, prop_dictionary_t);
static int scan_exec(prop_dictionary_t, prop_dictionary_t);

static void printies(const u_int8_t *, int, int);
static void printie(const char* , const uint8_t *, size_t , int);
static void printwmeparam(const char *, const u_int8_t *, size_t , int);
static void printwmeinfo(const char *, const u_int8_t *, size_t , int);
static const char * wpa_cipher(const u_int8_t *);
Expand Down Expand Up @@ -768,7 +767,7 @@ list_scan(prop_dictionary_t env)
if (direct_ioctl(env, SIOCG80211, &ireq) < 0)
errx(EXIT_FAILURE, "unable to get scan results");
len = ireq.i_len;
if (len < sizeof(struct ieee80211req_scan_result))
if (len < (int)sizeof(struct ieee80211req_scan_result))
return;

ssidmax = IEEE80211_NWID_LEN;
Expand Down Expand Up @@ -799,10 +798,10 @@ list_scan(prop_dictionary_t env)
, sr->isr_intval
, getcaps(sr->isr_capinfo)
);
printies(vp + sr->isr_ssid_len, sr->isr_ie_len, 24);;
printies(vp + sr->isr_ssid_len, sr->isr_ie_len, 24);
printf("\n");
cp += sr->isr_len, len -= sr->isr_len;
} while (len >= sizeof(struct ieee80211req_scan_result));
} while (len >= (int)sizeof(struct ieee80211req_scan_result));
}
/*
* Convert MHz frequency to IEEE channel number.
Expand Down Expand Up @@ -878,7 +877,7 @@ printie(const char* tag, const uint8_t *ie, size_t ielen, int maxlen)
printf("%s", tag);

maxlen -= strlen(tag)+2;
if (2*ielen > maxlen)
if ((int)(2*ielen) > maxlen)
maxlen--;
printf("<");
for (; ielen > 0; ie++, ielen--) {
Expand Down Expand Up @@ -1131,8 +1130,7 @@ static int
copy_essid(char buf[], size_t bufsize, const u_int8_t *essid, size_t essid_len)
{
const u_int8_t *p;
size_t maxlen;
int i;
size_t maxlen, i;

if (essid_len > bufsize)
maxlen = bufsize;
Expand Down Expand Up @@ -1175,7 +1173,7 @@ static void
printrates(const char *tag, const u_int8_t *ie, size_t ielen, int maxlen)
{
const char *sep;
int i;
size_t i;

printf("%s", tag);
sep = "<";
Expand Down
6 changes: 3 additions & 3 deletions sbin/ifconfig/ifconfig.c
@@ -1,4 +1,4 @@
/* $NetBSD: ifconfig.c,v 1.213 2008/08/01 22:29:13 dyoung Exp $ */
/* $NetBSD: ifconfig.c,v 1.214 2009/01/18 00:24:29 lukem Exp $ */

/*-
* Copyright (c) 1997, 1998, 2000 The NetBSD Foundation, Inc.
Expand Down Expand Up @@ -63,7 +63,7 @@
#ifndef lint
__COPYRIGHT("@(#) Copyright (c) 1983, 1993\
The Regents of the University of California. All rights reserved.");
__RCSID("$NetBSD: ifconfig.c,v 1.213 2008/08/01 22:29:13 dyoung Exp $");
__RCSID("$NetBSD: ifconfig.c,v 1.214 2009/01/18 00:24:29 lukem Exp $");
#endif /* not lint */

#include <sys/param.h>
Expand Down Expand Up @@ -691,7 +691,7 @@ main(int argc, char **argv)
static void
init_afs(void)
{
int i;
size_t i;
const struct afswtch *afp;
struct kwinst kw = {.k_type = KW_T_INT};

Expand Down

0 comments on commit c37aa81

Please sign in to comment.