Skip to content

Commit

Permalink
games: Fix -Werror for gcc47.
Browse files Browse the repository at this point in the history
* Remove unused variables and mark a few things __unused.

* Properly use socklen_t.

* Remove trek(6)'s undocumented -p option (which did nothing).
  • Loading branch information
Sascha Wildner committed Jul 12, 2012
1 parent a8f1df1 commit 435f923
Show file tree
Hide file tree
Showing 9 changed files with 13 additions and 62 deletions.
6 changes: 3 additions & 3 deletions games/adventure/io.c
Expand Up @@ -564,7 +564,7 @@ void
pspeak(int m, int skip) pspeak(int m, int skip)
{ {
char *s, nonfirst; char *s, nonfirst;
char *numst, ps_save; char *numst;
struct text *msg; struct text *msg;
char *tbuf; char *tbuf;


Expand All @@ -580,8 +580,8 @@ pspeak(int m, int skip)
for (numst = s; (*s ^= *tape++) != TAB; s++) /* get number */ for (numst = s; (*s ^= *tape++) != TAB; s++) /* get number */
; /* nothing */ ; /* nothing */


ps_save = *s; /* Temporarily trash the string (cringe) */ /* Temporarily trash the string (cringe) */
*s++ = 0; /* decrypting number within the string */ *s++ = 0; /* decrypting number within the string */


if (atoi(numst) != 100 * skip && skip >= 0) { if (atoi(numst) != 100 * skip && skip >= 0) {
while ((*s++ ^ *tape++) != LF) /* flush the line */ while ((*s++ ^ *tape++) != LF) /* flush the line */
Expand Down
4 changes: 0 additions & 4 deletions games/backgammon/teachgammon/ttext2.c
Expand Up @@ -28,7 +28,6 @@
* *
* @(#)ttext2.c 8.1 (Berkeley) 5/31/93 * @(#)ttext2.c 8.1 (Berkeley) 5/31/93
* $FreeBSD: src/games/backgammon/teachgammon/ttext2.c,v 1.3.2.1 2001/10/15 13:46:32 dd Exp $ * $FreeBSD: src/games/backgammon/teachgammon/ttext2.c,v 1.3.2.1 2001/10/15 13:46:32 dd Exp $
* $DragonFly: src/games/backgammon/teachgammon/ttext2.c,v 1.3 2006/08/08 16:36:11 pavalos Exp $
*/ */


#include "back.h" #include "back.h"
Expand Down Expand Up @@ -123,14 +122,12 @@ const char *const lastch[] = {
int int
text(const char *const *txt) text(const char *const *txt)
{ {
const char *const *begin;
const char *a; const char *a;
char b; char b;
const char *c; const char *c;
int i; int i;


fixtty(noech); fixtty(noech);
begin = txt;
while (*txt) { while (*txt) {
a = *(txt++); a = *(txt++);
if (*a != '\0') { if (*a != '\0') {
Expand Down Expand Up @@ -182,7 +179,6 @@ text(const char *const *txt)
fixtty(noech); fixtty(noech);
if (tflag) if (tflag)
curmove(curr, 0); curmove(curr, 0);
begin = txt;
} }
} }
fixtty(raw); fixtty(raw);
Expand Down
2 changes: 1 addition & 1 deletion games/battlestar/fly.c
Expand Up @@ -240,7 +240,7 @@ blast(void)
} }


static void static void
moveenemy(int sig) moveenemy(__unused int sig)
{ {
double d; double d;
int oldr, oldc; int oldr, oldc;
Expand Down
4 changes: 2 additions & 2 deletions games/hunt/hunt/list.c
Expand Up @@ -5,7 +5,6 @@
* This software is provided ``as is'' without express or implied warranty. * This software is provided ``as is'' without express or implied warranty.
* *
* $OpenBSD: list.c,v 1.5 2007/09/04 22:39:31 hshoexer Exp $ * $OpenBSD: list.c,v 1.5 2007/09/04 22:39:31 hshoexer Exp $
* $DragonFly: src/games/hunt/hunt/list.c,v 1.2 2008/09/04 16:12:51 swildner Exp $
*/ */


#include <stdio.h> #include <stdio.h>
Expand Down Expand Up @@ -54,7 +53,8 @@ next_driver_fd(int fd)
{ {
fd_set r; fd_set r;
int maxfd = -1; int maxfd = -1;
int i, s, ret, len; int i, s, ret;
socklen_t len;
struct driver *driver; struct driver *driver;
u_int16_t resp; u_int16_t resp;


Expand Down
5 changes: 1 addition & 4 deletions games/rain/rain.c
Expand Up @@ -29,7 +29,6 @@
* @(#) Copyright (c) 1980, 1993 The Regents of the University of California. All rights reserved. * @(#) Copyright (c) 1980, 1993 The Regents of the University of California. All rights reserved.
* @(#)rain.c 8.1 (Berkeley) 5/31/93 * @(#)rain.c 8.1 (Berkeley) 5/31/93
* $FreeBSD: src/games/rain/rain.c,v 1.8.2.1 2001/03/05 11:54:10 kris Exp $ * $FreeBSD: src/games/rain/rain.c,v 1.8.2.1 2001/03/05 11:54:10 kris Exp $
* $DragonFly: src/games/rain/rain.c,v 1.3 2003/11/12 14:53:54 eirikn Exp $
*/ */


/* /*
Expand Down Expand Up @@ -127,9 +126,7 @@ main(int argc, char **argv)
} }


static void static void
onsig(int sig) onsig(__unused int sig)
{ {

sig = 0;
sig_caught = 1; sig_caught = 1;
} }
4 changes: 1 addition & 3 deletions games/rogue/init.c
Expand Up @@ -80,7 +80,6 @@ boolean
init(int argc, char *argv[]) init(int argc, char *argv[])
{ {
const char *pn; const char *pn;
int seed;


pn = md_gln(); pn = md_gln();
if ((!pn) || (strlen(pn) >= MAX_OPT_LEN)) { if ((!pn) || (strlen(pn) >= MAX_OPT_LEN)) {
Expand Down Expand Up @@ -109,8 +108,7 @@ init(int argc, char *argv[])
if (score_only) { if (score_only) {
put_scores(NULL, 0); put_scores(NULL, 0);
} }
seed = md_gseed(); srandomdev();
srrandom(seed);
if (rest_file) { if (rest_file) {
restore(rest_file); restore(rest_file);
return(1); return(1);
Expand Down
28 changes: 0 additions & 28 deletions games/rogue/machdep.c
Expand Up @@ -31,7 +31,6 @@
* *
* @(#)machdep.c 8.1 (Berkeley) 5/31/93 * @(#)machdep.c 8.1 (Berkeley) 5/31/93
* $FreeBSD: src/games/rogue/machdep.c,v 1.6.2.1 2001/12/17 12:43:23 phantom Exp $ * $FreeBSD: src/games/rogue/machdep.c,v 1.6.2.1 2001/12/17 12:43:23 phantom Exp $
* $DragonFly: src/games/rogue/machdep.c,v 1.4 2006/09/09 02:21:49 pavalos Exp $
*/ */


/* /*
Expand Down Expand Up @@ -448,33 +447,6 @@ md_malloc(int n)
return(t); return(t);
} }


/* md_gseed() (Get Seed)
*
* This function returns a seed for the random number generator (RNG). This
* seed causes the RNG to begin generating numbers at some point in its
* sequence. Without a random seed, the RNG will generate the same set
* of numbers, and every game will start out exactly the same way. A good
* number to use is the process id, given by getpid() on most UNIX systems.
*
* You need to find some single random integer, such as:
* process id.
* current time (minutes + seconds) returned from md_gct(), if implemented.
*
* It will not help to return "get_rand()" or "rand()" or the return value of
* any pseudo-RNG. If you don't have a random number, you can just return 1,
* but this means your games will ALWAYS start the same way, and will play
* exactly the same way given the same input.
*/

int
md_gseed(void)
{
time_t seconds;

time(&seconds);
return((int)seconds);
}

/* md_exit(): /* md_exit():
* *
* This function causes the program to discontinue execution and exit. * This function causes the program to discontinue execution and exit.
Expand Down
3 changes: 0 additions & 3 deletions games/rogue/rogue.h
Expand Up @@ -31,7 +31,6 @@
* *
* @(#)rogue.h 8.1 (Berkeley) 5/31/93 * @(#)rogue.h 8.1 (Berkeley) 5/31/93
* $FreeBSD: src/games/rogue/rogue.h,v 1.3.2.1 2001/12/17 12:43:23 phantom Exp $ * $FreeBSD: src/games/rogue/rogue.h,v 1.3.2.1 2001/12/17 12:43:23 phantom Exp $
* $DragonFly: src/games/rogue/rogue.h,v 1.4 2006/09/02 19:31:07 pavalos Exp $
*/ */


#include <curses.h> #include <curses.h>
Expand Down Expand Up @@ -443,7 +442,6 @@ struct rogue_time {
/* external routine declarations. /* external routine declarations.
*/ */
#define rrandom random #define rrandom random
#define srrandom(x) srandomdev()


/* hit.c */ /* hit.c */
void mon_hit(object *); void mon_hit(object *);
Expand Down Expand Up @@ -505,7 +503,6 @@ const char *md_gln(void);
void md_sleep(int); void md_sleep(int);
char *md_getenv(const char *); char *md_getenv(const char *);
char *md_malloc(int); char *md_malloc(int);
int md_gseed(void);
void md_exit(int); void md_exit(int);
void md_lock(boolean); void md_lock(boolean);
void md_shell(const char *); void md_shell(const char *);
Expand Down
19 changes: 5 additions & 14 deletions games/trek/main.c
Expand Up @@ -29,14 +29,11 @@
* @(#) Copyright (c) 1980, 1993 The Regents of the University of California. All rights reserved. * @(#) Copyright (c) 1980, 1993 The Regents of the University of California. All rights reserved.
* @(#)main.c 8.1 (Berkeley) 5/31/93 * @(#)main.c 8.1 (Berkeley) 5/31/93
* $FreeBSD: src/games/trek/main.c,v 1.7.2.1 2001/03/05 12:11:14 kris Exp $ * $FreeBSD: src/games/trek/main.c,v 1.7.2.1 2001/03/05 12:11:14 kris Exp $
* $DragonFly: src/games/trek/main.c,v 1.3 2006/09/07 21:19:44 pavalos Exp $
*/ */


#include "trek.h" #include "trek.h"
#include "getpar.h" #include "getpar.h"


#define PRIO 00 /* default priority */

unsigned int Mother = 51 + (51 << 8); unsigned int Mother = 51 + (51 << 8);


/* /*
Expand Down Expand Up @@ -143,9 +140,8 @@ main(int argc, char **argv)
{ {
#if 0 #if 0
extern FILE *f_log; extern FILE *f_log;
#endif
char opencode; char opencode;
int prio; #endif
int ac; int ac;
char **av; char **av;


Expand All @@ -156,13 +152,15 @@ main(int argc, char **argv)
ac = argc; ac = argc;
av++; av++;
srandomdev(); srandomdev();
#if 0
opencode = 'w'; opencode = 'w';
prio = PRIO; #endif

while (ac > 1 && av[0][0] == '-') { while (ac > 1 && av[0][0] == '-') {
switch (av[0][1]) { switch (av[0][1]) {
case 'a': /* append to log file */ case 'a': /* append to log file */
#if 0
opencode = 'a'; opencode = 'a';
#endif
break; break;


#ifdef xTRACE #ifdef xTRACE
Expand All @@ -172,13 +170,6 @@ main(int argc, char **argv)
Trace++; Trace++;
break; break;
#endif #endif

case 'p': /* set priority */
if (getuid() != Mother)
goto badflag;
prio = atoi(av[0] + 2);
break;

default: default:
badflag: badflag:
printf("Invalid option: %s\n", av[0]); printf("Invalid option: %s\n", av[0]);
Expand Down

0 comments on commit 435f923

Please sign in to comment.