fix static analyzer complaints for shk.c

This cleans up analyzer feedback in shk.c, based on the set of
warnings specified by hints/MacOS.370 and the lower level hints it
applies, rather than anything specified during periodic 'onefile'
processing.

shk.c is the only file I've analyzed, to try again to figure out
how to suppress the old complaint that has been causing a special
case in Genonefile.  It isn't triggering during my testing but that
might be due to something in use by onefile but not by normal hints.
I'm running ccc-analyzer from llvm-16; I don't know whether that
matches Genonefile.
This commit is contained in:
PatR
2025-01-17 13:20:59 -08:00
parent fc7fdd7f08
commit e48824223f

View File

@@ -120,7 +120,7 @@ staticfn uint8 litter_getpos(uint8 *, coordxy, coordxy, struct monst *);
staticfn void litter_scatter(uint8 *, coordxy, coordxy, struct monst *);
staticfn void litter_newsyms(uint8 *, coordxy, coordxy);
staticfn int repair_damage(struct monst *, struct damage *, boolean);
staticfn void sub_one_frombill(struct obj *, struct monst *);
staticfn void sub_one_frombill(struct obj *, struct monst *) NONNULLPTRS;
staticfn void add_one_tobill(struct obj *, boolean, struct monst *);
staticfn void dropped_container(struct obj *, struct monst *, boolean);
staticfn void add_to_billobjs(struct obj *);
@@ -1731,6 +1731,7 @@ dopay(void)
shkp = next_shkp(shkp->nmon, FALSE))
if (canspotmon(shkp))
break;
assert(shkp != NULL); /* seensk==1 => traversal will spot one shk */
if (shkp != resident && !m_next2u(shkp)) {
pline("%s is not near enough to receive your payment.",
Shknam(shkp));
@@ -2243,9 +2244,8 @@ buy_container(
unsigned boid, boids[BILLSZ];
int i, j, buy, buycount = 0, boidsct = 0;
struct eshk *eshkp = ESHK(shkp);
int bidx = ibill[indx].bidx,
ebillct = eshkp->billct;
struct bill_x *bp = &eshkp->bill_p[bidx];
int ebillct = eshkp->billct;
struct bill_x *bp;
struct obj *otmp, *otop,
*container = ibill[indx].obj;
unsigned unpaidcontainer = container->unpaid;
@@ -3654,6 +3654,7 @@ stolen_container(
/* billable() returns false for objects already on bill */
if ((bp = onbill(otmp, shkp, FALSE)) == 0)
continue;
assert(shkp != NULL); /* onbill() found shkp so it's not Null */
/* this assumes that we're being called by stolen_value()
(or by a recursive call to self on behalf of it) where
the cost of this object is about to be added to shop
@@ -3707,6 +3708,7 @@ stolen_value(
/* things already on the bill yield a not-billable result, so
we need to check bill before deciding that shk doesn't care */
if ((bp = onbill(obj, shkp, FALSE)) != 0) {
assert(shkp != NULL); /* onbill() found shkp so it's not Null */
/* shk does care; take obj off bill to avoid double billing */
billamt = bp->bquan * bp->price;
sub_one_frombill(obj, shkp);
@@ -4461,9 +4463,8 @@ discard_damage_owned_by(struct monst *shkp)
prevdam->next = dam2;
if (dam == svl.level.damagelist)
svl.level.damagelist = dam2;
(void) memset(dam, 0, sizeof(struct damage));
free((genericptr_t) dam);
dam = dam2;
(void) memset(dam, 0, sizeof *dam);
free((genericptr_t) dam), dam = (struct damage *) NULL;
} else {
prevdam = dam;
dam2 = dam->next;