gcc -fanalyze vs artifact.c
This should pacify the analyzer. get_artifact(obj) expands to code which checks whether obj is Null. untouchable() knows that it will always be non-Null so didn't perform any comparable test and the analyzer complained. Using get_artifact() before the 'beingworn' assignment instead of after would just have shifted the complaint to the assignment's use of obj->owornmask. Adding a test for Null to that expression should eliminate the complaint but I haven't verified that.
This commit is contained in:
+17
-11
@@ -2304,22 +2304,27 @@ retouch_object(
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* an item which is worn/wielded or an artifact which conveys
|
/* hero has changed form or alignment; an item which is worn/wielded
|
||||||
something via being carried or which has an #invoke effect
|
or an artifact which conveys something via being carried or which
|
||||||
currently in operation undergoes a touch test; if it fails,
|
has an #invoke effect currently in operation undergoes a touch test;
|
||||||
it will be unworn/unwielded and revoked but not dropped */
|
if it fails, it will be unworn/unwielded and maybe dropped */
|
||||||
static boolean
|
static boolean
|
||||||
untouchable(struct obj *obj, boolean drop_untouchable)
|
untouchable(
|
||||||
|
struct obj *obj, /* object to test; in invent or is steed's saddle */
|
||||||
|
boolean drop_untouchable) /* whether to drop it if it can't be touched */
|
||||||
{
|
{
|
||||||
struct artifact *art;
|
struct artifact *art;
|
||||||
boolean beingworn, carryeffect, invoked;
|
boolean beingworn, carryeffect, invoked;
|
||||||
long wearmask = ~(W_QUIVER | (u.twoweap ? 0L : W_SWAPWEP) | W_BALL);
|
long wearmask = ~(W_QUIVER | (u.twoweap ? 0L : W_SWAPWEP) | W_BALL);
|
||||||
|
|
||||||
beingworn = ((obj->owornmask & wearmask) != 0L
|
beingworn = (obj /* never Null; this pacifies static analysis when
|
||||||
/* some items in use don't have any wornmask setting */
|
* the get_artifact() macro tests 'obj' for Null */
|
||||||
|| (obj->oclass == TOOL_CLASS
|
&& ((obj->owornmask & wearmask) != 0L
|
||||||
&& (obj->lamplit || (obj->otyp == LEASH && obj->leashmon)
|
/* some items in use don't have any wornmask setting */
|
||||||
|| (Is_container(obj) && Has_contents(obj)))));
|
|| (obj->oclass == TOOL_CLASS
|
||||||
|
&& (obj->lamplit
|
||||||
|
|| (obj->otyp == LEASH && obj->leashmon)
|
||||||
|
|| (Is_container(obj) && Has_contents(obj))))));
|
||||||
|
|
||||||
if ((art = get_artifact(obj)) != 0) {
|
if ((art = get_artifact(obj)) != 0) {
|
||||||
carryeffect = (art->cary.adtyp || art->cspfx);
|
carryeffect = (art->cary.adtyp || art->cspfx);
|
||||||
@@ -2346,7 +2351,8 @@ untouchable(struct obj *obj, boolean drop_untouchable)
|
|||||||
|
|
||||||
/* check all items currently in use (mostly worn) for touchability */
|
/* check all items currently in use (mostly worn) for touchability */
|
||||||
void
|
void
|
||||||
retouch_equipment(int dropflag) /* 0==don't drop, 1==drop all, 2==drop weapon */
|
retouch_equipment(
|
||||||
|
int dropflag) /* 0==don't drop, 1==drop all, 2==drop weapon */
|
||||||
{
|
{
|
||||||
static int nesting = 0; /* recursion control */
|
static int nesting = 0; /* recursion control */
|
||||||
struct obj *obj;
|
struct obj *obj;
|
||||||
|
|||||||
Reference in New Issue
Block a user