warning suppression

Fix a couple of the clang static analyzer's warnings.

muse.c has some reformatting.  zap.c wasn't triggering any warning about
possible null pointer, but using MON_AT() to maybe avoid m_at() is not
a useful optimization since m_at() is a macro which starts out by using
MON_AT() itself.
This commit is contained in:
PatR
2015-11-19 18:49:50 -08:00
parent 7d23420314
commit a2a567737e
3 changed files with 44 additions and 42 deletions
+18 -21
View File
@@ -1,4 +1,4 @@
/* NetHack 3.6 muse.c $NHDT-Date: 1445556877 2015/10/22 23:34:37 $ $NHDT-Branch: master $:$NHDT-Revision: 1.66 $ */
/* NetHack 3.6 muse.c $NHDT-Date: 1447987786 2015/11/20 02:49:46 $ $NHDT-Branch: master $:$NHDT-Revision: 1.68 $ */
/* Copyright (C) 1990 by Ken Arromdee */
/* NetHack may be freely redistributed. See license for details. */
@@ -24,17 +24,17 @@ STATIC_DCL void FDECL(mzapmsg, (struct monst *, struct obj *, BOOLEAN_P));
STATIC_DCL void FDECL(mreadmsg, (struct monst *, struct obj *));
STATIC_DCL void FDECL(mquaffmsg, (struct monst *, struct obj *));
STATIC_PTR int FDECL(mbhitm, (struct monst *, struct obj *));
STATIC_DCL void FDECL(mbhit,
(struct monst *, int, int FDECL((*), (MONST_P, OBJ_P)),
STATIC_DCL void FDECL(mbhit, (struct monst *, int,
int FDECL((*), (MONST_P, OBJ_P)),
int FDECL((*), (OBJ_P, OBJ_P)), struct obj *));
STATIC_DCL void FDECL(you_aggravate, (struct monst *));
STATIC_DCL void FDECL(mon_consume_unstone,
(struct monst *, struct obj *, BOOLEAN_P, BOOLEAN_P));
STATIC_DCL boolean
FDECL(cures_stoning, (struct monst *, struct obj *, BOOLEAN_P));
STATIC_DCL void FDECL(mon_consume_unstone, (struct monst *, struct obj *,
BOOLEAN_P, BOOLEAN_P));
STATIC_DCL boolean FDECL(cures_stoning, (struct monst *, struct obj *,
BOOLEAN_P));
STATIC_DCL boolean FDECL(mcould_eat_tin, (struct monst *));
STATIC_DCL boolean
FDECL(muse_unslime, (struct monst *, struct obj *, BOOLEAN_P));
STATIC_DCL boolean FDECL(muse_unslime, (struct monst *, struct obj *,
BOOLEAN_P));
STATIC_DCL int FDECL(cures_sliming, (struct monst *, struct obj *));
STATIC_DCL boolean FDECL(green_mon, (struct monst *));
@@ -48,17 +48,16 @@ static struct musable {
*/
} m;
static int trapx, trapy;
static boolean zap_oseen;
/* for wands which use mbhitm and are zapped at players. We usually
* want an oseen local to the function, but this is impossible since the
* function mbhitm has to be compatible with the normal zap routines,
* and those routines don't remember who zapped the wand.
*/
static boolean zap_oseen; /* for wands which use mbhitm and are zapped at
* players. We usually want an oseen local to
* the function, but this is impossible since the
* function mbhitm has to be compatible with the
* normal zap routines, and those routines don't
* remember who zapped the wand. */
/* Any preliminary checks which may result in the monster being unable to use
* the item. Returns 0 if nothing happened, 2 if the monster can't do
* anything
* (i.e. it teleported) and 1 if it's dead.
* anything (i.e. it teleported) and 1 if it's dead.
*/
STATIC_OVL int
precheck(mon, obj)
@@ -96,8 +95,7 @@ struct obj *obj;
mon_nam(mon),
Hallucination ? rndmonnam(NULL)
: (const char *) "ghost");
pline(
"%s is frightened to death, and unable to move.",
pline("%s is frightened to death, and unable to move.",
Monnam(mon));
}
paralyze_monst(mon, 3);
@@ -1312,8 +1310,7 @@ struct obj *obj; /* 2nd arg to fhitm/fhito */
if (bhitpos.x == u.ux && bhitpos.y == u.uy) {
(*fhitm)(&youmonst, obj);
range -= 3;
} else if (MON_AT(bhitpos.x, bhitpos.y)) {
mtmp = m_at(bhitpos.x, bhitpos.y);
} else if ((mtmp = m_at(bhitpos.x, bhitpos.y)) != 0) {
if (cansee(bhitpos.x, bhitpos.y) && !canspotmon(mtmp))
map_invisible(bhitpos.x, bhitpos.y);
(*fhitm)(mtmp, obj);
+7 -1
View File
@@ -1,4 +1,4 @@
/* NetHack 3.6 read.c $NHDT-Date: 1446854233 2015/11/06 23:57:13 $ $NHDT-Branch: master $:$NHDT-Revision: 1.121 $ */
/* NetHack 3.6 read.c $NHDT-Date: 1447987787 2015/11/20 02:49:47 $ $NHDT-Branch: master $:$NHDT-Revision: 1.123 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/* NetHack may be freely redistributed. See license for details. */
@@ -739,11 +739,13 @@ int percent;
return;
}
indices[0] = 0; /* lint suppression */
for (count = 0, i = 1; i < NUM_OBJECTS; i++)
if (OBJ_DESCR(objects[i])
&& (objects[i].oc_name_known || objects[i].oc_uname))
indices[count++] = i;
if (count > 0) {
randomize(indices, count);
/* forget first % of randomized indices */
@@ -751,6 +753,7 @@ int percent;
for (i = 0; i < count; i++)
forget_single_object(indices[i]);
}
}
/* Forget some or all of map (depends on parameters). */
void
@@ -815,6 +818,7 @@ int percent;
* shift the forgetting elsewhere by fiddling with percent
* instead of forgetting fewer levels.
*/
indices[0] = 0; /* lint suppression */
for (count = 0, i = 0; i <= maxl; i++)
if ((level_info[i].flags & VISITED)
&& !(level_info[i].flags & FORGOTTEN) && i != this_lev) {
@@ -827,6 +831,7 @@ int percent;
if (percent > 100)
percent = 100;
if (count > 0) {
randomize(indices, count);
/* forget first % of randomized indices */
@@ -836,6 +841,7 @@ int percent;
forget_mapseen(indices[i]);
}
}
}
/*
* Forget some things (e.g. after reading a scroll of amnesia). When called,
+2 -3
View File
@@ -1,4 +1,4 @@
/* NetHack 3.6 zap.c $NHDT-Date: 1447475947 2015/11/14 04:39:07 $ $NHDT-Branch: master $:$NHDT-Revision: 1.235 $ */
/* NetHack 3.6 zap.c $NHDT-Date: 1447987787 2015/11/20 02:49:47 $ $NHDT-Branch: master $:$NHDT-Revision: 1.236 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/* NetHack may be freely redistributed. See license for details. */
@@ -3322,8 +3322,7 @@ int dx, dy;
dy = ydir[i];
bhitpos.x += dx;
bhitpos.y += dy;
if (MON_AT(bhitpos.x, bhitpos.y)) {
mtmp = m_at(bhitpos.x, bhitpos.y);
if ((mtmp = m_at(bhitpos.x, bhitpos.y)) != 0) {
m_respond(mtmp);
tmp_at(DISP_END, 0);
return mtmp;