From 2e8d32e0eca6351cfedf7592db0cab349cfbd9cc Mon Sep 17 00:00:00 2001 From: Peter Avalos Date: Tue, 8 Aug 2006 15:03:02 +0000 Subject: [PATCH] -WARNS6 cleanups (452 warnings) -staticize functions -ANSI function declarations -Add $DragonFly$ keyword where needed -Thanks to swildner for some of the yacc and lex cleanups. --- games/atc/Makefile | 3 +- games/atc/extern.c | 4 +- games/atc/extern.h | 40 ++++++++++- games/atc/grammar.y | 48 ++++++++----- games/atc/graphics.c | 64 +++++++++-------- games/atc/include.h | 4 +- games/atc/input.c | 167 +++++++++++++++++++++++++------------------ games/atc/lex.l | 7 +- games/atc/list.c | 16 ++--- games/atc/log.c | 28 ++++---- games/atc/main.c | 52 +++++++------- games/atc/update.c | 51 ++++++------- 12 files changed, 291 insertions(+), 193 deletions(-) diff --git a/games/atc/Makefile b/games/atc/Makefile index 120c767be4..5baceafcb0 100644 --- a/games/atc/Makefile +++ b/games/atc/Makefile @@ -1,6 +1,6 @@ # @(#)Makefile 8.1 (Berkeley) 5/31/93 # $FreeBSD: src/games/atc/Makefile,v 1.14.2.3 2002/02/18 16:02:41 ru Exp $ -# $DragonFly: src/games/atc/Makefile,v 1.2 2003/06/17 04:25:22 dillon Exp $ +# $DragonFly: src/games/atc/Makefile,v 1.3 2006/08/08 15:03:02 pavalos Exp $ PROG= atc CFLAGS+=-DBSD -I${.CURDIR} -I. @@ -12,6 +12,7 @@ LDADD= -ll -lm -lcurses -ltermcap FILES= Game_List Killer crossover default easy game_2 FILESDIR= ${SHAREDIR}/games/atc HIDEGAME=hidegame +WARNS?= 6 .PATH: ${.CURDIR}/games diff --git a/games/atc/extern.c b/games/atc/extern.c index fc74b8fbca..1cb5ee5329 100644 --- a/games/atc/extern.c +++ b/games/atc/extern.c @@ -35,7 +35,7 @@ * * @(#)extern.c 8.1 (Berkeley) 5/31/93 * $FreeBSD: src/games/atc/extern.c,v 1.3 1999/11/30 03:48:19 billf Exp $ - * $DragonFly: src/games/atc/extern.c,v 1.2 2003/06/17 04:25:22 dillon Exp $ + * $DragonFly: src/games/atc/extern.c,v 1.3 2006/08/08 15:03:02 pavalos Exp $ */ /* @@ -53,7 +53,7 @@ char GAMES[] = "Game_List"; int clck, safe_planes, start_time, test_mode; -const char *file; +const char *filename; FILE *filein, *fileout; diff --git a/games/atc/extern.h b/games/atc/extern.h index 4072873f81..f1efc05d8a 100644 --- a/games/atc/extern.h +++ b/games/atc/extern.h @@ -34,6 +34,7 @@ * SUCH DAMAGE. * * @(#)extern.h 8.1 (Berkeley) 5/31/93 + * $DragonFly: src/games/atc/extern.h,v 1.2 2006/08/08 15:03:02 pavalos Exp $ */ /* @@ -46,7 +47,7 @@ */ extern char GAMES[]; -extern const char *file; +extern const char *filename; extern int clck, safe_planes, start_time, test_mode; @@ -60,4 +61,39 @@ extern struct sgttyb tty_start, tty_new; extern DISPLACEMENT displacement[MAXDIR]; -extern PLANE *findplane(), *newplane(); +extern int yyparse(void); + +/* graphics.c */ +extern void done_screen(void); +extern void draw_all(void); +extern void erase_all(void); +extern int getAChar(void); +extern void init_gr(void); +extern void ioaddstr(int, const char *); +extern void ioclrtobot(void); +extern void ioclrtoeol(int); +extern void ioerror(int, int, const char *); +extern void iomove(int); +extern void loser(const PLANE *, const char *); +extern void planewin(void); +extern void redraw(void); +extern void setup_screen(const C_SCREEN *); +extern void quit(void); +/* input.c */ +extern int dir_no(char); +extern int getcommand(void); +/* list.c */ +extern void append(LIST *, PLANE *); +extern void delete(LIST *, PLANE *); +extern PLANE *newplane(void); +/* log.c */ +extern int log_score(int); +extern void open_score_file(void); +/* update.c */ +extern int addplane(void); +extern const char *command(const PLANE *); +extern PLANE *findplane(int); +extern char name(const PLANE *); +extern char number(char); +extern void update(void); + diff --git a/games/atc/grammar.y b/games/atc/grammar.y index 76439e32ba..bae0478825 100644 --- a/games/atc/grammar.y +++ b/games/atc/grammar.y @@ -34,6 +34,7 @@ * SUCH DAMAGE. * * @(#)grammar.y 8.1 (Berkeley) 5/31/93 + * $DragonFly: src/games/atc/grammar.y,v 1.3 2006/08/08 15:03:02 pavalos Exp $ */ /* @@ -63,6 +64,16 @@ %{ #include "include.h" +extern int yylex(void); + +static void check_edge(int, int); +static void check_point(int, int); +static void check_linepoint(int, int); +static void check_line(int, int, int, int); +static int yyerror(const char *); +static void check_edir(int, int, int); +static int checkdefs(void); + int errors = 0; int line = 1; %} @@ -244,7 +255,6 @@ Apoint: sp->airport[sp->num_airports].y = $3; sp->airport[sp->num_airports].dir = dir; check_point($2, $3); - check_adir($2, $3, dir); sp->num_airports++; } ; @@ -280,14 +290,16 @@ Lline: ; %% -check_edge(x, y) +static void +check_edge(int x, int y) { if (!(x == 0) && !(x == sp->width - 1) && !(y == 0) && !(y == sp->height - 1)) yyerror("edge value not on edge."); } -check_point(x, y) +static void +check_point(int x, int y) { if (x < 1 || x >= sp->width - 1) yyerror("X value out of range."); @@ -295,7 +307,8 @@ check_point(x, y) yyerror("Y value out of range."); } -check_linepoint(x, y) +static void +check_linepoint(int x, int y) { if (x < 0 || x >= sp->width) yyerror("X value out of range."); @@ -303,30 +316,32 @@ check_linepoint(x, y) yyerror("Y value out of range."); } -check_line(x1, y1, x2, y2) +static void +check_line(int x_1, int y_1, int x_2, int y_2) { int d1, d2; - check_linepoint(x1, y1); - check_linepoint(x2, y2); + check_linepoint(x_1, y_1); + check_linepoint(x_2, y_2); - d1 = ABS(x2 - x1); - d2 = ABS(y2 - y1); + d1 = ABS(x_2 - x_1); + d2 = ABS(y_2 - y_1); if (!(d1 == d2) && !(d1 == 0) && !(d2 == 0)) yyerror("Bad line endpoints."); } -yyerror(s) - char *s; +static int +yyerror(const char *s) { - fprintf(stderr, "\"%s\": line %d: %s\n", file, line, s); + fprintf(stderr, "\"%s\": line %d: %s\n", filename, line, s); errors++; return (errors); } -check_edir(x, y, dir) +static void +check_edir(int x, int y, int dir) { int bad = 0; @@ -357,11 +372,8 @@ check_edir(x, y, dir) yyerror("Bad direction for entrance at exit."); } -check_adir(x, y, dir) -{ -} - -checkdefs() +static int +checkdefs(void) { int err = 0; diff --git a/games/atc/graphics.c b/games/atc/graphics.c index cb3d79d4c5..59199a9ec3 100644 --- a/games/atc/graphics.c +++ b/games/atc/graphics.c @@ -35,7 +35,7 @@ * * @(#)graphics.c 8.1 (Berkeley) 5/31/93 * $FreeBSD: src/games/atc/graphics.c,v 1.7 1999/11/30 03:48:19 billf Exp $ - * $DragonFly: src/games/atc/graphics.c,v 1.2 2003/06/17 04:25:22 dillon Exp $ + * $DragonFly: src/games/atc/graphics.c,v 1.3 2006/08/08 15:03:02 pavalos Exp $ */ /* @@ -47,7 +47,6 @@ * For more info on this and all of my stuff, mail edjames@berkeley.edu. */ -#include #include "include.h" #ifdef SYSV #include @@ -63,7 +62,11 @@ WINDOW *radar, *cleanradar, *credit, *input, *planes; -getAChar() +static void draw_line(WINDOW *, int, int, int, int, const char *); + + +int +getAChar(void) { #ifdef BSD return (getchar()); @@ -76,7 +79,8 @@ getAChar() #endif } -erase_all() +void +erase_all(void) { PLANE *pp; @@ -90,7 +94,8 @@ erase_all() } } -draw_all() +void +draw_all(void) { PLANE *pp; @@ -109,7 +114,8 @@ draw_all() fflush(stdout); } -init_gr() +void +init_gr(void) { static char buffer[BUFSIZ]; @@ -121,8 +127,8 @@ init_gr() planes = newwin(LINES - INPUT_LINES, PLANE_COLS, 0, COLS - PLANE_COLS); } -setup_screen(scp) - const C_SCREEN *scp; +void +setup_screen(const C_SCREEN *scp) { int i, j; char str[3]; @@ -213,10 +219,8 @@ setup_screen(scp) fflush(stdout); } -draw_line(w, x, y, lx, ly, s) - WINDOW *w; - int x, y, lx, ly; - const char *s; +static void +draw_line(WINDOW *w, int x, int y, int lx, int ly, const char *s) { int dx, dy; @@ -232,7 +236,8 @@ draw_line(w, x, y, lx, ly, s) } } -ioclrtoeol(pos) +void +ioclrtoeol(int pos) { wmove(input, 0, pos); wclrtoeol(input); @@ -240,15 +245,16 @@ ioclrtoeol(pos) fflush(stdout); } -iomove(pos) +void +iomove(int pos) { wmove(input, 0, pos); wrefresh(input); fflush(stdout); } -ioaddstr(pos, str) - const char *str; +void +ioaddstr(int pos, const char *str) { wmove(input, 0, pos); waddstr(input, str); @@ -256,15 +262,16 @@ ioaddstr(pos, str) fflush(stdout); } -ioclrtobot() +void +ioclrtobot(void) { wclrtobot(input); wrefresh(input); fflush(stdout); } -ioerror(pos, len, str) - const char *str; +void +ioerror(int pos, int len, const char *str) { int i; @@ -277,7 +284,8 @@ ioerror(pos, len, str) fflush(stdout); } -quit() +void +quit(void) { int c, y, x; #ifdef BSD @@ -317,10 +325,10 @@ quit() return; } -planewin() +void +planewin(void) { PLANE *pp; - char *command(); int warning = 0; #ifdef BSD @@ -360,9 +368,8 @@ planewin() fflush(stdout); } -loser(p, s) - const PLANE *p; - const char *s; +void +loser(const PLANE *p, const char *s) { int c; #ifdef BSD @@ -394,7 +401,8 @@ loser(p, s) exit(0); } -redraw() +void +redraw(void) { clear(); refresh(); @@ -412,8 +420,8 @@ redraw() fflush(stdout); } - -done_screen() +void +done_screen(void) { clear(); refresh(); diff --git a/games/atc/include.h b/games/atc/include.h index bef7e05567..c5887d25a7 100644 --- a/games/atc/include.h +++ b/games/atc/include.h @@ -34,6 +34,7 @@ * SUCH DAMAGE. * * @(#)include.h 8.1 (Berkeley) 5/31/93 + * $DragonFly: src/games/atc/include.h,v 1.2 2006/08/08 15:03:02 pavalos Exp $ */ /* @@ -56,10 +57,11 @@ #include #endif -#ifdef SYSV #include #include #include +#include +#ifdef SYSV #include #endif diff --git a/games/atc/input.c b/games/atc/input.c index e6d670cd0f..eef1280caa 100644 --- a/games/atc/input.c +++ b/games/atc/input.c @@ -35,7 +35,7 @@ * * @(#)input.c 8.1 (Berkeley) 5/31/93 * $FreeBSD: src/games/atc/input.c,v 1.7 2000/02/27 23:02:47 mph Exp $ - * $DragonFly: src/games/atc/input.c,v 1.2 2003/06/17 04:25:22 dillon Exp $ + * $DragonFly: src/games/atc/input.c,v 1.3 2006/08/08 15:03:02 pavalos Exp $ */ /* @@ -47,8 +47,8 @@ * For more info on this and all of my stuff, mail edjames@berkeley.edu. */ -#include -#include +#include + #include "include.h" #include "pathnames.h" @@ -69,7 +69,7 @@ typedef struct { int token; int to_state; const char *str; - const char *(*func)(); + const char *(*func)(int); } RULE; typedef struct { @@ -95,10 +95,32 @@ typedef struct { #define NUMSTATES NUMELS(st) -const char *setplane(), *circle(), *left(), *right(), *Left(), *Right(), - *beacon(), *ex_it(), *climb(), *descend(), *setalt(), *setrelalt(), - *benum(), *to_dir(), *rel_dir(), *delayb(), *mark(), *unmark(), - *airport(), *turn(), *ignore(); +static int pop(void); +static void rezero(void); +static void push(int, int); +static void noise(void); +static int gettoken(void); +static const char *setplane(int); +static const char *turn(int); +static const char *circle(int); +static const char *left(int); +static const char *right(int); +static const char *Left(int); +static const char *Right(int); +static const char *delayb(int); +static const char *beacon(int); +static const char *ex_it(int); +static const char *airport(int); +static const char *climb(int); +static const char *descend(int); +static const char *setalt(int); +static const char *setrelalt(int); +static const char *benum(int); +static const char *to_dir(int); +static const char *rel_dir(int); +static const char *mark(int); +static const char *unmark(int); +static const char *ignore(int); RULE state0[] = { { ALPHATOKEN, 1, "%c:", setplane}, { RETTOKEN, -1, "", NULL }, @@ -192,7 +214,9 @@ int level; int tval; int dest_type, dest_no, dir; -pop() + +static int +pop(void) { if (level == 0) return (-1); @@ -206,7 +230,8 @@ pop() return (0); } -rezero() +static void +rezero(void) { iomove(0); @@ -218,7 +243,8 @@ rezero() strcpy(T_STR, ""); } -push(ruleno, ch) +static void +push(int ruleno, int ch) { int newstate, newpos; @@ -239,10 +265,11 @@ push(ruleno, ch) strcpy(T_STR, ""); } -getcommand() +int +getcommand(void) { int c, i, done; - const char *s, *(*func)(); + const char *s, *(*func)(int); PLANE *pp; rezero(); @@ -297,13 +324,15 @@ getcommand() return (0); } -noise() +static void +noise(void) { putchar('\07'); fflush(stdout); } -gettoken() +static int +gettoken(void) { while ((tval = getAChar()) == REDRAWTOKEN || tval == SHELLTOKEN) { @@ -368,8 +397,8 @@ gettoken() return (tval); } -const char * -setplane(c) +static const char * +setplane(int c) { PLANE *pp; @@ -381,16 +410,16 @@ setplane(c) return (NULL); } -const char * -turn(c) +static const char * +turn(__unused int c) { if (p.altitude == 0) return ("Planes at airports may not change direction"); return (NULL); } -const char * -circle(c) +static const char * +circle(__unused int c) { if (p.altitude == 0) return ("Planes cannot circle on the ground"); @@ -398,8 +427,8 @@ circle(c) return (NULL); } -const char * -left(c) +static const char * +left(__unused int c) { dir = D_LEFT; p.new_dir = p.dir - 1; @@ -408,8 +437,8 @@ left(c) return (NULL); } -const char * -right(c) +static const char * +right(__unused int c) { dir = D_RIGHT; p.new_dir = p.dir + 1; @@ -418,8 +447,8 @@ right(c) return (NULL); } -const char * -Left(c) +static const char * +Left(__unused int c) { p.new_dir = p.dir - 2; if (p.new_dir < 0) @@ -427,8 +456,8 @@ Left(c) return (NULL); } -const char * -Right(c) +static const char * +Right(__unused int c) { p.new_dir = p.dir + 2; if (p.new_dir >= MAXDIR) @@ -436,8 +465,8 @@ Right(c) return (NULL); } -const char * -delayb(c) +static const char * +delayb(int c) { int xdiff, ydiff; @@ -481,43 +510,43 @@ delayb(c) return (NULL); } -const char * -beacon(c) +static const char * +beacon(__unused int c) { dest_type = T_BEACON; return (NULL); } -const char * -ex_it(c) +static const char * +ex_it(__unused int c) { dest_type = T_EXIT; return (NULL); } -const char * -airport(c) +static const char * +airport(__unused int c) { dest_type = T_AIRPORT; return (NULL); } -const char * -climb(c) +static const char * +climb(__unused int c) { dir = D_UP; return (NULL); } -const char * -descend(c) +static const char * +descend(__unused int c) { dir = D_DOWN; return (NULL); } -const char * -setalt(c) +static const char * +setalt(int c) { if ((p.altitude == c - '0') && (p.new_altitude == p.altitude)) return ("Already at that altitude"); @@ -525,8 +554,8 @@ setalt(c) return (NULL); } -const char * -setrelalt(c) +static const char * +setrelalt(int c) { if (c == 0) return ("altitude not changed"); @@ -549,8 +578,8 @@ setrelalt(c) return (NULL); } -const char * -benum(c) +static const char * +benum(int c) { dest_no = c -= '0'; @@ -580,15 +609,15 @@ benum(c) return (NULL); } -const char * -to_dir(c) +static const char * +to_dir(int c) { p.new_dir = dir_no(c); return (NULL); } -const char * -rel_dir(c) +static const char * +rel_dir(int c) { int angle; @@ -611,8 +640,8 @@ rel_dir(c) return (NULL); } -const char * -mark(c) +static const char * +mark(__unused int c) { if (p.altitude == 0) return ("Cannot mark planes on the ground"); @@ -622,8 +651,8 @@ mark(c) return (NULL); } -const char * -unmark(c) +static const char * +unmark(__unused int c) { if (p.altitude == 0) return ("Cannot unmark planes on the ground"); @@ -633,8 +662,8 @@ unmark(c) return (NULL); } -const char * -ignore(c) +static const char * +ignore(__unused int c) { if (p.altitude == 0) return ("Cannot ignore planes on the ground"); @@ -644,23 +673,23 @@ ignore(c) return (NULL); } -dir_no(ch) - char ch; +int +dir_no(char ch) { - int dir; + int dirno = dir; switch (ch) { - case 'w': dir = 0; break; - case 'e': dir = 1; break; - case 'd': dir = 2; break; - case 'c': dir = 3; break; - case 'x': dir = 4; break; - case 'z': dir = 5; break; - case 'a': dir = 6; break; - case 'q': dir = 7; break; + case 'w': dirno = 0; break; + case 'e': dirno = 1; break; + case 'd': dirno = 2; break; + case 'c': dirno = 3; break; + case 'x': dirno = 4; break; + case 'z': dirno = 5; break; + case 'a': dirno = 6; break; + case 'q': dirno = 7; break; default: fprintf(stderr, "bad character in dir_no\n"); break; } - return (dir); + return (dirno); } diff --git a/games/atc/lex.l b/games/atc/lex.l index 874d8fadcd..647480144b 100644 --- a/games/atc/lex.l +++ b/games/atc/lex.l @@ -35,6 +35,7 @@ * SUCH DAMAGE. * * @(#)lex.l 8.1 (Berkeley) 5/31/93 + * $DragonFly: src/games/atc/lex.l,v 1.3 2006/08/08 15:03:02 pavalos Exp $ */ /* @@ -46,8 +47,12 @@ * For more info on this and all of my stuff, mail edjames@berkeley.edu. */ -#include "y.tab.h" +#include +#include "y.tab.h" + +#define YY_NO_UNPUT extern int line; +extern int yylex(void); %} %% diff --git a/games/atc/list.c b/games/atc/list.c index 38668d9335..a024ad94db 100644 --- a/games/atc/list.c +++ b/games/atc/list.c @@ -35,7 +35,7 @@ * * @(#)list.c 8.1 (Berkeley) 5/31/93 * $FreeBSD: src/games/atc/list.c,v 1.4 1999/11/30 03:48:20 billf Exp $ - * $DragonFly: src/games/atc/list.c,v 1.2 2003/06/17 04:25:22 dillon Exp $ + * $DragonFly: src/games/atc/list.c,v 1.3 2006/08/08 15:03:02 pavalos Exp $ */ /* @@ -47,18 +47,17 @@ * For more info on this and all of my stuff, mail edjames@berkeley.edu. */ -#include #include "include.h" + PLANE * -newplane() +newplane(void) { return ((PLANE *) calloc(1, sizeof (PLANE))); } -append(l, p) - LIST *l; - PLANE *p; +void +append(LIST *l, PLANE *p) { PLANE *q = NULL, *r = NULL; @@ -94,9 +93,8 @@ append(l, p) } } -delete(l, p) - LIST *l; - PLANE *p; +void +delete(LIST *l, PLANE *p) { if (l->head == NULL) loser(p, "deleted a non-existant plane! Get help!"); diff --git a/games/atc/log.c b/games/atc/log.c index 83ac7ca9f4..a6f971955d 100644 --- a/games/atc/log.c +++ b/games/atc/log.c @@ -35,7 +35,7 @@ * * @(#)log.c 8.1 (Berkeley) 5/31/93 * $FreeBSD: src/games/atc/log.c,v 1.7 1999/11/30 03:48:20 billf Exp $ - * $DragonFly: src/games/atc/log.c,v 1.2 2003/06/17 04:25:22 dillon Exp $ + * $DragonFly: src/games/atc/log.c,v 1.3 2006/08/08 15:03:02 pavalos Exp $ */ /* @@ -47,7 +47,9 @@ * For more info on this and all of my stuff, mail edjames@berkeley.edu. */ -#include +#include +#include + #include "include.h" #include "pathnames.h" @@ -57,9 +59,12 @@ static FILE *score_fp; -int -compar(va, vb) - const void *va, *vb; +static int compar(const void *, const void *); +static const char *timestr(int); + + +static int +compar(const void *va, const void *vb) { const SCORE *a, *b; @@ -82,8 +87,8 @@ compar(va, vb) #define MIN(t) (((t) % SECAHOUR) / SECAMIN) #define SEC(t) ((t) % SECAMIN) -const char * -timestr(t) +static const char * +timestr(int t) { static char s[80]; @@ -102,7 +107,7 @@ timestr(t) } void -open_score_file() +open_score_file(void) { mode_t old_mask; int score_fd; @@ -135,8 +140,7 @@ open_score_file() } int -log_score(list_em) - int list_em; +log_score(int list_em) { int i, num_scores = 0, good, changed = 0, found = 0; struct passwd *pw; @@ -191,9 +195,9 @@ log_score(list_em) strcpy(thisscore.host, name.nodename); #endif - cp = rindex(file, '/'); + cp = rindex(filename, '/'); if (cp == NULL) { - fprintf(stderr, "log: where's the '/' in %s?\n", file); + fprintf(stderr, "log: where's the '/' in %s?\n", filename); return (-1); } cp++; diff --git a/games/atc/main.c b/games/atc/main.c index d6b6dcbb99..c87d6eb70a 100644 --- a/games/atc/main.c +++ b/games/atc/main.c @@ -36,7 +36,7 @@ * @(#) Copyright (c) 1990, 1993 The Regents of the University of California. All rights reserved. * @(#)main.c 8.1 (Berkeley) 5/31/93 * $FreeBSD: src/games/atc/main.c,v 1.9 1999/11/30 03:48:21 billf Exp $ - * $DragonFly: src/games/atc/main.c,v 1.2 2003/06/17 04:25:22 dillon Exp $ + * $DragonFly: src/games/atc/main.c,v 1.3 2006/08/08 15:03:02 pavalos Exp $ */ /* @@ -48,24 +48,27 @@ * For more info on this and all of my stuff, mail edjames@berkeley.edu. */ -#include #include "include.h" #include "pathnames.h" -main(ac, av) - int ac; - char *av[]; +extern FILE *yyin; +static int read_file(const char *); +static const char *default_game(void); +static const char *okay_game(const char *); +static int list_games(void); + + +int +main(__unused int ac, char **av) { int seed = 0; int f_usage = 0, f_list = 0, f_showscore = 0; int f_printpath = 0; const char *file = NULL; - char *name, *ptr; + char *p_name, *ptr; #ifdef BSD struct itimerval itv; #endif - extern const char *default_game(), *okay_game(); - extern void log_score(), quit(), update(); /* Open the score file then revoke setgid privileges */ open_score_file(); @@ -73,7 +76,7 @@ main(ac, av) start_time = time(0); - name = *av++; + p_name = *av++; while (*av) { #ifndef SAVEDASH if (**av == '-') @@ -122,7 +125,7 @@ main(ac, av) if (f_usage) fprintf(stderr, "Usage: %s -[u?lstp] [-[gf] game_name] [-r random seed]\n", - name); + p_name); if (f_showscore) log_score(1); if (f_list) @@ -151,14 +154,14 @@ main(ac, av) addplane(); - signal(SIGINT, quit); - signal(SIGQUIT, quit); + signal(SIGINT, (sig_t)quit); + signal(SIGQUIT, (sig_t)quit); #ifdef BSD signal(SIGTSTP, SIG_IGN); signal(SIGSTOP, SIG_IGN); #endif - signal(SIGHUP, log_score); - signal(SIGTERM, log_score); + signal(SIGHUP, (sig_t)log_score); + signal(SIGTERM, (sig_t)log_score); #ifdef BSD ioctl(fileno(stdin), TIOCGETP, &tty_start); @@ -178,7 +181,7 @@ main(ac, av) ioctl(fileno(stdin), TCSETAW, &tty_new); #endif - signal(SIGALRM, update); + signal(SIGALRM, (sig_t)update); #ifdef BSD itv.it_value.tv_sec = 0; @@ -220,13 +223,12 @@ main(ac, av) } } -read_file(s) - const char *s; +static int +read_file(const char *s) { - extern FILE *yyin; int retval; - file = s; + filename = s; yyin = fopen(s, "r"); if (yyin == NULL) { perror(s); @@ -241,8 +243,8 @@ read_file(s) return (0); } -const char * -default_game() +static const char * +default_game(void) { FILE *fp; static char file[256]; @@ -266,9 +268,8 @@ default_game() return (file); } -const char * -okay_game(s) - char *s; +static const char * +okay_game(const char *s) { FILE *fp; static char file[256]; @@ -302,7 +303,8 @@ okay_game(s) return (ret); } -list_games() +static int +list_games(void) { FILE *fp; char line[256], games[256]; diff --git a/games/atc/update.c b/games/atc/update.c index 09ba8cfca1..beebae126e 100644 --- a/games/atc/update.c +++ b/games/atc/update.c @@ -35,7 +35,7 @@ * * @(#)update.c 8.1 (Berkeley) 5/31/93 * $FreeBSD: src/games/atc/update.c,v 1.6 1999/11/30 03:48:21 billf Exp $ - * $DragonFly: src/games/atc/update.c,v 1.2 2003/06/17 04:25:22 dillon Exp $ + * $DragonFly: src/games/atc/update.c,v 1.3 2006/08/08 15:03:02 pavalos Exp $ */ /* @@ -47,15 +47,18 @@ * For more info on this and all of my stuff, mail edjames@berkeley.edu. */ -#include #include "include.h" -char name(); +static int next_plane(void); +static int too_close(const PLANE *, const PLANE *, int); +static int dir_deg(int); -update() + +void +update(void) { int i, dir_diff, mask, unclean; - PLANE *pp, *p1, *p2, *p; + PLANE *pp, *p1, *p2; #ifdef BSD mask = sigblock(sigmask(SIGINT)); @@ -223,11 +226,9 @@ update() } const char * -command(pp) - const PLANE *pp; +command(const PLANE *pp) { static char buf[50], *bp, *comm_start; - char *index(); buf[0] = '\0'; bp = buf; @@ -256,8 +257,7 @@ command(pp) /* char */ char -name(p) - const PLANE *p; +name(const PLANE *p) { if (p->plane_type == 0) return ('A' + p->plane_no); @@ -265,7 +265,8 @@ name(p) return ('a' + p->plane_no); } -number(l) +char +number(char l) { if (l < 'a' && l > 'z' && l < 'A' && l > 'Z') return (-1); @@ -275,7 +276,8 @@ number(l) return (l - 'A'); } -next_plane() +static int +next_plane(void) { static int last_plane = -1; PLANE *pp; @@ -303,10 +305,11 @@ next_plane() return (last_plane); } -addplane() +int +addplane(void) { PLANE p, *pp, *p1; - int i, num_starts, close, rnd, rnd2, pnum; + int i, num_starts, is_close, rnd, rnd2, pnum; bzero(&p, sizeof (p)); @@ -336,13 +339,13 @@ addplane() p.ypos = sp->exit[rnd2].y; p.new_dir = p.dir = sp->exit[rnd2].dir; p.altitude = p.new_altitude = 7; - close = 0; + is_close = 0; for (p1 = air.head; p1 != NULL; p1 = p1->next) if (too_close(p1, &p, 4)) { - close++; + is_close++; break; } - if (close) + if (is_close) continue; } else { p.orig_type = T_AIRPORT; @@ -373,9 +376,8 @@ addplane() return (pp->dest_type); } -PLANE * -findplane(n) - int n; +PLANE * +findplane(int n) { PLANE *pp; @@ -388,10 +390,8 @@ findplane(n) return (NULL); } -int -too_close(p1, p2, dist) - const PLANE *p1, *p2; - int dist; +static int +too_close(const PLANE *p1, const PLANE *p2, int dist) { if (ABS(p1->altitude - p2->altitude) <= dist && ABS(p1->xpos - p2->xpos) <= dist && ABS(p1->ypos - p2->ypos) <= dist) @@ -400,7 +400,8 @@ too_close(p1, p2, dist) return (0); } -dir_deg(d) +static int +dir_deg(int d) { switch (d) { case 0: return (0); -- 2.41.0