Module Name:    src
Committed By:   dholland
Date:           Sat Mar 22 22:24:21 UTC 2014

Modified Files:
        src/games/atc: graphics.c input.c struct.h update.c

Log Message:
Make some things unsigned that should be (why would we need e.g. a
negative number of airports?) and remove some related bogus casts.


To generate a diff of this commit:
cvs rdiff -u -r1.16 -r1.17 src/games/atc/graphics.c
cvs rdiff -u -r1.24 -r1.25 src/games/atc/input.c
cvs rdiff -u -r1.6 -r1.7 src/games/atc/struct.h
cvs rdiff -u -r1.22 -r1.23 src/games/atc/update.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/games/atc/graphics.c
diff -u src/games/atc/graphics.c:1.16 src/games/atc/graphics.c:1.17
--- src/games/atc/graphics.c:1.16	Wed Aug 12 04:48:03 2009
+++ src/games/atc/graphics.c	Sat Mar 22 22:24:21 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: graphics.c,v 1.16 2009/08/12 04:48:03 dholland Exp $	*/
+/*	$NetBSD: graphics.c,v 1.17 2014/03/22 22:24:21 dholland Exp $	*/
 
 /*-
  * Copyright (c) 1990, 1993
@@ -46,7 +46,7 @@
 #if 0
 static char sccsid[] = "@(#)graphics.c	8.1 (Berkeley) 5/31/93";
 #else
-__RCSID("$NetBSD: graphics.c,v 1.16 2009/08/12 04:48:03 dholland Exp $");
+__RCSID("$NetBSD: graphics.c,v 1.17 2014/03/22 22:24:21 dholland Exp $");
 #endif
 #endif /* not lint */
 
@@ -130,6 +130,7 @@ void
 setup_screen(const C_SCREEN *scp)
 {
 	int	i, j;
+	unsigned iu;
 	char	str[3];
 	const char *airstr;
 
@@ -193,22 +194,22 @@ setup_screen(const C_SCREEN *scp)
 	}
 
 	str[0] = C_BEACON;
-	for (i = 0; i < scp->num_beacons; i++) {
-		str[1] = '0' + i;
-		(void)wmove(radar, scp->beacon[i].y, scp->beacon[i].x * 2);
+	for (iu = 0; iu < scp->num_beacons; iu++) {
+		str[1] = '0' + iu;
+		(void)wmove(radar, scp->beacon[iu].y, scp->beacon[iu].x * 2);
 		(void)waddstr(radar, str);
 	}
 
-	for (i = 0; i < scp->num_exits; i++) {
-		(void)wmove(radar, scp->exit[i].y, scp->exit[i].x * 2);
-		(void)waddch(radar, '0' + i);
+	for (iu = 0; iu < scp->num_exits; iu++) {
+		(void)wmove(radar, scp->exit[iu].y, scp->exit[iu].x * 2);
+		(void)waddch(radar, '0' + iu);
 	}
 
 	airstr = "^?>?v?<?";
-	for (i = 0; i < scp->num_airports; i++) {
-		str[0] = airstr[scp->airport[i].dir];
-		str[1] = '0' + i;
-		(void)wmove(radar, scp->airport[i].y, scp->airport[i].x * 2);
+	for (iu = 0; iu < scp->num_airports; iu++) {
+		str[0] = airstr[scp->airport[iu].dir];
+		str[1] = '0' + iu;
+		(void)wmove(radar, scp->airport[iu].y, scp->airport[iu].x * 2);
 		(void)waddstr(radar, str);
 	}
 	

Index: src/games/atc/input.c
diff -u src/games/atc/input.c:1.24 src/games/atc/input.c:1.25
--- src/games/atc/input.c:1.24	Wed Aug 12 04:48:03 2009
+++ src/games/atc/input.c	Sat Mar 22 22:24:21 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: input.c,v 1.24 2009/08/12 04:48:03 dholland Exp $	*/
+/*	$NetBSD: input.c,v 1.25 2014/03/22 22:24:21 dholland Exp $	*/
 
 /*-
  * Copyright (c) 1990, 1993
@@ -46,7 +46,7 @@
 #if 0
 static char sccsid[] = "@(#)input.c	8.1 (Berkeley) 5/31/93";
 #else
-__RCSID("$NetBSD: input.c,v 1.24 2009/08/12 04:48:03 dholland Exp $");
+__RCSID("$NetBSD: input.c,v 1.25 2014/03/22 22:24:21 dholland Exp $");
 #endif
 #endif /* not lint */
 
@@ -459,36 +459,37 @@ Right(int c __unused)
 }
 
 static const char *
-delayb(int c)
+delayb(int ch)
 {
 	int	xdiff, ydiff;
+	unsigned bn;
 
-	c -= '0';
+	bn = ch -= '0';
 
-	if (c >= sp->num_beacons)
+	if (bn >= sp->num_beacons)
 		return ("Unknown beacon");
-	xdiff = sp->beacon[(int)c].x - p.xpos;
+	xdiff = sp->beacon[bn].x - p.xpos;
 	xdiff = SGN(xdiff);
-	ydiff = sp->beacon[(int)c].y - p.ypos;
+	ydiff = sp->beacon[bn].y - p.ypos;
 	ydiff = SGN(ydiff);
 	if (xdiff != displacement[p.dir].dx || ydiff != displacement[p.dir].dy)
 		return ("Beacon is not in flight path");
 	p.delayd = 1;
-	p.delayd_no = c;
+	p.delayd_no = bn;
 
 	if (dest_type != T_NODEST) {
 		switch (dest_type) {
 		case T_BEACON:
-			xdiff = sp->beacon[dest_no].x - sp->beacon[(int)c].x;
-			ydiff = sp->beacon[dest_no].y - sp->beacon[(int)c].y;
+			xdiff = sp->beacon[dest_no].x - sp->beacon[bn].x;
+			ydiff = sp->beacon[dest_no].y - sp->beacon[bn].y;
 			break;
 		case T_EXIT:
-			xdiff = sp->exit[dest_no].x - sp->beacon[(int)c].x;
-			ydiff = sp->exit[dest_no].y - sp->beacon[(int)c].y;
+			xdiff = sp->exit[dest_no].x - sp->beacon[bn].x;
+			ydiff = sp->exit[dest_no].y - sp->beacon[bn].y;
 			break;
 		case T_AIRPORT:
-			xdiff = sp->airport[dest_no].x - sp->beacon[(int)c].x;
-			ydiff = sp->airport[dest_no].y - sp->beacon[(int)c].y;
+			xdiff = sp->airport[dest_no].x - sp->beacon[bn].x;
+			ydiff = sp->airport[dest_no].y - sp->beacon[bn].y;
 			break;
 		default:
 			return ("Bad case in delayb!  Get help!");
@@ -587,28 +588,31 @@ setrelalt(int c)
 }
 
 static const char *
-benum(int c)
+benum(int ch)
 {
-	dest_no = c -= '0';
+	unsigned n;
+
+	n = ch - '0';
+	dest_no = n;
 
 	switch (dest_type) {
 	case T_BEACON:
-		if (c >= sp->num_beacons)
+		if (n >= sp->num_beacons)
 			return ("Unknown beacon");
-		p.new_dir = DIR_FROM_DXDY(sp->beacon[(int)c].x - p.xpos,
-			sp->beacon[(int)c].y - p.ypos);
+		p.new_dir = DIR_FROM_DXDY(sp->beacon[n].x - p.xpos,
+			sp->beacon[n].y - p.ypos);
 		break;
 	case T_EXIT:
-		if (c >= sp->num_exits)
+		if (n >= sp->num_exits)
 			return ("Unknown exit");
-		p.new_dir = DIR_FROM_DXDY(sp->exit[(int)c].x - p.xpos,
-			sp->exit[(int)c].y - p.ypos);
+		p.new_dir = DIR_FROM_DXDY(sp->exit[n].x - p.xpos,
+			sp->exit[n].y - p.ypos);
 		break;
 	case T_AIRPORT:
-		if (c >= sp->num_airports)
+		if (n >= sp->num_airports)
 			return ("Unknown airport");
-		p.new_dir = DIR_FROM_DXDY(sp->airport[(int)c].x - p.xpos,
-			sp->airport[(int)c].y - p.ypos);
+		p.new_dir = DIR_FROM_DXDY(sp->airport[n].x - p.xpos,
+			sp->airport[n].y - p.ypos);
 		break;
 	default:
 		return ("Unknown case in benum!  Get help!");

Index: src/games/atc/struct.h
diff -u src/games/atc/struct.h:1.6 src/games/atc/struct.h:1.7
--- src/games/atc/struct.h:1.6	Wed Jun  7 09:36:39 2006
+++ src/games/atc/struct.h	Sat Mar 22 22:24:21 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: struct.h,v 1.6 2006/06/07 09:36:39 jnemeth Exp $	*/
+/*	$NetBSD: struct.h,v 1.7 2014/03/22 22:24:21 dholland Exp $	*/
 
 /*-
  * Copyright (c) 1990, 1993
@@ -60,10 +60,10 @@ typedef struct {
 	int	width, height;
 	int	update_secs;
 	int	newplane_time;
-	int	num_exits;
+	unsigned num_exits;
 	int	num_lines;
-	int	num_beacons;
-	int	num_airports;
+	unsigned num_beacons;
+	unsigned num_airports;
 	EXIT	*exit;
 	LINE	*line;
 	BEACON	*beacon;

Index: src/games/atc/update.c
diff -u src/games/atc/update.c:1.22 src/games/atc/update.c:1.23
--- src/games/atc/update.c:1.22	Tue Feb 15 08:25:25 2011
+++ src/games/atc/update.c	Sat Mar 22 22:24:21 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: update.c,v 1.22 2011/02/15 08:25:25 is Exp $	*/
+/*	$NetBSD: update.c,v 1.23 2014/03/22 22:24:21 dholland Exp $	*/
 
 /*-
  * Copyright (c) 1990, 1993
@@ -46,7 +46,7 @@
 #if 0
 static char sccsid[] = "@(#)update.c	8.1 (Berkeley) 5/31/93";
 #else
-__RCSID("$NetBSD: update.c,v 1.22 2011/02/15 08:25:25 is Exp $");
+__RCSID("$NetBSD: update.c,v 1.23 2014/03/22 22:24:21 dholland Exp $");
 #endif
 #endif /* not lint */
 
@@ -60,7 +60,8 @@ static int dir_deg(int);
 void
 update(int dummy __unused)
 {
-	int	i, dir_diff, unclean;
+	int dir_diff, unclean;
+	unsigned i;
 	PLANE	*pp, *p1, *p2;
 
 #ifdef SYSV
@@ -311,7 +312,8 @@ int
 addplane(void)
 {
 	PLANE	p, *pp, *p1;
-	int	i, num_starts, isclose, rnd, rnd2, pnum;
+	int	isclose, pnum;
+	unsigned num_starts, rnd, rnd2, i;
 
 	(void)memset(&p, 0, sizeof (p));
 

Reply via email to