Skip to content

Commit bf72b65

Browse files
committed
Warns fixes:
use varargs properly use unsigned chars where appropriate fix typos eliminate gcc warnings
1 parent e95c79e commit bf72b65

25 files changed

+979
-605
lines changed

games/sail/Makefile

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1-
# $NetBSD: Makefile,v 1.6 1997/10/12 14:21:50 lukem Exp $
1+
# $NetBSD: Makefile,v 1.7 1997/10/13 19:42:53 christos Exp $
22
# @(#)Makefile 8.1 (Berkeley) 5/31/93
33

4-
WARNS=0
54
PROG= sail
65
SRCS= main.c pl_main.c pl_1.c pl_2.c pl_3.c pl_4.c pl_5.c pl_6.c pl_7.c \
76
dr_main.c dr_1.c dr_2.c dr_3.c dr_4.c dr_5.c lo_main.c \

games/sail/assorted.c

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* $NetBSD: assorted.c,v 1.4 1997/01/07 12:42:14 tls Exp $ */
1+
/* $NetBSD: assorted.c,v 1.5 1997/10/13 19:43:05 christos Exp $ */
22

33
/*
44
* Copyright (c) 1983, 1993
@@ -33,25 +33,32 @@
3333
* SUCH DAMAGE.
3434
*/
3535

36+
#include <sys/cdefs.h>
3637
#ifndef lint
3738
#if 0
3839
static char sccsid[] = "@(#)assorted.c 8.2 (Berkeley) 4/28/95";
3940
#else
40-
static char rcsid[] = "$NetBSD: assorted.c,v 1.4 1997/01/07 12:42:14 tls Exp $";
41+
__RCSID("$NetBSD: assorted.c,v 1.5 1997/10/13 19:43:05 christos Exp $");
4142
#endif
4243
#endif /* not lint */
4344

4445
#include "extern.h"
46+
#include <stdlib.h>
47+
#include <unistd.h>
48+
#include <err.h>
4549

50+
static void strike __P((struct ship *, struct ship *));
51+
52+
void
4653
table(rig, shot, hittable, on, from, roll)
4754
struct ship *on, *from;
4855
int rig, shot, hittable, roll;
4956
{
50-
register int hhits = 0, chits = 0, ghits = 0, rhits = 0;
57+
int hhits = 0, chits = 0, ghits = 0, rhits = 0;
5158
int Ghit = 0, Hhit = 0, Rhit = 0, Chit = 0;
5259
int guns, car, pc, hull;
5360
int crew[3];
54-
register int n;
61+
int n;
5562
int rigg[4];
5663
char *message;
5764
struct Tables *tp;
@@ -158,6 +165,10 @@ int rig, shot, hittable, roll;
158165
break;
159166
case L_EXPLODE:
160167
message = "exploding shot on %s (%c%c)";
168+
break;
169+
default:
170+
errx(1, "Unknown shot type %d", shot);
171+
161172
}
162173
makesignal(from, message, on);
163174
if (roll == 6 && rig) {
@@ -183,6 +194,8 @@ int rig, shot, hittable, roll;
183194
case 7:
184195
message = "main topmast and mizzen mast shattered";
185196
break;
197+
default:
198+
errx(1, "Bad Rhit = %d", Rhit);
186199
}
187200
makesignal(on, message, (struct ship *)0);
188201
} else if (roll == 6) {
@@ -209,6 +222,8 @@ int rig, shot, hittable, roll;
209222
case 6:
210223
message = "shot holes below the water line";
211224
break;
225+
default:
226+
errx(1, "Bad Hhit = %d", Hhit);
212227
}
213228
makesignal(on, message, (struct ship *)0);
214229
}
@@ -228,8 +243,9 @@ int rig, shot, hittable, roll;
228243
strike(on, from);
229244
}
230245

246+
void
231247
Cleansnag(from, to, all, flag)
232-
register struct ship *from, *to;
248+
struct ship *from, *to;
233249
char all, flag;
234250
{
235251
if (flag & 1) {
@@ -254,8 +270,9 @@ char all, flag;
254270
}
255271
}
256272

273+
static void
257274
strike(ship, from)
258-
register struct ship *ship, *from;
275+
struct ship *ship, *from;
259276
{
260277
int points;
261278

games/sail/dr_1.c

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* $NetBSD: dr_1.c,v 1.4 1995/04/24 12:25:10 cgd Exp $ */
1+
/* $NetBSD: dr_1.c,v 1.5 1997/10/13 19:43:14 christos Exp $ */
22

33
/*
44
* Copyright (c) 1983, 1993
@@ -33,22 +33,25 @@
3333
* SUCH DAMAGE.
3434
*/
3535

36+
#include <sys/cdefs.h>
3637
#ifndef lint
3738
#if 0
3839
static char sccsid[] = "@(#)dr_1.c 8.1 (Berkeley) 5/31/93";
3940
#else
40-
static char rcsid[] = "$NetBSD: dr_1.c,v 1.4 1995/04/24 12:25:10 cgd Exp $";
41+
__RCSID("$NetBSD: dr_1.c,v 1.5 1997/10/13 19:43:14 christos Exp $");
4142
#endif
4243
#endif /* not lint */
4344

4445
#include "driver.h"
46+
#include <stdlib.h>
4547

48+
void
4649
unfoul()
4750
{
48-
register struct ship *sp;
51+
struct ship *sp;
4952
struct ship *to;
50-
register int nat;
51-
register i;
53+
int nat;
54+
int i;
5255

5356
foreachship(sp) {
5457
if (sp->file->captain[0])
@@ -65,10 +68,11 @@ unfoul()
6568
}
6669
}
6770

71+
void
6872
boardcomp()
6973
{
7074
int crew[3];
71-
register struct ship *sp, *sq;
75+
struct ship *sp, *sq;
7276

7377
foreachship(sp) {
7478
if (*sp->file->captain)
@@ -129,6 +133,7 @@ boardcomp()
129133
}
130134
}
131135

136+
int
132137
fightitout(from, to, key)
133138
struct ship *from, *to;
134139
int key;
@@ -162,7 +167,7 @@ int key;
162167
fromstrength = menfrom * fromcap->specs->qual;
163168
strengthto = mento * tocap->specs->qual;
164169
for (count = 0;
165-
(fromstrength < strengthto * 3 && strengthto < fromstrength * 3
170+
((fromstrength < strengthto * 3 && strengthto < fromstrength * 3)
166171
|| fromstrength == -1) && count < 4;
167172
count++) {
168173
index = fromstrength/10;
@@ -230,10 +235,11 @@ int key;
230235
return 0;
231236
}
232237

238+
void
233239
resolve()
234240
{
235241
int thwart;
236-
register struct ship *sp, *sq;
242+
struct ship *sp, *sq;
237243

238244
foreachship(sp) {
239245
if (sp->file->dir == 0)
@@ -260,10 +266,11 @@ resolve()
260266
}
261267
}
262268

269+
void
263270
compcombat()
264271
{
265-
register n;
266-
register struct ship *sp;
272+
int n;
273+
struct ship *sp;
267274
struct ship *closest;
268275
int crew[3], men = 0, target, temp;
269276
int r, guns, ready, load, car;
@@ -389,6 +396,7 @@ compcombat()
389396
}
390397
}
391398

399+
int
392400
next()
393401
{
394402
if (++turn % 55 == 0)
@@ -397,8 +405,8 @@ next()
397405
else
398406
people = 0;
399407
if (people <= 0 || windspeed == 7) {
400-
register struct ship *s;
401-
struct ship *bestship;
408+
struct ship *s;
409+
struct ship *bestship = NULL;
402410
float net, best = 0.0;
403411
foreachship(s) {
404412
if (*s->file->captain)
@@ -419,7 +427,7 @@ next()
419427
sizeof bestship->file->captain);
420428
bestship->file->captain
421429
[sizeof bestship->file->captain - 1] = 0;
422-
log(bestship);
430+
logger(bestship);
423431
}
424432
return -1;
425433
}

games/sail/dr_2.c

Lines changed: 32 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* $NetBSD: dr_2.c,v 1.4 1995/04/24 12:25:12 cgd Exp $ */
1+
/* $NetBSD: dr_2.c,v 1.5 1997/10/13 19:43:23 christos Exp $ */
22

33
/*
44
* Copyright (c) 1983, 1993
@@ -33,21 +33,24 @@
3333
* SUCH DAMAGE.
3434
*/
3535

36+
#include <sys/cdefs.h>
3637
#ifndef lint
3738
#if 0
3839
static char sccsid[] = "@(#)dr_2.c 8.1 (Berkeley) 5/31/93";
3940
#else
40-
static char rcsid[] = "$NetBSD: dr_2.c,v 1.4 1995/04/24 12:25:12 cgd Exp $";
41+
__RCSID("$NetBSD: dr_2.c,v 1.5 1997/10/13 19:43:23 christos Exp $");
4142
#endif
4243
#endif /* not lint */
4344

4445
#include "driver.h"
46+
#include <stdlib.h>
4547

4648
#define couldwin(f,t) (f->specs->crew2 > t->specs->crew2 * 1.5)
4749

50+
void
4851
thinkofgrapples()
4952
{
50-
register struct ship *sp, *sq;
53+
struct ship *sp, *sq;
5154
char friendly;
5255

5356
foreachship(sp) {
@@ -75,10 +78,11 @@ thinkofgrapples()
7578
}
7679
}
7780

81+
void
7882
checkup()
7983
{
80-
register struct ship *sp, *sq;
81-
register char explode, sink;
84+
struct ship *sp, *sq;
85+
char explode, sink;
8286

8387
foreachship(sp) {
8488
if (sp->file->dir == 0)
@@ -105,9 +109,10 @@ checkup()
105109
}
106110
}
107111

112+
void
108113
prizecheck()
109114
{
110-
register struct ship *sp;
115+
struct ship *sp;
111116

112117
foreachship(sp) {
113118
if (sp->file->captured == 0)
@@ -123,18 +128,20 @@ prizecheck()
123128
}
124129
}
125130

131+
int
126132
strend(str)
127133
char *str;
128134
{
129-
register char *p;
135+
char *p;
130136

131137
for (p = str; *p; p++)
132138
;
133139
return p == str ? 0 : p[-1];
134140
}
135141

142+
void
136143
closeon(from, to, command, ta, ma, af)
137-
register struct ship *from, *to;
144+
struct ship *from, *to;
138145
char command[];
139146
int ma, ta, af;
140147
{
@@ -148,14 +155,15 @@ int ma, ta, af;
148155

149156
int dtab[] = {0,1,1,2,3,4,4,5}; /* diagonal distances in x==y */
150157

158+
int
151159
score(movement, ship, to, onlytemp)
152160
char movement[];
153-
register struct ship *ship, *to;
161+
struct ship *ship, *to;
154162
char onlytemp;
155163
{
156164
char drift;
157165
int row, col, dir, total, ran;
158-
register struct File *fp = ship->file;
166+
struct File *fp = ship->file;
159167

160168
if ((dir = fp->dir) == 0)
161169
return 0;
@@ -181,12 +189,13 @@ char onlytemp;
181189
return total;
182190
}
183191

192+
void
184193
move(p, ship, dir, row, col, drift)
185-
register char *p;
186-
register struct ship *ship;
187-
register char *dir;
188-
register short *row, *col;
189-
register char *drift;
194+
char *p;
195+
struct ship *ship;
196+
unsigned char *dir;
197+
short *row, *col;
198+
char *drift;
190199
{
191200
int dist;
192201
char moved = 0;
@@ -215,7 +224,7 @@ register char *drift;
215224
}
216225
if (!moved) {
217226
if (windspeed != 0 && ++*drift > 2) {
218-
if (ship->specs->class >= 3 && !snagged(ship)
227+
if ((ship->specs->class >= 3 && !snagged(ship))
219228
|| (turn & 1) == 0) {
220229
*row -= dr[winddir];
221230
*col -= dc[winddir];
@@ -225,12 +234,13 @@ register char *drift;
225234
*drift = 0;
226235
}
227236

237+
void
228238
try(command, temp, ma, ta, af, vma, dir, f, t, high, rakeme)
229-
register struct ship *f, *t;
239+
struct ship *f, *t;
230240
int ma, ta, af, *high, rakeme;
231241
char command[], temp[];
232242
{
233-
register int new, n;
243+
int new, n;
234244
char st[4];
235245
#define rakeyou (gunsbear(f, t) && !gunsbear(t, f))
236246

@@ -247,10 +257,10 @@ char command[], temp[];
247257
dir, f, t, high, rakeme);
248258
rmend(temp);
249259
}
250-
if (ma > 0 && ta > 0 && (n = strend(temp)) != 'l' && n != 'r' || !strlen(temp)) {
260+
if ((ma > 0 && ta > 0 && (n = strend(temp)) != 'l' && n != 'r') || !strlen(temp)) {
251261
(void) strcat(temp, "r");
252262
new = score(temp, f, t, rakeme);
253-
if (new > *high && (!rakeme || gunsbear(f, t) && !gunsbear(t, f))) {
263+
if (new > *high && (!rakeme || (gunsbear(f, t) && !gunsbear(t, f)))) {
254264
*high = new;
255265
(void) strcpy(command, temp);
256266
}
@@ -269,10 +279,11 @@ char command[], temp[];
269279
}
270280
}
271281

282+
void
272283
rmend(str)
273284
char *str;
274285
{
275-
register char *p;
286+
char *p;
276287

277288
for (p = str; *p; p++)
278289
;

0 commit comments

Comments
 (0)