static analyzer bit for wield.c
src/wield.c(254): warning: Dereferencing NULL pointer 'wep'.
See line 190 for an earlier location where this can occur
This seems to be a case where an unnecessary null test (A) caused
the analyzer to call into question whether or not wep
is null at (B):
if (!wep) {
} else if (wep->otyp == CORPSE && cant_wield_corpse(wep)) {
} else if (uarms && bimanual(wep)) {
} else if (!retouch_object(&wep, FALSE)) {
} else {
/* Weapon WILL be wielded after this point */
if (will_weld(wep)) {
} else {
}
if (was_twoweap && !u.twoweap && flags.verbose) {
}
/* KMH -- Talking artifacts are finally implemented */
A ==> if (wep && wep->oartifact) {
}
if (artifact_light(wep) && !wep->lamplit) {
}
B ==> if (wep->unpaid) {
}
}
Removing the extraneous wep test from (A) resolves the complaint.
This commit is contained in:
@@ -232,7 +232,7 @@ ready_weapon(struct obj *wep)
|
||||
}
|
||||
|
||||
/* KMH -- Talking artifacts are finally implemented */
|
||||
if (wep && wep->oartifact) {
|
||||
if (wep->oartifact) {
|
||||
res |= arti_speak(wep); /* sets ECMD_TIME bit if artifact speaks */
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user