From 746d00d170ca698df885425ad050945a5848bd64 Mon Sep 17 00:00:00 2001 From: nhmall Date: Fri, 22 Dec 2023 14:35:59 -0500 Subject: [PATCH] assess wizard.c static functions for nonnull No nonnull return attributes were appropriate for wizard.c section of include/extern.h either. --- src/wizard.c | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/src/wizard.c b/src/wizard.c index 26d27a782..816887242 100644 --- a/src/wizard.c +++ b/src/wizard.c @@ -11,12 +11,15 @@ #include "hack.h" static short which_arti(int); -static boolean mon_has_arti(struct monst *, short); -static struct monst *other_mon_has_arti(struct monst *, short); -static struct obj *on_ground(short); +static boolean mon_has_arti(struct monst *, short) NONNULLARG1; +/* other_mon_has_arti() won't blow up if passed a NULL monst, + * but its caller target_on() passes it a nonnull monst; + * it may return a NULL monst pointer */ +static struct monst *other_mon_has_arti(struct monst *, short) NONNULLARG1; +static struct obj *on_ground(short); /* might return NULL obj pointer */ static boolean you_have(int); -static unsigned long target_on(int, struct monst *); -static unsigned long strategy(struct monst *); +static unsigned long target_on(int, struct monst *) NONNULLARG2; +static unsigned long strategy(struct monst *) NONNULLARG1; /* adding more neutral creatures will tend to reduce the number of monsters summoned by nasty(); adding more lawful creatures will reduce the number @@ -176,6 +179,10 @@ mon_has_arti(struct monst *mtmp, short otyp) return 0; } +/* + * Returns some monster other than mtmp that + * has arifact, or NULL monst pointer. + */ static struct monst * other_mon_has_arti(struct monst *mtmp, short otyp) { @@ -190,6 +197,10 @@ other_mon_has_arti(struct monst *mtmp, short otyp) return (struct monst *) 0; } +/* + * Returns obj of type specified if there is one + * on the ground, otherwise returns NULL obj pointer. + */ static struct obj * on_ground(short otyp) {