Revert "allow readobjnam arg to be nonnull"

This reverts commit 10f29a9760.
This commit is contained in:
nhmall
2023-12-17 07:20:35 -05:00
parent e6c4838161
commit 3bf2f0daee
5 changed files with 8 additions and 8 deletions

View File

@@ -1156,7 +1156,6 @@ struct const_globals {
extern const struct const_globals cg;
extern struct obj hands_obj;
extern char do_random_str;
#endif /* DECL_H */

View File

@@ -2125,7 +2125,10 @@ extern char *bare_artifactname(struct obj *) NONNULLARG1;
that leads to impossible(), preventing NONNULLARG1 */
extern char *makeplural(const char *) NO_NONNULLS;
extern char *makesingular(const char *) NO_NONNULLS;
extern struct obj *readobjnam(char *, struct obj *) NONNULLARG1;
/* readobjnam() allows a NULL to trigger code path for random; if it
and its caller were modifed to look for/provide a particular address
to use as a trigger instead, it could be declared NONNULLARG1 */
extern struct obj *readobjnam(char *, struct obj *) NO_NONNULLS;
extern int rnd_class(int, int);
/* discover_object() passes NULL arg2 to Japanese_item_name(),
* preventing NONNULLARG2 */

View File

@@ -1069,10 +1069,8 @@ decl_globals_init(void)
gu.urace = urace_init_data;
}
/* fields in 'hands_obj' and contents of 'do_random_str' don't matter,
* just their distinct addresses */
/* fields in 'hands_obj' don't matter, just its distinct address */
struct obj hands_obj = DUMMY;
char do_random_str = '\0';
/* gcc 12.2's static analyzer thinks that some fields of gc.context.victual
are uninitialized when compiling 'bite(eat.c)' but that's impossible;

View File

@@ -4576,7 +4576,7 @@ readobjnam_postparse3(struct _readobjnam_data *d)
/*
* Return something wished for. Specifying &do_random_str for
* Return something wished for. Specifying a null pointer for
* the user request string results in a random object. Otherwise,
* if asking explicitly for "nothing" (or "nil") return no_wish;
* if not an object return &hands_obj; if an error (no matching object),
@@ -4588,7 +4588,7 @@ readobjnam(char *bp, struct obj *no_wish)
struct _readobjnam_data d;
readobjnam_init(bp, &d);
if (bp == &do_random_str)
if (!bp)
goto any;
/* first, remove extra whitespace they may have typed */

View File

@@ -6024,7 +6024,7 @@ makewish(void)
if (++tries < MAXWISHTRY)
goto retry;
pline1(thats_enough_tries);
otmp = readobjnam(&do_random_str, (struct obj *) 0);
otmp = readobjnam((char *) 0, (struct obj *) 0);
if (!otmp)
return; /* for safety; should never happen */
} else if (otmp == &nothing) {