Module Name:    src
Committed By:   christos
Date:           Sun Aug 14 17:50:17 UTC 2011

Modified Files:
        src/usr.sbin/installboot: Makefile
        src/usr.sbin/installboot/arch: alpha.c i386.c

Log Message:
fix various gcc-4.5 warnings


To generate a diff of this commit:
cvs rdiff -u -r1.45 -r1.46 src/usr.sbin/installboot/Makefile
cvs rdiff -u -r1.20 -r1.21 src/usr.sbin/installboot/arch/alpha.c
cvs rdiff -u -r1.36 -r1.37 src/usr.sbin/installboot/arch/i386.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/Makefile
diff -u src/usr.sbin/installboot/Makefile:1.45 src/usr.sbin/installboot/Makefile:1.46
--- src/usr.sbin/installboot/Makefile:1.45	Tue Jun 21 22:49:45 2011
+++ src/usr.sbin/installboot/Makefile	Sun Aug 14 13:50:16 2011
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.45 2011/06/22 02:49:45 mrg Exp $
+#	$NetBSD: Makefile,v 1.46 2011/08/14 17:50:16 christos Exp $
 #
 
 .include <bsd.own.mk>
@@ -52,8 +52,3 @@
 .endif
 
 .include <bsd.prog.mk>
-
-# XXX
-.if ${HAVE_GCC} == 45
-COPTS.i386.c+=	-Wno-error
-.endif

Index: src/usr.sbin/installboot/arch/alpha.c
diff -u src/usr.sbin/installboot/arch/alpha.c:1.20 src/usr.sbin/installboot/arch/alpha.c:1.21
--- src/usr.sbin/installboot/arch/alpha.c:1.20	Mon Oct 26 10:26:25 2009
+++ src/usr.sbin/installboot/arch/alpha.c	Sun Aug 14 13:50:17 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: alpha.c,v 1.20 2009/10/26 14:26:25 tsutsui Exp $	*/
+/*	$NetBSD: alpha.c,v 1.21 2011/08/14 17:50:17 christos 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.20 2009/10/26 14:26:25 tsutsui Exp $");
+__RCSID("$NetBSD: alpha.c,v 1.21 2011/08/14 17:50:17 christos Exp $");
 #endif	/* !__lint */
 
 #include <sys/param.h>
@@ -440,8 +440,7 @@
 check_sparc(const struct alpha_boot_block * const bb, const char *when)
 {
 	uint16_t bb16[256];
-	const char * const wmsg =
-	    "%s sparc %s 0x%04x invalid, expected 0x%04x";
+#define wmsg "%s sparc %s 0x%04x invalid, expected 0x%04x"
 
 	memcpy(bb16, bb, sizeof(bb16));
 	if (compute_sunsum(bb16) != bb16[255])

Index: src/usr.sbin/installboot/arch/i386.c
diff -u src/usr.sbin/installboot/arch/i386.c:1.36 src/usr.sbin/installboot/arch/i386.c:1.37
--- src/usr.sbin/installboot/arch/i386.c:1.36	Sun Jan 17 09:54:44 2010
+++ src/usr.sbin/installboot/arch/i386.c	Sun Aug 14 13:50:17 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: i386.c,v 1.36 2010/01/17 14:54:44 drochner Exp $ */
+/* $NetBSD: i386.c,v 1.37 2011/08/14 17:50:17 christos 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.36 2010/01/17 14:54:44 drochner Exp $");
+__RCSID("$NetBSD: i386.c,v 1.37 2011/08/14 17:50:17 christos Exp $");
 #endif /* !__lint */
 
 #include <sys/param.h>
@@ -56,8 +56,6 @@
 
 #include "installboot.h"
 
-#define nelem(x) (sizeof (x)/sizeof *(x))
-
 static const struct console_name {
 	const char	*name;		/* Name of console selection */
 	const int	dev;		/* value matching CONSDEV_* from sys/arch/i386/stand/lib/libi386.h */
@@ -124,10 +122,9 @@
 }
 
 static int
-write_boot_area(ib_params *params, void *v_buf, int len)
+write_boot_area(ib_params *params, uint8_t *buf, size_t len)
 {
 	int rv, i;
-	uint8_t *buf = v_buf;
 
 	/*
 	 * Writing the 'label' sector (likely to be bytes 512-1023) could
@@ -149,7 +146,7 @@
 			return 1;
 		len -= 512 * 2;
 		rv = pwrite_validate(params->fsfd, buf + 512 * 2, len, 512 * 2);
-		if (rv != len)
+		if (rv != (ssize_t)len)
 			goto bad_write;
 		return 1;
 	}
@@ -159,7 +156,7 @@
 	if (errno == EINVAL) {
 		/* Assume the failure was due to to the sector size > 512 */
 		rv = pwrite_validate(params->fsfd, buf, len, 0);
-		if (rv == len)
+		if (rv == (ssize_t)len)
 			return 1;
 		if (rv != -1 || (errno != EROFS))
 			goto bad_write;
@@ -179,7 +176,7 @@
 	/* Reset write-protext */
 	i = 0;
 	ioctl(params->fsfd, DIOCWLABEL, &i);
-	if (rv == len)
+	if (rv == (ssize_t)len)
 		return 1;
 #endif
 
@@ -202,11 +199,11 @@
 	printf("flags %x, ", le32toh(bpp->bp_flags));
 	printf("speed %d, ", le32toh(bpp->bp_conspeed));
 	printf("ioaddr %x, ", le32toh(bpp->bp_consaddr));
-	for (i = 0; i < nelem(consoles); i++) {
+	for (i = 0; i < __arraycount(consoles); i++) {
 		if (consoles[i].dev == (int)le32toh(bpp->bp_consdev))
 			break;
 	}
-	if (i == nelem(consoles))
+	if (i == __arraycount(consoles))
 		printf("console %d\n", le32toh(bpp->bp_consdev));
 	else
 		printf("console %s\n", consoles[i].name);
@@ -245,11 +242,11 @@
 	if (params->flags & IB_CONSADDR)
 		bp.bp_consaddr = htole32(params->consaddr);
 	if (params->flags & IB_CONSOLE) {
-		for (i = 0; i < nelem(consoles); i++)
+		for (i = 0; i < __arraycount(consoles); i++)
 			if (strcmp(consoles[i].name, params->console) == 0)
 				break;
 
-		if (i == nelem(consoles)) {
+		if (i == __arraycount(consoles)) {
 			warnx("invalid console name, valid names are:");
 			(void)fprintf(stderr, "\t%s", consoles[0].name);
 			for (i = 1; consoles[i].name != NULL; i++)
@@ -471,7 +468,7 @@
 			(8192 - params->s1stat.st_size) & 511);
 	}
 
-	return write_boot_area(params, &disk_buf, sizeof disk_buf);
+	return write_boot_area(params, disk_buf.b, sizeof disk_buf.b);
 }
 
 static int
@@ -543,8 +540,8 @@
 		warn("Writing `%s'", params->filesystem);
 		goto done;
 	} else if (rv != sizeof buf) {
-		warnx("Writing `%s': short write, %ld bytes (should be %ld)",
-		    params->filesystem, (long)rv, (long)sizeof(buf));
+		warnx("Writing `%s': short write, %zd bytes (should be %zu)",
+		    params->filesystem, rv, sizeof(buf));
 		goto done;
 	}
 

Reply via email to