Fix some warnings from clang's static code analyzer
This commit is contained in:
@@ -73,7 +73,7 @@
|
||||
* canseemon() or canspotmon() which already check that.
|
||||
*/
|
||||
#define see_with_infrared(mon) \
|
||||
(!Blind && Infravision && infravisible(mon->data) \
|
||||
(!Blind && Infravision && mon && infravisible(mon->data) \
|
||||
&& couldsee(mon->mx, mon->my))
|
||||
|
||||
/*
|
||||
|
||||
@@ -2036,8 +2036,8 @@ boolean quietly;
|
||||
You("don't have enough room in here.");
|
||||
return FALSE;
|
||||
}
|
||||
x = cc->x;
|
||||
y = cc->y;
|
||||
x = cc ? cc->x : u.ux;
|
||||
y = cc ? cc->y : u.uy;
|
||||
if (!isok(x, y)) {
|
||||
if (!quietly)
|
||||
You("cannot put the figurine there.");
|
||||
|
||||
@@ -1404,7 +1404,10 @@ arti_invoke(obj)
|
||||
struct obj *obj;
|
||||
{
|
||||
register const struct artifact *oart = get_artifact(obj);
|
||||
|
||||
if (!obj) {
|
||||
impossible("arti_invoke without obj");
|
||||
return 0;
|
||||
}
|
||||
if (!oart || !oart->inv_prop) {
|
||||
if (obj->otyp == CRYSTAL_BALL)
|
||||
use_crystal_ball(&obj);
|
||||
|
||||
@@ -385,7 +385,6 @@ extcmd_via_menu()
|
||||
biggest = 0;
|
||||
while (!ret) {
|
||||
i = n = 0;
|
||||
accelerator = 0;
|
||||
any = zeroany;
|
||||
/* populate choices */
|
||||
for (efp = extcmdlist; efp->ef_txt; efp++) {
|
||||
@@ -421,7 +420,7 @@ extcmd_via_menu()
|
||||
/* otherwise... */
|
||||
win = create_nhwindow(NHW_MENU);
|
||||
start_menu(win);
|
||||
prevaccelerator = 0;
|
||||
accelerator = prevaccelerator = 0;
|
||||
acount = 0;
|
||||
for (i = 0; choices[i]; ++i) {
|
||||
accelerator = choices[i]->ef_txt[matchlevel];
|
||||
@@ -1769,7 +1768,7 @@ int final;
|
||||
/* when mounted, Wounded_legs applies to steed rather than to
|
||||
hero; we only report steed's wounded legs in wizard mode */
|
||||
if (u.usteed) { /* not `Riding' here */
|
||||
if (wizard) {
|
||||
if (wizard && steedname) {
|
||||
Strcpy(buf, steedname);
|
||||
*buf = highc(*buf);
|
||||
enl_msg(buf, " has", " had", " wounded legs", "");
|
||||
|
||||
@@ -388,7 +388,7 @@ const char *verb;
|
||||
static char wholebuf[80];
|
||||
|
||||
Strcpy(wholebuf, is_u(etmp) ? "You" : Monnam(etmp->emon));
|
||||
if (!*verb)
|
||||
if (!verb || !*verb)
|
||||
return wholebuf;
|
||||
Strcat(wholebuf, " ");
|
||||
if (is_u(etmp))
|
||||
|
||||
@@ -1123,6 +1123,10 @@ register struct obj *otmp;
|
||||
{
|
||||
boolean was_blind = Blind, changed = FALSE;
|
||||
|
||||
if (!otmp) {
|
||||
impossible("Blindf_off without otmp");
|
||||
return;
|
||||
}
|
||||
context.takeoff.mask &= ~W_TOOL;
|
||||
setworn((struct obj *) 0, otmp->owornmask);
|
||||
off_msg(otmp);
|
||||
|
||||
@@ -271,7 +271,10 @@ STATIC_OVL void
|
||||
recalc_wt()
|
||||
{
|
||||
struct obj *piece = context.victual.piece;
|
||||
|
||||
if (!piece) {
|
||||
impossible("recalc_wt without piece");
|
||||
return;
|
||||
}
|
||||
debugpline1("Old weight = %d", piece->owt);
|
||||
debugpline2("Used time = %d, Req'd time = %d", context.victual.usedtime,
|
||||
context.victual.reqtime);
|
||||
|
||||
@@ -627,7 +627,7 @@ boolean taken;
|
||||
{
|
||||
char c = 0, defquery;
|
||||
char qbuf[QBUFSZ];
|
||||
boolean ask;
|
||||
boolean ask = FALSE;
|
||||
|
||||
if (invent && !done_stopprint) {
|
||||
if (taken)
|
||||
|
||||
@@ -64,8 +64,10 @@ lock_action()
|
||||
return actions[3]; /* same as lock_pick */
|
||||
else if (xlock.door)
|
||||
return actions[0]; /* "unlocking the door" */
|
||||
else
|
||||
else if (xlock.box)
|
||||
return xlock.box->otyp == CHEST ? actions[1] : actions[2];
|
||||
else
|
||||
return actions[3];
|
||||
}
|
||||
|
||||
/* try to open/close a lock */
|
||||
|
||||
@@ -391,6 +391,8 @@ unsigned corpseflags;
|
||||
}
|
||||
/* All special cases should precede the G_NOCORPSE check */
|
||||
|
||||
if (!obj) return NULL;
|
||||
|
||||
/* if polymorph or undead turning has killed this monster,
|
||||
prevent the same attack beam from hitting its corpse */
|
||||
if (context.bypasses)
|
||||
|
||||
@@ -797,7 +797,7 @@ gcrownu()
|
||||
case A_NEUTRAL:
|
||||
if (class_gift != STRANGE_OBJECT) {
|
||||
; /* already got bonus above */
|
||||
} else if (in_hand) {
|
||||
} else if (obj && in_hand) {
|
||||
Your("%s goes snicker-snack!", xname(obj));
|
||||
obj->dknown = TRUE;
|
||||
} else if (!already_exists) {
|
||||
@@ -819,7 +819,7 @@ gcrownu()
|
||||
Sprintf(swordbuf, "%s sword", hcolor(NH_BLACK));
|
||||
if (class_gift != STRANGE_OBJECT) {
|
||||
; /* already got bonus above */
|
||||
} else if (in_hand) {
|
||||
} else if (obj && in_hand) {
|
||||
Your("%s hums ominously!", swordbuf);
|
||||
obj->dknown = TRUE;
|
||||
} else if (!already_exists) {
|
||||
|
||||
@@ -976,6 +976,9 @@ packed_coord pos;
|
||||
schar try_x, try_y;
|
||||
register int trycnt = 0;
|
||||
|
||||
if (!x || !y)
|
||||
panic("get_free_room_loc: x or y is null");
|
||||
|
||||
get_location_coord(&try_x, &try_y, DRY, croom, pos);
|
||||
if (levl[try_x][try_y].typ != ROOM) {
|
||||
do {
|
||||
|
||||
@@ -3764,7 +3764,7 @@ STATIC_OVL void
|
||||
move_into_trap(ttmp)
|
||||
struct trap *ttmp;
|
||||
{
|
||||
int bc;
|
||||
int bc = 0;
|
||||
xchar x = ttmp->tx, y = ttmp->ty, bx, by, cx, cy;
|
||||
boolean unused;
|
||||
|
||||
|
||||
@@ -959,7 +959,7 @@ int otyp;
|
||||
break;
|
||||
}
|
||||
|
||||
while (skills->skill != P_NONE) {
|
||||
while (skills && skills->skill != P_NONE) {
|
||||
if (skills->skill == this_skill)
|
||||
return FALSE;
|
||||
++skills;
|
||||
|
||||
Reference in New Issue
Block a user