From 78f2acb399b7ee114054076af75a876ea880d96f Mon Sep 17 00:00:00 2001 From: jmc Date: Fri, 1 Jul 2005 01:12:39 +0000 Subject: KNF and WARNS=3 fixes --- backgammon/common_source/allow.c | 6 +- backgammon/common_source/back.h | 8 +-- backgammon/common_source/board.c | 8 +-- backgammon/common_source/check.c | 9 ++- backgammon/common_source/fancy.c | 131 +++++++++++++++++++++------------------ backgammon/common_source/odds.c | 12 ++-- backgammon/common_source/one.c | 21 +++---- backgammon/common_source/save.c | 13 ++-- backgammon/common_source/subs.c | 52 +++++++--------- backgammon/common_source/table.c | 13 ++-- 10 files changed, 128 insertions(+), 145 deletions(-) (limited to 'backgammon/common_source') diff --git a/backgammon/common_source/allow.c b/backgammon/common_source/allow.c index f6bae784..04eaa4cd 100644 --- a/backgammon/common_source/allow.c +++ b/backgammon/common_source/allow.c @@ -1,4 +1,4 @@ -/* $NetBSD: allow.c,v 1.5 2003/08/07 09:36:56 agc Exp $ */ +/* $NetBSD: allow.c,v 1.6 2005/07/01 01:12:39 jmc Exp $ */ /* * Copyright (c) 1980, 1993 @@ -34,14 +34,14 @@ #if 0 static char sccsid[] = "@(#)allow.c 8.1 (Berkeley) 5/31/93"; #else -__RCSID("$NetBSD: allow.c,v 1.5 2003/08/07 09:36:56 agc Exp $"); +__RCSID("$NetBSD: allow.c,v 1.6 2005/07/01 01:12:39 jmc Exp $"); #endif #endif /* not lint */ #include "back.h" int -movallow() +movallow(void) { int i, m, iold; int r; diff --git a/backgammon/common_source/back.h b/backgammon/common_source/back.h index 468d0e0b..557cfc6b 100644 --- a/backgammon/common_source/back.h +++ b/backgammon/common_source/back.h @@ -1,4 +1,4 @@ -/* $NetBSD: back.h,v 1.14 2004/01/27 20:30:28 jsm Exp $ */ +/* $NetBSD: back.h,v 1.15 2005/07/01 01:12:39 jmc Exp $ */ /* * Copyright (c) 1980, 1993 @@ -141,7 +141,7 @@ void clend(void); void cline(void); int count(void); void curmove(int, int); -int dotable(char, int); +int dotable(int, int); void errexit(const char *) __attribute__((__noreturn__)); void fancyc(int); void fboard(void); @@ -179,7 +179,7 @@ void wrboard(void); void wrbsub(void); void wrhit(int); void wrint(int); -void writec(char); +void writec(int); void writel(const char *); void wrscore(void); -int yorn(char); +int yorn(int); diff --git a/backgammon/common_source/board.c b/backgammon/common_source/board.c index f7eaa1bf..1c76eddb 100644 --- a/backgammon/common_source/board.c +++ b/backgammon/common_source/board.c @@ -1,4 +1,4 @@ -/* $NetBSD: board.c,v 1.7 2003/08/07 09:36:57 agc Exp $ */ +/* $NetBSD: board.c,v 1.8 2005/07/01 01:12:39 jmc Exp $ */ /* * Copyright (c) 1980, 1993 @@ -34,7 +34,7 @@ #if 0 static char sccsid[] = "@(#)board.c 8.1 (Berkeley) 5/31/93"; #else -__RCSID("$NetBSD: board.c,v 1.7 2003/08/07 09:36:57 agc Exp $"); +__RCSID("$NetBSD: board.c,v 1.8 2005/07/01 01:12:39 jmc Exp $"); #endif #endif /* not lint */ @@ -44,7 +44,7 @@ static int i, j, k; static char ln[60]; void -wrboard() +wrboard(void) { int l; static const char bl[] = @@ -161,7 +161,7 @@ lastline: } void -wrbsub() +wrbsub(void) { int m; char d; diff --git a/backgammon/common_source/check.c b/backgammon/common_source/check.c index 04ce1dba..185583e1 100644 --- a/backgammon/common_source/check.c +++ b/backgammon/common_source/check.c @@ -1,4 +1,4 @@ -/* $NetBSD: check.c,v 1.5 2003/08/07 09:36:57 agc Exp $ */ +/* $NetBSD: check.c,v 1.6 2005/07/01 01:12:39 jmc Exp $ */ /* * Copyright (c) 1980, 1993 @@ -34,14 +34,14 @@ #if 0 static char sccsid[] = "@(#)check.c 8.1 (Berkeley) 5/31/93"; #else -__RCSID("$NetBSD: check.c,v 1.5 2003/08/07 09:36:57 agc Exp $"); +__RCSID("$NetBSD: check.c,v 1.6 2005/07/01 01:12:39 jmc Exp $"); #endif #endif /* not lint */ #include "back.h" void -getmove() +getmove(void) { int i, c; @@ -105,8 +105,7 @@ getmove() } int -movokay(mv) - int mv; +movokay(int mv) { int i, m; diff --git a/backgammon/common_source/fancy.c b/backgammon/common_source/fancy.c index d38bc4ea..fcbeabb4 100644 --- a/backgammon/common_source/fancy.c +++ b/backgammon/common_source/fancy.c @@ -1,4 +1,4 @@ -/* $NetBSD: fancy.c,v 1.12 2004/04/23 02:58:27 simonb Exp $ */ +/* $NetBSD: fancy.c,v 1.13 2005/07/01 01:12:39 jmc Exp $ */ /* * Copyright (c) 1980, 1993 @@ -34,7 +34,7 @@ #if 0 static char sccsid[] = "@(#)fancy.c 8.1 (Berkeley) 5/31/93"; #else -__RCSID("$NetBSD: fancy.c,v 1.12 2004/04/23 02:58:27 simonb Exp $"); +__RCSID("$NetBSD: fancy.c,v 1.13 2005/07/01 01:12:39 jmc Exp $"); #endif #endif /* not lint */ @@ -70,7 +70,8 @@ int buffnum; /* pointer to output buffer */ char tbuf[1024]; /* buffer for decoded termcap entries */ -int oldb[] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; +int oldb[] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0}; int oldr; int oldw; @@ -80,7 +81,7 @@ int realr; int realc; void -fboard() +fboard(void) { int i, j, l; @@ -187,11 +188,7 @@ fboard() * differently. */ void -bsect(b, rpos, cpos, cnext) - int b; /* contents of position */ - int rpos; /* row of position */ - int cpos; /* column of position */ - int cnext; /* direction of position */ +bsect(int b, int rpos, int cpos, int cnext) { int j; /* index */ int n; /* number of men on position */ @@ -240,13 +237,14 @@ bsect(b, rpos, cpos, cnext) bct = 3; } } - curmove(curr + cnext, curc - bct); /* reposition cursor */ + /* reposition cursor */ + curmove(curr + cnext, curc - bct); } } } void -refresh() +refresh(void) { int i, r, c; @@ -297,18 +295,17 @@ refresh() } void -fixpos(old, new, r, c, inc) - int old, new, r, c, inc; +fixpos(int cur, int new, int r, int c, int inc) { int o, n, nv; int ov, nc; char col; nc = 0; - if (old * new >= 0) { - ov = abs(old); + if (cur * new >= 0) { + ov = abs(cur); nv = abs(new); - col = (old + new > 0 ? 'r' : 'w'); + col = (cur + new > 0 ? 'r' : 'w'); o = (ov - 1) / 5; n = (nv - 1) / 5; if (o == n) { @@ -319,23 +316,29 @@ fixpos(old, new, r, c, inc) if (o == 0) nc = c < 54 ? c + 1 : c; if (ov > nv) - fixcol(r + inc * (nv - n * 5), nc, abs(ov - nv), ' ', inc); + fixcol(r + inc * (nv - n * 5), nc, + abs(ov - nv), ' ', inc); else - fixcol(r + inc * (ov - o * 5), nc, abs(ov - nv), col, inc); + fixcol(r + inc * (ov - o * 5), nc, + abs(ov - nv), col, inc); return; } else { if (c < 54) { if (o + n == 1) { if (n) { - fixcol(r, c, abs(nv - 5), col, inc); + fixcol(r, c, abs(nv - 5), col, + inc); if (ov != 5) - fixcol(r + inc * ov, c + 1, - abs(ov - 5), col, inc); + fixcol(r + inc * ov, + c + 1, abs(ov - 5), + col, inc); } else { - fixcol(r, c, abs(ov - 5), ' ', inc); + fixcol(r, c, abs(ov - 5), ' ', + inc); if (nv != 5) - fixcol(r + inc * nv, c + 1, - abs(nv - 5), ' ', inc); + fixcol(r + inc * nv, + c + 1, abs(nv - 5), + ' ', inc); } return; } @@ -343,37 +346,42 @@ fixpos(old, new, r, c, inc) if (ov != 10) fixcol(r + inc * (ov - 5), c, abs(ov - 10), col, inc); - fixcol(r, c + 2, abs(nv - 10), col, inc); + fixcol(r, c + 2, abs(nv - 10), col, + inc); } else { if (nv != 10) fixcol(r + inc * (nv - 5), c, abs(nv - 10), ' ', inc); - fixcol(r, c + 2, abs(ov - 10), ' ', inc); + fixcol(r, c + 2, abs(ov - 10), ' ', + inc); } return; } if (n > o) { - fixcol(r + inc * (ov % 5), c + o, abs(5 * n - ov), col, inc); + fixcol(r + inc * (ov % 5), c + o, + abs(5 * n - ov), col, inc); if (nv != 5 * n) - fixcol(r, c + n, abs(5 * n - nv), col, inc); + fixcol(r, c + n, abs(5 * n - nv), + col, inc); } else { - fixcol(r + inc * (nv % 5), c + n, abs(5 * n - nv), ' ', inc); + fixcol(r + inc * (nv % 5), c + n, + abs(5 * n - nv), ' ', inc); if (ov != 5 * o) - fixcol(r, c + o, abs(5 * o - ov), ' ', inc); + fixcol(r, c + o, abs(5 * o - ov), + ' ', inc); } return; } } nv = abs(new); fixcol(r, c + 1, nv, new > 0 ? 'r' : 'w', inc); - if (abs(old) <= abs(new)) + if (abs(cur) <= abs(new)) return; - fixcol(r + inc * new, c + 1, abs(old + new), ' ', inc); + fixcol(r + inc * new, c + 1, abs(cur + new), ' ', inc); } void -fixcol(r, c, l, ch, inc) - int l, ch, r, c, inc; +fixcol(int r, int c, int l, int ch, int inc) { int i; @@ -386,8 +394,7 @@ fixcol(r, c, l, ch, inc) } void -curmove(r, c) - int r, c; +curmove(int r, int c) { if (curr == r && curc == c) return; @@ -400,13 +407,13 @@ curmove(r, c) } void -newpos() +newpos(void) { int r; /* destination row */ int c; /* destination column */ int mode = -1; /* mode of movement */ - int count = 1000; /* character count */ + int ccount = 1000; /* character count */ int i; /* index */ int n; /* temporary variable */ char *m; /* string containing CM movement */ @@ -429,51 +436,53 @@ newpos() if (CM) { /* try CM to get there */ mode = 0; m = (char *) tgoto(CM, c, r); - count = strlen(m); + ccount = strlen(m); } /* try HO and local movement */ - if (HO && (n = r + c * lND + lHO) < count) { + if (HO && (n = r + c * lND + lHO) < ccount) { mode = 1; - count = n; + ccount = n; } /* try various LF combinations */ if (r >= curr) { /* CR, LF, and ND */ - if ((n = (r - curr) + c * lND + 1) < count) { + if ((n = (r - curr) + c * lND + 1) < ccount) { mode = 2; - count = n; + ccount = n; } /* LF, ND */ - if (c >= curc && (n = (r - curr) + (c - curc) * lND) < count) { + if (c >= curc && (n = (r - curr) + (c - curc) * lND) < ccount) { mode = 3; - count = n; + ccount = n; } /* LF, BS */ - if (c < curc && (n = (r - curr) + (curc - c) * lBC) < count) { + if (c < curc && (n = (r - curr) + (curc - c) * lBC) < ccount) { mode = 4; - count = n; + ccount = n; } } /* try corresponding UP combinations */ if (r < curr) { /* CR, UP, and ND */ - if ((n = (curr - r) * lUP + c * lND + 1) < count) { + if ((n = (curr - r) * lUP + c * lND + 1) < ccount) { mode = 5; - count = n; + ccount = n; } /* UP and ND */ - if (c >= curc && (n = (curr - r) * lUP + (c - curc) * lND) < count) { + if (c >= curc && + (n = (curr - r) * lUP + (c - curc) * lND) < ccount) { mode = 6; - count = n; + ccount = n; } /* UP and BS */ - if (c < curc && (n = (curr - r) * lUP + (curc - c) * lBC) < count) { + if (c < curc && + (n = (curr - r) * lUP + (curc - c) * lBC) < ccount) { mode = 7; - count = n; + ccount = n; } } /* space over */ - if (curr == r && c > curc && linect[r] < curc && c - curc < count) + if (curr == r && c > curc && linect[r] < curc && c - curc < ccount) mode = 8; switch (mode) { @@ -564,7 +573,7 @@ newpos() } void -clear() +clear(void) { int i; @@ -582,8 +591,7 @@ clear() } void -fancyc(c) - char c; /* character to output */ +fancyc(int c) { int sp; /* counts spaces in a tab */ @@ -633,7 +641,7 @@ fancyc(c) } void -clend() +clend(void) { int i; @@ -654,7 +662,7 @@ clend() } void -cline() +cline(void) { int c; @@ -676,7 +684,7 @@ cline() } void -newline() +newline(void) { cline(); if (curr == LI - 1) @@ -686,8 +694,7 @@ newline() } int -getcaps(s) - const char *s; +getcaps(const char *s) { char *code; /* two letter code */ char ***cap; /* pointer to cap string */ diff --git a/backgammon/common_source/odds.c b/backgammon/common_source/odds.c index 509d5f49..0d875848 100644 --- a/backgammon/common_source/odds.c +++ b/backgammon/common_source/odds.c @@ -1,4 +1,4 @@ -/* $NetBSD: odds.c,v 1.5 2003/08/07 09:36:57 agc Exp $ */ +/* $NetBSD: odds.c,v 1.6 2005/07/01 01:12:39 jmc Exp $ */ /* * Copyright (c) 1980, 1993 @@ -34,15 +34,14 @@ #if 0 static char sccsid[] = "@(#)odds.c 8.1 (Berkeley) 5/31/93"; #else -__RCSID("$NetBSD: odds.c,v 1.5 2003/08/07 09:36:57 agc Exp $"); +__RCSID("$NetBSD: odds.c,v 1.6 2005/07/01 01:12:39 jmc Exp $"); #endif #endif /* not lint */ #include "back.h" void -odds(r1, r2, val) - int r1, r2, val; +odds(int r1, int r2, int val) { int i, j; @@ -66,7 +65,7 @@ odds(r1, r2, val) } int -count() +count(void) { int i; int j; @@ -80,8 +79,7 @@ count() } int -canhit(i, c) - int i, c; +canhit(int i, int c) { int j, k, b; int a, diff, place, addon, menstuck; diff --git a/backgammon/common_source/one.c b/backgammon/common_source/one.c index 86b57ef6..dde3096a 100644 --- a/backgammon/common_source/one.c +++ b/backgammon/common_source/one.c @@ -1,4 +1,4 @@ -/* $NetBSD: one.c,v 1.5 2003/08/07 09:36:57 agc Exp $ */ +/* $NetBSD: one.c,v 1.6 2005/07/01 01:12:39 jmc Exp $ */ /* * Copyright (c) 1980, 1993 @@ -34,15 +34,14 @@ #if 0 static char sccsid[] = "@(#)one.c 8.1 (Berkeley) 5/31/93"; #else -__RCSID("$NetBSD: one.c,v 1.5 2003/08/07 09:36:57 agc Exp $"); +__RCSID("$NetBSD: one.c,v 1.6 2005/07/01 01:12:39 jmc Exp $"); #endif #endif /* not lint */ #include "back.h" int -makmove(i) - int i; +makmove(int i) { int n, d; int max; @@ -95,8 +94,7 @@ makmove(i) } void -moverr(i) - int i; +moverr(int i) { int j; @@ -118,8 +116,7 @@ moverr(i) int -checkd(d) - int d; +checkd(int d) { if (d0 != d) swap; @@ -127,7 +124,7 @@ checkd(d) } int -last() +last(void) { int i; @@ -138,8 +135,7 @@ last() } void -movback(i) - int i; +movback(int i) { int j; @@ -148,8 +144,7 @@ movback(i) } void -backone(i) - int i; +backone(int i) { board[p[i]] += cturn; if (g[i] != home) { diff --git a/backgammon/common_source/save.c b/backgammon/common_source/save.c index e48a914f..d0c58715 100644 --- a/backgammon/common_source/save.c +++ b/backgammon/common_source/save.c @@ -1,4 +1,4 @@ -/* $NetBSD: save.c,v 1.10 2003/08/07 09:36:57 agc Exp $ */ +/* $NetBSD: save.c,v 1.11 2005/07/01 01:12:39 jmc Exp $ */ /* * Copyright (c) 1980, 1993 @@ -34,7 +34,7 @@ #if 0 static char sccsid[] = "@(#)save.c 8.1 (Berkeley) 5/31/93"; #else -__RCSID("$NetBSD: save.c,v 1.10 2003/08/07 09:36:57 agc Exp $"); +__RCSID("$NetBSD: save.c,v 1.11 2005/07/01 01:12:39 jmc Exp $"); #endif #endif /* not lint */ @@ -54,8 +54,7 @@ static const char rec[] = "\" to recover your game.\n\n"; static const char cantrec[] = "Can't recover file: "; void -save(n) - int n; +save(int n) { int fdesc; char *fs; @@ -145,8 +144,7 @@ save(n) } void -recover(s) - const char *s; +recover(const char *s) { int fdesc; @@ -168,8 +166,7 @@ recover(s) } void -norec(s) - const char *s; +norec(const char *s) { const char *c; diff --git a/backgammon/common_source/subs.c b/backgammon/common_source/subs.c index 1daeb72e..a95e4813 100644 --- a/backgammon/common_source/subs.c +++ b/backgammon/common_source/subs.c @@ -1,4 +1,4 @@ -/* $NetBSD: subs.c,v 1.14 2003/08/07 09:36:57 agc Exp $ */ +/* $NetBSD: subs.c,v 1.15 2005/07/01 01:12:39 jmc Exp $ */ /* * Copyright (c) 1980, 1993 @@ -34,7 +34,7 @@ #if 0 static char sccsid[] = "@(#)subs.c 8.1 (Berkeley) 5/31/93"; #else -__RCSID("$NetBSD: subs.c,v 1.14 2003/08/07 09:36:57 agc Exp $"); +__RCSID("$NetBSD: subs.c,v 1.15 2005/07/01 01:12:39 jmc Exp $"); #endif #endif /* not lint */ @@ -61,8 +61,7 @@ const char *const descr[] = { }; void -errexit(s) - const char *s; +errexit(const char *s) { write(2, "\n", 1); perror(s); @@ -70,8 +69,7 @@ errexit(s) } int -addbuf(c) - int c; +addbuf(int c) { buffnum++; if (buffnum == BUFSIZ) { @@ -84,7 +82,7 @@ addbuf(c) } void -buflush() +buflush(void) { if (buffnum < 0) return; @@ -95,7 +93,7 @@ buflush() } int -readc() +readc(void) { char c; @@ -122,8 +120,7 @@ readc() } void -writec(c) - char c; +writec(int c) { if (tflag) fancyc(c); @@ -132,8 +129,7 @@ writec(c) } void -writel(l) - const char *l; +writel(const char *l) { #ifdef DEBUG const char *s; @@ -157,7 +153,7 @@ writel(l) } void -proll() +proll(void) { if (d0) swap; @@ -173,8 +169,7 @@ proll() } void -wrint(n) - int n; +wrint(int n) { int i, j, t; @@ -189,7 +184,7 @@ wrint(n) } void -gwrite() +gwrite(void) { int r, c; @@ -232,7 +227,7 @@ gwrite() } int -quit() +quit(void) { if (tflag) { @@ -254,8 +249,7 @@ quit() } int -yorn(special) - char special; /* special response */ +yorn(int special) { char c; int i; @@ -285,8 +279,7 @@ yorn(special) } void -wrhit(i) - int i; +wrhit(int i) { writel("Blot hit on "); wrint(i); @@ -295,7 +288,7 @@ wrhit(i) } void -nexturn() +nexturn(void) { int c; @@ -312,8 +305,7 @@ nexturn() } void -getarg(arg) - char ***arg; +getarg(char ***arg) { char **s; @@ -399,7 +391,7 @@ getarg(arg) } void -init() +init(void) { int i; @@ -418,7 +410,7 @@ init() } void -wrscore() +wrscore(void) { writel("Score: "); writel(color[1]); @@ -431,8 +423,7 @@ wrscore() } void -fixtty(t) - struct termios *t; +fixtty(struct termios *t) { if (tflag) newpos(); @@ -442,8 +433,7 @@ fixtty(t) } void -getout(dummy) - int dummy __attribute__((__unused__)); +getout(int dummy __attribute__((__unused__))) { /* go to bottom of screen */ if (tflag) { @@ -458,7 +448,7 @@ getout(dummy) } void -roll() +roll(void) { char c; int row; diff --git a/backgammon/common_source/table.c b/backgammon/common_source/table.c index e54e8010..280fe87c 100644 --- a/backgammon/common_source/table.c +++ b/backgammon/common_source/table.c @@ -1,4 +1,4 @@ -/* $NetBSD: table.c,v 1.7 2003/08/07 09:36:57 agc Exp $ */ +/* $NetBSD: table.c,v 1.8 2005/07/01 01:12:39 jmc Exp $ */ /* * Copyright (c) 1980, 1993 @@ -34,7 +34,7 @@ #if 0 static char sccsid[] = "@(#)table.c 8.1 (Berkeley) 5/31/93"; #else -__RCSID("$NetBSD: table.c,v 1.7 2003/08/07 09:36:57 agc Exp $"); +__RCSID("$NetBSD: table.c,v 1.8 2005/07/01 01:12:39 jmc Exp $"); #endif #endif /* not lint */ @@ -78,8 +78,7 @@ static const struct state atmata[] = { }; int -checkmove(ist) - int ist; +checkmove(int ist) { int j, n; char c; @@ -196,9 +195,7 @@ dochar: } int -dotable(c, i) - char c; - int i; +dotable(int c, int i) { int a; int test; @@ -292,7 +289,7 @@ dotable(c, i) } int -rsetbrd() +rsetbrd(void) { int i, j, n; -- cgit v1.2.3-56-ge451