move null-check on tin_details()
Move null-check of obj and buf before their first use.
This commit is contained in:
40
src/eat.c
40
src/eat.c
@@ -1237,30 +1237,32 @@ void
|
|||||||
tin_details(struct obj *obj, int mnum, char *buf)
|
tin_details(struct obj *obj, int mnum, char *buf)
|
||||||
{
|
{
|
||||||
char buf2[BUFSZ];
|
char buf2[BUFSZ];
|
||||||
|
|
||||||
|
if (!obj || !buf)
|
||||||
|
return;
|
||||||
|
|
||||||
int r = tin_variety(obj, TRUE);
|
int r = tin_variety(obj, TRUE);
|
||||||
|
|
||||||
if (obj && buf) {
|
if (r == SPINACH_TIN)
|
||||||
if (r == SPINACH_TIN)
|
Strcat(buf, " of spinach");
|
||||||
Strcat(buf, " of spinach");
|
else if (mnum == NON_PM)
|
||||||
else if (mnum == NON_PM)
|
Strcpy(buf, "empty tin");
|
||||||
Strcpy(buf, "empty tin");
|
else {
|
||||||
else {
|
if ((obj->cknown || iflags.override_ID) && obj->spe < 0) {
|
||||||
if ((obj->cknown || iflags.override_ID) && obj->spe < 0) {
|
if (r == ROTTEN_TIN || r == HOMEMADE_TIN) {
|
||||||
if (r == ROTTEN_TIN || r == HOMEMADE_TIN) {
|
/* put these before the word tin */
|
||||||
/* put these before the word tin */
|
Sprintf(buf2, "%s %s of ", tintxts[r].txt, buf);
|
||||||
Sprintf(buf2, "%s %s of ", tintxts[r].txt, buf);
|
Strcpy(buf, buf2);
|
||||||
Strcpy(buf, buf2);
|
|
||||||
} else {
|
|
||||||
Sprintf(eos(buf), " of %s ", tintxts[r].txt);
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
Strcpy(eos(buf), " of ");
|
Sprintf(eos(buf), " of %s ", tintxts[r].txt);
|
||||||
}
|
}
|
||||||
if (vegetarian(&mons[mnum]))
|
} else {
|
||||||
Sprintf(eos(buf), "%s", mons[mnum].pmnames[NEUTRAL]);
|
Strcpy(eos(buf), " of ");
|
||||||
else
|
|
||||||
Sprintf(eos(buf), "%s meat", mons[mnum].pmnames[NEUTRAL]);
|
|
||||||
}
|
}
|
||||||
|
if (vegetarian(&mons[mnum]))
|
||||||
|
Sprintf(eos(buf), "%s", mons[mnum].pmnames[NEUTRAL]);
|
||||||
|
else
|
||||||
|
Sprintf(eos(buf), "%s meat", mons[mnum].pmnames[NEUTRAL]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user