diff --git a/src/light.c b/src/light.c index 89a8d8baf..901a72aec 100644 --- a/src/light.c +++ b/src/light.c @@ -1,8 +1,9 @@ -/* NetHack 3.7 light.c $NHDT-Date: 1657918094 2022/07/15 20:48:14 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.57 $ */ +/* NetHack 3.7 light.c $NHDT-Date: 1702680171 2023/12/15 22:42:51 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.66 $ */ /* Copyright (c) Dean Luick, 1994 */ /* NetHack may be freely redistributed. See license for details. */ #include "hack.h" +#include /* * Mobile light sources. @@ -239,6 +240,9 @@ show_transient_light(struct obj *obj, coordxy x, coordxy y) cameraflash = cg.zeroany; /* radius 0 will just light ; cameraflash.a_obj is Null */ ls = new_light_core(x, y, 0, LS_OBJECT, &cameraflash); + /* pacify static analysis; 'ls' is never Null for + new_light_core(,,0,LS_OBJECT,&zeroany) */ + assert(ls != NULL); } else { /* thrown or kicked object which is emitting light; validate its light source to obtain its radius (for monster sightings) */ @@ -248,12 +252,14 @@ show_transient_light(struct obj *obj, coordxy x, coordxy y) if (ls->id.a_obj == obj) break; } - } - if (!ls || (obj && obj->where != OBJ_FREE)) { - impossible("transient light %s %s is not %s?", - obj->lamplit ? "lit" : "unlit", xname(obj), - !ls ? "a light source" : "free"); - return; + assert(obj != NULL); /* necessary condition to get into this 'else' */ + if (!ls || obj->where != OBJ_FREE) { + impossible("transient light %s %s %s not %s?", + obj->lamplit ? "lit" : "unlit", + simpleonames(obj), otense(obj, "are"), + !ls ? "a light source" : "free"); + return; + } } if (obj) /* put lit candle or lamp temporarily on the map */