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