Subject: bin/5567: battlestar(6) externs/commons patch
To: None <gnats-bugs@gnats.netbsd.org>
From: None <dholland@eecs.harvard.edu>
List: netbsd-bugs
Date: 06/10/1998 20:50:18
>Number:         5567
>Category:       bin
>Synopsis:       battlestar(6) doesn't extern all its globals; patch
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    bin-bug-people (Utility Bug People)
>State:          open
>Class:          change-request
>Submitter-Id:   net
>Arrival-Date:   Wed Jun 10 18:35:00 1998
>Last-Modified:
>Originator:     David A. Holland
>Organization:
   - David A. Holland             |    VINO project home page:
     dholland@eecs.harvard.edu    | http://www.eecs.harvard.edu/vino
>Release:        1.3
>Environment:

	NetBSD 1.3 release (on x86, but cross-compiling for VINO)

>Description:
	battlestar(6) is missing "extern" on most of its globals
	(of which it has a lot). Some of these are causing the
	VINO ELF linker to issue warnings, so I went in and 
	fixed the lot. The patch is appended.

>How-To-Repeat:
	Compiling and linking battlestar with gnu binutils compiled
	for ELF causes warnings about the sizes of some symbols
	changing.

>Fix:

Index: extern.h
===================================================================
RCS file: /home/vino/repo/src/utils/bsd/games/battlestar/extern.h,v
retrieving revision 1.1.1.2
diff -u -r1.1.1.2 extern.h
--- extern.h	1998/05/28 23:24:37	1.1.1.2
+++ extern.h	1998/06/11 01:23:05
@@ -234,72 +234,68 @@
 	char   *desc;
 	unsigned int objects[NUMOFWORDS];
 };
-struct room dayfile[];
-struct room nightfile[];
-struct room *location;
+extern struct room dayfile[];
+extern struct room nightfile[];
+extern struct room *location;
 
  /* object characteristics */
-char   *objdes[NUMOFOBJECTS];
-char   *objsht[NUMOFOBJECTS];
-char   *ouch[NUMOFINJURIES];
-int     objwt[NUMOFOBJECTS];
-int     objcumber[NUMOFOBJECTS];
+extern char   *objdes[NUMOFOBJECTS];
+extern char   *objsht[NUMOFOBJECTS];
+extern char   *ouch[NUMOFINJURIES];
+extern int     objwt[NUMOFOBJECTS];
+extern int     objcumber[NUMOFOBJECTS];
 
  /* current input line */
 #define NWORD	20		/* words per line */
-char    words[NWORD][15];
-int     wordvalue[NWORD];
-int     wordtype[NWORD];
-int     wordcount, wordnumber;
+extern char    words[NWORD][15];
+extern int     wordvalue[NWORD];
+extern int     wordtype[NWORD];
+extern int     wordcount, wordnumber;
 
  /* state of the game */
-int     ourtime;
-int     position;
-int     direction;
-int     left, right, ahead, back;
-int     ourclock, fuel, torps;
-int     carrying, encumber;
-int     rythmn;
-int     followfight;
-int     ate;
-int     snooze;
-int     meetgirl;
-int     followgod;
-int     godready;
-int     win;
-int     wintime;
-int     wiz;
-int     tempwiz;
-int     matchlight, matchcount;
-int     loved;
-int     pleasure, power, ego;
-int     WEIGHT;
-int     CUMBER;
-int     notes[NUMOFNOTES];
-unsigned int inven[NUMOFWORDS];
-unsigned int wear[NUMOFWORDS];
-char    beenthere[NUMOFROOMS + 1];
-char    injuries[NUMOFINJURIES];
+extern int     ourtime;
+extern int     position;
+extern int     direction;
+extern int     left, right, ahead, back;
+extern int     ourclock, fuel, torps;
+extern int     carrying, encumber;
+extern int     rythmn;
+extern int     followfight;
+extern int     ate;
+extern int     snooze;
+extern int     meetgirl;
+extern int     followgod;
+extern int     godready;
+extern int     win;
+extern int     wintime;
+extern int     wiz;
+extern int     tempwiz;
+extern int     matchlight, matchcount;
+extern int     loved;
+extern int     pleasure, power, ego;
+extern int     WEIGHT;
+extern int     CUMBER;
+extern int     notes[NUMOFNOTES];
+extern unsigned int inven[NUMOFWORDS];
+extern unsigned int wear[NUMOFWORDS];
+extern char    beenthere[NUMOFROOMS + 1];
+extern char    injuries[NUMOFINJURIES];
 
-char    uname[9];
+extern char    uname[9];
 
 struct wlist {
 	char   *string;
 	int     value, article;
 	struct wlist *next;
 };
-#define HASHSIZE	256
-#define HASHMUL		81
-#define HASHMASK	(HASHSIZE - 1)
-struct wlist *hashtab[HASHSIZE];
-struct wlist wlist[];
+extern struct wlist wlist[];
 
 struct objs {
 	short   room;
 	short   obj;
 };
-struct objs dayobjs[];
-struct objs nightobjs[];
+extern struct objs dayobjs[];
+extern struct objs nightobjs[];
 
 void blast __P((void));
 void bury __P((void));
Index: fly.c
===================================================================
RCS file: /home/vino/repo/src/utils/bsd/games/battlestar/fly.c,v
retrieving revision 1.1.1.2
diff -u -r1.1.1.2 fly.c
--- fly.c	1998/05/28 23:24:38	1.1.1.2
+++ fly.c	1998/06/11 01:20:11
@@ -50,12 +50,13 @@
 #define MIDR  (LINES/2 - 1)
 #define MIDC  (COLS/2 - 1)
 
-int     row, column;
+static int     row, column;
+static char    destroyed;
+static sig_t   oldsig;
+
 int     dr = 0, dc = 0;
-char    destroyed;
 int     ourclock = 120;		/* time for all the flights in the game */
 char    cross = 0;
-sig_t   oldsig;
 
 void
 succumb(dummy)
Index: globals.c
===================================================================
RCS file: /home/vino/repo/src/utils/bsd/games/battlestar/globals.c,v
retrieving revision 1.1.1.2
diff -u -r1.1.1.2 globals.c
--- globals.c	1998/05/28 23:24:39	1.1.1.2
+++ globals.c	1998/06/11 01:22:00
@@ -224,3 +224,40 @@
 int     matchcount = 20;
 int     followgod = -1;
 int     followfight = -1;
+
+struct room *location;
+
+char    words[NWORD][15];
+int     wordvalue[NWORD];
+int     wordtype[NWORD];
+int     wordcount, wordnumber;
+
+int     ourtime;
+int     position;
+int     direction;
+int     left, right, ahead, back;
+int     ourclock, fuel, torps;
+int     carrying, encumber;
+int     rythmn;
+int     followfight;
+int     ate;
+int     snooze;
+int     meetgirl;
+int     followgod;
+int     godready;
+int     win;
+int     wintime;
+int     wiz;
+int     tempwiz;
+int     matchlight, matchcount;
+int     loved;
+int     pleasure, power, ego;
+int     WEIGHT;
+int     CUMBER;
+int     notes[NUMOFNOTES];
+unsigned int inven[NUMOFWORDS];
+unsigned int wear[NUMOFWORDS];
+char    beenthere[NUMOFROOMS + 1];
+char    injuries[NUMOFINJURIES];
+
+char    uname[9];
Index: parse.c
===================================================================
RCS file: /home/vino/repo/src/utils/bsd/games/battlestar/parse.c,v
retrieving revision 1.1.1.2
diff -u -r1.1.1.2 parse.c
--- parse.c	1998/05/28 23:24:44	1.1.1.2
+++ parse.c	1998/06/11 01:22:48
@@ -44,6 +44,11 @@
 
 #include "extern.h"
 
+#define HASHSIZE	256
+#define HASHMUL		81
+#define HASHMASK	(HASHSIZE - 1)
+static struct wlist *hashtab[HASHSIZE];
+
 void
 wordinit()
 {
>Audit-Trail:
>Unformatted: