changeset 200:1cd604c827a3

Advanced Rogue 7: initialize multiple variables. MSVC complained that they might be used uninitialized. In some cases, this might have been possible. XRogue already has initializations for all these variables.
author John "Elwin" Edwards
date Wed, 12 Aug 2015 15:42:02 -0400
parents efdbeec0816d
children 6fb21004a981
files arogue7/actions.c arogue7/command.c arogue7/daemons.c arogue7/fight.c arogue7/misc.c arogue7/move.c arogue7/pack.c arogue7/passages.c arogue7/scrolls.c arogue7/sticks.c arogue7/util.c arogue7/wizard.c
diffstat 12 files changed, 23 insertions(+), 23 deletions(-) [+]
line wrap: on
line diff
--- a/arogue7/actions.c	Tue Aug 11 16:19:04 2015 -0400
+++ b/arogue7/actions.c	Wed Aug 12 15:42:02 2015 -0400
@@ -239,7 +239,7 @@
 register struct thing *tp;
 {
     register int damage;
-    register char *breath;
+    register char *breath = "";
 
     damage = tp->t_stats.s_hpt;
     turn_off(*tp, CANSURPRISE);
@@ -783,7 +783,7 @@
 int segments;    /* Number of segments since last called */
 {
     register struct linked_list *item;
-    register struct thing *tp;
+    register struct thing *tp = NULL;
     register min_time = 20;	/* Minimum time until a monster can act */
 
     /*
--- a/arogue7/command.c	Tue Aug 11 16:19:04 2015 -0400
+++ b/arogue7/command.c	Wed Aug 12 15:42:02 2015 -0400
@@ -1078,7 +1078,7 @@
 bool mark;
 {
     register struct object *obj;
-    register char **guess, *elsewise;
+    register char **guess = NULL, *elsewise = NULL;
     register bool *know;
 
     if (item == NULL) {
--- a/arogue7/daemons.c	Tue Aug 11 16:19:04 2015 -0400
+++ b/arogue7/daemons.c	Wed Aug 12 15:42:02 2015 -0400
@@ -417,7 +417,7 @@
 alchemy(obj)
 register struct object *obj;
 {
-    register struct object *tobj;
+    register struct object *tobj = NULL;
     register struct linked_list *item;
 
     /*
@@ -535,7 +535,7 @@
  */
 quill_charge()
 {
-    register struct object *tobj;
+    register struct object *tobj = NULL;
     register struct linked_list *item;
 
     /*
--- a/arogue7/fight.c	Tue Aug 11 16:19:04 2015 -0400
+++ b/arogue7/fight.c	Wed Aug 12 15:42:02 2015 -0400
@@ -331,7 +331,7 @@
 bool back_stab;
 {
     register struct stats *att, *def;
-    register char *cp;
+    register char *cp = NULL;
     register int ndice, nsides, nplus, def_arm;
     bool did_hit = FALSE;
     int prop_hplus, prop_dplus;
--- a/arogue7/misc.c	Tue Aug 11 16:19:04 2015 -0400
+++ b/arogue7/misc.c	Wed Aug 12 15:42:02 2015 -0400
@@ -277,7 +277,7 @@
 register struct linked_list *item;
 {
 
-    register struct linked_list *titem;
+    register struct linked_list *titem = NULL;
     register struct object *obj, *tobj;
     bool doit = TRUE;
 
@@ -838,8 +838,8 @@
 use_mm(which)
 int which;
 {
-    register struct object *obj;
-    register struct linked_list *item;
+    register struct object *obj = NULL;
+    register struct linked_list *item = NULL;
     bool cursed, blessed, is_mm;
 
     cursed = FALSE;
--- a/arogue7/move.c	Tue Aug 11 16:19:04 2015 -0400
+++ b/arogue7/move.c	Wed Aug 12 15:42:02 2015 -0400
@@ -46,10 +46,10 @@
 register coord *tc;
 {
     register struct trap *tp;
-    register char ch, *mname;
+    register char ch, *mname = "";
     register bool is_player = (th == &player),
 	          can_see;
-    register struct linked_list *mitem;
+    register struct linked_list *mitem = NULL;
     register struct thing *mp;
 
 
@@ -764,7 +764,7 @@
     register struct room *rp, *orp;
     register char ch;
     struct linked_list *item;
-    register struct thing *tp;
+    register struct thing *tp = NULL;
     coord old_hero;
     register int wasfirstmove, moved, num_hits;
     bool changed=FALSE;	/* Did we switch places with a friendly monster? */
--- a/arogue7/pack.c	Tue Aug 11 16:19:04 2015 -0400
+++ b/arogue7/pack.c	Wed Aug 12 15:42:02 2015 -0400
@@ -34,8 +34,8 @@
 register struct linked_list *item, **packret;
 bool silent;
 {
-    register struct linked_list *ip, *lp, *ap;
-    register struct object *obj, *op;
+    register struct linked_list *ip, *lp = NULL, *ap;
+    register struct object *obj, *op = NULL;
     register bool exact, from_floor;
 
     if (packret != NULL)
@@ -576,7 +576,7 @@
     reg struct linked_list *item;
     reg struct object *obj;
     reg int cnt, pagecnt, ch, och, maxx, curx, confused;
-    struct linked_list *saveitem;
+    struct linked_list *saveitem = NULL;
     char description[2*LINELEN+1];
     char cost[LINELEN/2];
 #ifdef PC7300
--- a/arogue7/passages.c	Tue Aug 11 16:19:04 2015 -0400
+++ b/arogue7/passages.c	Wed Aug 12 15:42:02 2015 -0400
@@ -28,7 +28,7 @@
 
 do_passages()
 {
-    register struct rdes *r1, *r2;
+    register struct rdes *r1, *r2 = NULL;
     register int i, j;
     register int roomcount;
     static struct rdes
@@ -137,7 +137,7 @@
 conn(r1, r2)
 int r1, r2;
 {
-    register struct room *rpf, *rpt;
+    register struct room *rpf, *rpt = NULL;
     register char rmt;
     register int distance, max_diag, offset, i;
     register int rm;
--- a/arogue7/scrolls.c	Tue Aug 11 16:19:04 2015 -0400
+++ b/arogue7/scrolls.c	Wed Aug 12 15:42:02 2015 -0400
@@ -62,7 +62,7 @@
 int flag;
 bool is_scroll;
 {
-    register struct object *obj, *nobj;
+    register struct object *obj = NULL, *nobj;
     register struct linked_list *item, *nitem;
     register int i,j;
     register char ch, nch;
--- a/arogue7/sticks.c	Tue Aug 11 16:19:04 2015 -0400
+++ b/arogue7/sticks.c	Wed Aug 12 15:42:02 2015 -0400
@@ -33,13 +33,13 @@
 int which;
 int flags;
 {
-    register struct linked_list *item;
+    register struct linked_list *item = NULL;
     register struct thing *tp;
     register int y, x, bonus;
     struct linked_list *nitem;
     struct object *nobj;
     bool cursed, blessed, is_player;
-    char *mname;
+    char *mname = "";
 
     cursed = flags & ISCURSED;
     blessed = flags & ISBLESSED;
--- a/arogue7/util.c	Tue Aug 11 16:19:04 2015 -0400
+++ b/arogue7/util.c	Wed Aug 12 15:42:02 2015 -0400
@@ -1006,7 +1006,7 @@
 move_hero(why)
 int why;
 {
-    char *action;
+    char *action = "";
     char which;
     coord c;
 
@@ -1207,7 +1207,7 @@
 tr_name(ch)
 char ch;
 {
-    register char *s;
+    register char *s = "";
 
     switch (ch)
     {
--- a/arogue7/wizard.c	Tue Aug 11 16:19:04 2015 -0400
+++ b/arogue7/wizard.c	Wed Aug 12 15:42:02 2015 -0400
@@ -537,7 +537,7 @@
 
 teleport()
 {
-    register struct room *new_rp, *old_rp = roomin(&hero);
+    register struct room *new_rp = NULL, *old_rp = roomin(&hero);
     register int rm, which;
     coord old;
     bool got_position = FALSE;