From: PatR Date: Tue, 11 May 2021 22:59:19 +0000 (-0700) Subject: fix saddle sanity check code X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=25b1baed84be3a53f174a302efd2e9db4d2730a6;p=nethack fix saddle sanity check code Fix some bad code for "no saddle" caused by careless editing that changed (uncomitted) char *ns = 0; if (foo) ns = "foo"; else if (bar) ns = "bar"; by splicing lines together and accidentally ended up with char *ns; ns = foo ? ns = "foo" : bar ? ns = "bar" : 0; when char *ns; ns = foo ? "foo" : bar ? "bar" : 0; was intended. I'm a bit surprised that the intermediate form without any parentheses around 'ns = "bar"' compiles at all. C99? I don't think that it would have if it had been processed as C90 or pre-ANSI. --- diff --git a/src/mon.c b/src/mon.c index 0aef9dda5..1297f5d28 100644 --- a/src/mon.c +++ b/src/mon.c @@ -111,8 +111,8 @@ sanity_check_single_mon( if (mtmp == u.usteed) { const char *ns, *nt = !mtmp->mtame ? "not tame" : 0; - ns = !m_carrying(mtmp, SADDLE) ? ns = "no saddle" - : !which_armor(mtmp, W_SADDLE) ? ns = "saddle not worn" + ns = !m_carrying(mtmp, SADDLE) ? "no saddle" + : !which_armor(mtmp, W_SADDLE) ? "saddle not worn" : 0; if (ns || nt) impossible("steed: %s%s%s (%s)",