Module Name: src
Committed By: lukem
Date: Sun Apr 5 11:55:39 UTC 2009
Modified Files:
src/usr.sbin/installboot: bbinfo.c installboot.c
src/usr.sbin/installboot/arch: alpha.c hp300.c i386.c landisk.c
next68k.c pmax.c vax.c
Log Message:
fix sign-compare issues
To generate a diff of this commit:
cvs rdiff -u -r1.13 -r1.14 src/usr.sbin/installboot/bbinfo.c
cvs rdiff -u -r1.30 -r1.31 src/usr.sbin/installboot/installboot.c
cvs rdiff -u -r1.18 -r1.19 src/usr.sbin/installboot/arch/alpha.c
cvs rdiff -u -r1.10 -r1.11 src/usr.sbin/installboot/arch/hp300.c
cvs rdiff -u -r1.31 -r1.32 src/usr.sbin/installboot/arch/i386.c
cvs rdiff -u -r1.3 -r1.4 src/usr.sbin/installboot/arch/landisk.c
cvs rdiff -u -r1.5 -r1.6 src/usr.sbin/installboot/arch/next68k.c
cvs rdiff -u -r1.13 -r1.14 src/usr.sbin/installboot/arch/pmax.c
cvs rdiff -u -r1.12 -r1.13 src/usr.sbin/installboot/arch/vax.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/usr.sbin/installboot/bbinfo.c
diff -u src/usr.sbin/installboot/bbinfo.c:1.13 src/usr.sbin/installboot/bbinfo.c:1.14
--- src/usr.sbin/installboot/bbinfo.c:1.13 Fri May 9 10:53:55 2008
+++ src/usr.sbin/installboot/bbinfo.c Sun Apr 5 11:55:39 2009
@@ -1,4 +1,4 @@
-/* $NetBSD: bbinfo.c,v 1.13 2008/05/09 10:53:55 tsutsui Exp $ */
+/* $NetBSD: bbinfo.c,v 1.14 2009/04/05 11:55:39 lukem Exp $ */
/*-
* Copyright (c) 1998, 2002 The NetBSD Foundation, Inc.
@@ -35,7 +35,7 @@
#include <sys/cdefs.h>
#if !defined(__lint)
-__RCSID("$NetBSD: bbinfo.c,v 1.13 2008/05/09 10:53:55 tsutsui Exp $");
+__RCSID("$NetBSD: bbinfo.c,v 1.14 2009/04/05 11:55:39 lukem Exp $");
#endif /* !__lint */
#include <sys/param.h>
@@ -81,7 +81,7 @@
if (rv == -1) {
warn("Reading `%s'", params->filesystem);
goto done;
- } else if (rv != bbparams->maxsize) {
+ } else if ((uint32_t)rv != bbparams->maxsize) {
warnx("Reading `%s': short read", params->filesystem);
goto done;
}
@@ -127,7 +127,7 @@
if (rv == -1) {
warn("Writing `%s'", params->filesystem);
goto done;
- } else if (rv != bbparams->maxsize) {
+ } else if ((uint32_t)rv != bbparams->maxsize) {
warnx("Writing `%s': short write", params->filesystem);
goto done;
} else
@@ -202,9 +202,9 @@
}
#define HOSTTOTARGET32(x) ((bbparams->endian == BBINFO_LITTLE_ENDIAN) \
- ? htole32((x)) : htobe32((x)))
+ ? (uint32_t)htole32((x)) : (uint32_t)htobe32((x)))
#define TARGET32TOHOST(x) ((bbparams->endian == BBINFO_LITTLE_ENDIAN) \
- ? le32toh((x)) : be32toh((x)))
+ ? (uint32_t)le32toh((x)) : (uint32_t)be32toh((x)))
/* Look for the bbinfo structure. */
bbinfop = NULL;
@@ -314,7 +314,7 @@
if (rv == -1) {
warn("Writing `%s'", params->filesystem);
goto done;
- } else if (rv != bbparams->maxsize) {
+ } else if ((uint32_t)rv != bbparams->maxsize) {
warnx("Writing `%s': short write", params->filesystem);
goto done;
} else {
Index: src/usr.sbin/installboot/installboot.c
diff -u src/usr.sbin/installboot/installboot.c:1.30 src/usr.sbin/installboot/installboot.c:1.31
--- src/usr.sbin/installboot/installboot.c:1.30 Mon Apr 28 20:24:16 2008
+++ src/usr.sbin/installboot/installboot.c Sun Apr 5 11:55:39 2009
@@ -1,4 +1,4 @@
-/* $NetBSD: installboot.c,v 1.30 2008/04/28 20:24:16 martin Exp $ */
+/* $NetBSD: installboot.c,v 1.31 2009/04/05 11:55:39 lukem Exp $ */
/*-
* Copyright (c) 2002 The NetBSD Foundation, Inc.
@@ -35,7 +35,7 @@
#include <sys/cdefs.h>
#if defined(__RCSID) && !defined(__lint)
-__RCSID("$NetBSD: installboot.c,v 1.30 2008/04/28 20:24:16 martin Exp $");
+__RCSID("$NetBSD: installboot.c,v 1.31 2009/04/05 11:55:39 lukem Exp $");
#endif /* !__lint */
#include <sys/ioctl.h>
@@ -370,10 +370,9 @@
val = strtoul(option, &cp, 0);
if (cp > option + len || (*cp != 0 && *cp != ','))
break;
- OPTION(params, int, opt) = val;
- if (OPTION(params, int, opt) != val)
- /* value got truncated on int convertion */
+ if (val > INT_MAX)
break;
+ OPTION(params, int, opt) = (int)val;
continue;
default:
errx(1, "Internal error: option `%s' has invalid type %d",
Index: src/usr.sbin/installboot/arch/alpha.c
diff -u src/usr.sbin/installboot/arch/alpha.c:1.18 src/usr.sbin/installboot/arch/alpha.c:1.19
--- src/usr.sbin/installboot/arch/alpha.c:1.18 Mon Apr 28 20:24:16 2008
+++ src/usr.sbin/installboot/arch/alpha.c Sun Apr 5 11:55:39 2009
@@ -1,4 +1,4 @@
-/* $NetBSD: alpha.c,v 1.18 2008/04/28 20:24:16 martin Exp $ */
+/* $NetBSD: alpha.c,v 1.19 2009/04/05 11:55:39 lukem Exp $ */
/*-
* Copyright (c) 2002 The NetBSD Foundation, Inc.
@@ -95,7 +95,7 @@
#include <sys/cdefs.h>
#if !defined(__lint)
-__RCSID("$NetBSD: alpha.c,v 1.18 2008/04/28 20:24:16 martin Exp $");
+__RCSID("$NetBSD: alpha.c,v 1.19 2009/04/05 11:55:39 lukem Exp $");
#endif /* !__lint */
#include <sys/param.h>
@@ -309,7 +309,7 @@
if (rv == -1) {
warn("Writing `%s'", params->filesystem);
goto done;
- } else if (rv != bootstrapsize) {
+ } else if ((size_t)rv != bootstrapsize) {
warnx("Writing `%s': short write", params->filesystem);
goto done;
}
Index: src/usr.sbin/installboot/arch/hp300.c
diff -u src/usr.sbin/installboot/arch/hp300.c:1.10 src/usr.sbin/installboot/arch/hp300.c:1.11
--- src/usr.sbin/installboot/arch/hp300.c:1.10 Mon Apr 28 20:24:16 2008
+++ src/usr.sbin/installboot/arch/hp300.c Sun Apr 5 11:55:39 2009
@@ -1,4 +1,4 @@
-/* $NetBSD: hp300.c,v 1.10 2008/04/28 20:24:16 martin Exp $ */
+/* $NetBSD: hp300.c,v 1.11 2009/04/05 11:55:39 lukem Exp $ */
/*-
* Copyright (c) 2003 The NetBSD Foundation, Inc.
@@ -35,7 +35,7 @@
#include <sys/cdefs.h>
#if !defined(__lint)
-__RCSID("$NetBSD: hp300.c,v 1.10 2008/04/28 20:24:16 martin Exp $");
+__RCSID("$NetBSD: hp300.c,v 1.11 2009/04/05 11:55:39 lukem Exp $");
#endif /* !__lint */
/* We need the target disklabel.h, not the hosts one..... */
@@ -137,7 +137,7 @@
* Maybe we ought to be able to take a binary file and add
* it to the LIF filesystem.
*/
- if (boot_size < params->s1stat.st_size) {
+ if (boot_size < (uint64_t)params->s1stat.st_size) {
warn("BOOT partition too small (%llu < %llu)",
(unsigned long long)boot_size,
(unsigned long long)params->s1stat.st_size);
@@ -155,11 +155,12 @@
/* Relocate files, sanity check LIF directory on the way */
lifdir = (void *)(bootstrap + HP300_SECTSIZE * 2);
for (i = 0; i < 8; lifdir++, i++) {
- int addr = be32toh(lifdir->dir_addr);
- int limit = (params->s1stat.st_size - 1) / HP300_SECTSIZE + 1;
- if (addr + be32toh(lifdir->dir_length) > limit) {
+ int32_t addr = be32toh(lifdir->dir_addr);
+ int32_t limit = (params->s1stat.st_size - 1) / HP300_SECTSIZE + 1;
+ int32_t end = addr + be32toh(lifdir->dir_length);
+ if (end > limit) {
warnx("LIF entry %d larger (%d %d) than LIF file",
- i, addr + be32toh(lifdir->dir_length), limit);
+ i, end, limit);
goto done;
}
if (addr != 0 && boot_offset != 0)
Index: src/usr.sbin/installboot/arch/i386.c
diff -u src/usr.sbin/installboot/arch/i386.c:1.31 src/usr.sbin/installboot/arch/i386.c:1.32
--- src/usr.sbin/installboot/arch/i386.c:1.31 Wed Feb 18 20:06:27 2009
+++ src/usr.sbin/installboot/arch/i386.c Sun Apr 5 11:55:39 2009
@@ -1,4 +1,4 @@
-/* $NetBSD: i386.c,v 1.31 2009/02/18 20:06:27 christos Exp $ */
+/* $NetBSD: i386.c,v 1.32 2009/04/05 11:55:39 lukem Exp $ */
/*-
* Copyright (c) 2003 The NetBSD Foundation, Inc.
@@ -35,7 +35,7 @@
#include <sys/cdefs.h>
#if !defined(__lint)
-__RCSID("$NetBSD: i386.c,v 1.31 2009/02/18 20:06:27 christos Exp $");
+__RCSID("$NetBSD: i386.c,v 1.32 2009/04/05 11:55:39 lukem Exp $");
#endif /* !__lint */
#include <sys/param.h>
@@ -201,7 +201,7 @@
printf("speed %d, ", le32toh(bpp->bp_conspeed));
printf("ioaddr %x, ", le32toh(bpp->bp_consaddr));
for (i = 0; i < nelem(consoles); i++) {
- if (consoles[i].dev == le32toh(bpp->bp_consdev))
+ if (consoles[i].dev == (int)le32toh(bpp->bp_consdev))
break;
}
if (i == nelem(consoles))
@@ -222,7 +222,7 @@
update_i386_boot_params(ib_params *params, struct x86_boot_params *bpp)
{
struct x86_boot_params bp;
- int bplen;
+ uint32_t bplen;
size_t i;
bplen = le32toh(bpp->bp_length);
@@ -306,7 +306,7 @@
* There is only 8k of space in a UFSv1 partition (and ustarfs)
* so ensure we don't splat over anything important.
*/
- if (params->s1stat.st_size > sizeof bootstrap) {
+ if (params->s1stat.st_size > (off_t)(sizeof bootstrap)) {
warnx("stage1 bootstrap `%s' (%u bytes) is larger than 8192 bytes",
params->stage1, (unsigned int)params->s1stat.st_size);
return 0;
Index: src/usr.sbin/installboot/arch/landisk.c
diff -u src/usr.sbin/installboot/arch/landisk.c:1.3 src/usr.sbin/installboot/arch/landisk.c:1.4
--- src/usr.sbin/installboot/arch/landisk.c:1.3 Mon Apr 28 20:24:16 2008
+++ src/usr.sbin/installboot/arch/landisk.c Sun Apr 5 11:55:39 2009
@@ -1,4 +1,4 @@
-/* $NetBSD: landisk.c,v 1.3 2008/04/28 20:24:16 martin Exp $ */
+/* $NetBSD: landisk.c,v 1.4 2009/04/05 11:55:39 lukem Exp $ */
/*-
* Copyright (c) 2003 The NetBSD Foundation, Inc.
@@ -35,7 +35,7 @@
#include <sys/cdefs.h>
#if !defined(__lint)
-__RCSID("$NetBSD: landisk.c,v 1.3 2008/04/28 20:24:16 martin Exp $");
+__RCSID("$NetBSD: landisk.c,v 1.4 2009/04/05 11:55:39 lukem Exp $");
#endif /* !__lint */
#include <sys/param.h>
@@ -65,9 +65,9 @@
uint8_t *bootstrapbuf;
ssize_t rv;
uint32_t magic;
- u_int bootstrapsize;
+ size_t bootstrapsize;
int retval, i;
- int bplen;
+ uint32_t bplen;
int bpbsize;
assert(params != NULL);
@@ -118,7 +118,7 @@
bootstrapbuf = malloc(bootstrapsize);
if (bootstrapbuf == NULL) {
- warn("Allocating %u bytes", bootstrapsize);
+ warn("Allocating %zu bytes", bootstrapsize);
goto done;
}
memset(bootstrapbuf, 0, bootstrapsize);
@@ -161,7 +161,7 @@
* Ensure bootxx hasn't got any code or data (i.e, non-zero bytes) in
* the partition table.
*/
- for (i = 0; i < sizeof(mbr.mbr_parts); i++) {
+ for (i = 0; i < (int)sizeof(mbr.mbr_parts); i++) {
if (*(uint8_t *)(bootstrapbuf + MBR_PART_OFFSET + i) != 0) {
warnx(
"Partition table has non-zero byte at offset %d in `%s'",
@@ -236,7 +236,7 @@
if (rv == -1) {
warn("Writing `%s'", params->filesystem);
goto done;
- } else if (rv != bootstrapsize - 512 * 2) {
+ } else if ((size_t)rv != bootstrapsize - 512 * 2) {
warnx("Writing `%s': short write", params->filesystem);
goto done;
}
Index: src/usr.sbin/installboot/arch/next68k.c
diff -u src/usr.sbin/installboot/arch/next68k.c:1.5 src/usr.sbin/installboot/arch/next68k.c:1.6
--- src/usr.sbin/installboot/arch/next68k.c:1.5 Mon Apr 28 20:24:16 2008
+++ src/usr.sbin/installboot/arch/next68k.c Sun Apr 5 11:55:39 2009
@@ -1,4 +1,4 @@
-/* $NetBSD: next68k.c,v 1.5 2008/04/28 20:24:16 martin Exp $ */
+/* $NetBSD: next68k.c,v 1.6 2009/04/05 11:55:39 lukem Exp $ */
/*-
* Copyright (c) 2003 The NetBSD Foundation, Inc.
@@ -35,7 +35,7 @@
#include <sys/cdefs.h>
#if !defined(__lint)
-__RCSID("$NetBSD: next68k.c,v 1.5 2008/04/28 20:24:16 martin Exp $");
+__RCSID("$NetBSD: next68k.c,v 1.6 2009/04/05 11:55:39 lukem Exp $");
#endif /* !__lint */
#include <sys/param.h>
@@ -78,7 +78,7 @@
{
int retval, labelupdated;
uint8_t *bootbuf;
- u_int bootsize;
+ size_t bootsize;
ssize_t rv;
uint32_t cd_secsize;
int sec_netonb_mult;
@@ -139,7 +139,7 @@
bootbuf = malloc(bootsize);
if (bootbuf == NULL) {
- warn("Allocating %lu bytes", (unsigned long)bootsize);
+ warn("Allocating %zu bytes", bootsize);
goto done;
}
memset(bootbuf, 0, bootsize);
@@ -193,11 +193,11 @@
b1 = fp - bootsize / cd_secsize;
}
}
- if (next68klabel->cd_boot_blkno[0] != htobe32(b0)) {
+ if (next68klabel->cd_boot_blkno[0] != (int32_t)htobe32(b0)) {
next68klabel->cd_boot_blkno[0] = htobe32(b0);
labelupdated = 1;
}
- if (next68klabel->cd_boot_blkno[1] != htobe32(b1)) {
+ if (next68klabel->cd_boot_blkno[1] != (int32_t)htobe32(b1)) {
next68klabel->cd_boot_blkno[1] = htobe32(b1);
labelupdated = 1;
}
@@ -245,7 +245,7 @@
warn("Writing `%s' at %d", params->filesystem, b0);
goto done;
}
- if (rv != bootsize) {
+ if ((size_t)rv != bootsize) {
warnx("Writing `%s' at %d: short write",
params->filesystem, b0);
goto done;
Index: src/usr.sbin/installboot/arch/pmax.c
diff -u src/usr.sbin/installboot/arch/pmax.c:1.13 src/usr.sbin/installboot/arch/pmax.c:1.14
--- src/usr.sbin/installboot/arch/pmax.c:1.13 Mon Apr 28 20:24:16 2008
+++ src/usr.sbin/installboot/arch/pmax.c Sun Apr 5 11:55:39 2009
@@ -1,4 +1,4 @@
-/* $NetBSD: pmax.c,v 1.13 2008/04/28 20:24:16 martin Exp $ */
+/* $NetBSD: pmax.c,v 1.14 2009/04/05 11:55:39 lukem Exp $ */
/*-
* Copyright (c) 1999, 2002 The NetBSD Foundation, Inc.
@@ -98,7 +98,7 @@
#include <sys/cdefs.h>
#if !defined(__lint)
-__RCSID("$NetBSD: pmax.c,v 1.13 2008/04/28 20:24:16 martin Exp $");
+__RCSID("$NetBSD: pmax.c,v 1.14 2009/04/05 11:55:39 lukem Exp $");
#endif /* !__lint */
#include <sys/param.h>
@@ -269,7 +269,7 @@
if (rv == -1) {
warn("Writing `%s'", params->filesystem);
goto done;
- } else if (rv != bootstrapsize) {
+ } else if ((size_t)rv != bootstrapsize) {
warnx("Writing `%s': short write", params->filesystem);
goto done;
}
@@ -357,7 +357,8 @@
/* Now load the bootstrap into memory */
for (i = 0; i < nsegs; i++) {
- if (pread(params->s1fd, *data + seglist[i].addr - lowaddr,
+ if ((Elf32_Word)pread(params->s1fd,
+ *data + seglist[i].addr - lowaddr,
seglist[i].f_size, (off_t)seglist[i].f_offset)
!= seglist[i].f_size) {
warn("Reading `%s'", params->stage1);
Index: src/usr.sbin/installboot/arch/vax.c
diff -u src/usr.sbin/installboot/arch/vax.c:1.12 src/usr.sbin/installboot/arch/vax.c:1.13
--- src/usr.sbin/installboot/arch/vax.c:1.12 Mon Apr 28 20:24:16 2008
+++ src/usr.sbin/installboot/arch/vax.c Sun Apr 5 11:55:39 2009
@@ -1,4 +1,4 @@
-/* $NetBSD: vax.c,v 1.12 2008/04/28 20:24:16 martin Exp $ */
+/* $NetBSD: vax.c,v 1.13 2009/04/05 11:55:39 lukem Exp $ */
/*-
* Copyright (c) 1999, 2002 The NetBSD Foundation, Inc.
@@ -68,7 +68,7 @@
#include <sys/cdefs.h>
#if !defined(__lint)
-__RCSID("$NetBSD: vax.c,v 1.12 2008/04/28 20:24:16 martin Exp $");
+__RCSID("$NetBSD: vax.c,v 1.13 2009/04/05 11:55:39 lukem Exp $");
#endif /* !__lint */
#include <sys/param.h>
@@ -261,7 +261,7 @@
if (rv == -1) {
warn("Writing `%s'", params->filesystem);
goto done;
- } else if (rv != bootstrapsize) {
+ } else if ((size_t)rv != bootstrapsize) {
warnx("Writing `%s': short write", params->filesystem);
goto done;
}