mirror of
https://git.tartarus.org/simon/putty.git
synced 2025-07-01 03:22:48 -05:00
Replace assert(false) with an unreachable() macro.
Taking a leaf out of the LLVM code base: this macro still includes an assert(false) so that the message will show up in a typical build, but it follows it up with a call to a function explicitly marked as no- return. So this ought to do a better job of convincing compilers that once a code path hits this function it _really doesn't_ have to still faff about with making up a bogus return value or filling in a variable that 'might be used uninitialised' in the following code that won't be reached anyway. I've gone through the existing code looking for the assert(false) / assert(0) idiom and replaced all the ones I found with the new macro, which also meant I could remove a few pointless return statements and variable initialisations that I'd already had to put in to placate compiler front ends.
This commit is contained in:
@ -1145,7 +1145,7 @@ static void update_mouse_pointer(void)
|
||||
force_visible = true;
|
||||
break;
|
||||
default:
|
||||
assert(0);
|
||||
unreachable("Bad busy_status");
|
||||
}
|
||||
{
|
||||
HCURSOR cursor = LoadCursor(NULL, curstype);
|
||||
|
@ -784,7 +784,7 @@ void sk_addrcopy(SockAddr *addr, char *buf)
|
||||
memcpy(buf, &((struct sockaddr_in6 *)step.ai->ai_addr)->sin6_addr,
|
||||
sizeof(struct in6_addr));
|
||||
else
|
||||
assert(false);
|
||||
unreachable("bad address family in sk_addrcopy");
|
||||
} else
|
||||
#endif
|
||||
if (family == AF_INET) {
|
||||
|
@ -61,7 +61,9 @@ void nonfatal(const char *fmt, ...)
|
||||
}
|
||||
|
||||
/* Stubs needed to link against misc.c */
|
||||
void queue_idempotent_callback(IdempotentCallback *ic) { assert(0); }
|
||||
void queue_idempotent_callback(IdempotentCallback *ic) {
|
||||
unreachable("No callbacks in this application");
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
* Progress report code. This is really horrible :-)
|
||||
|
@ -86,7 +86,9 @@ void modalfatalbox(const char *fmt, ...)
|
||||
}
|
||||
|
||||
/* Stubs needed to link against misc.c */
|
||||
void queue_idempotent_callback(IdempotentCallback *ic) { assert(0); }
|
||||
void queue_idempotent_callback(IdempotentCallback *ic) {
|
||||
unreachable("No callbacks in this application");
|
||||
}
|
||||
|
||||
static bool has_security;
|
||||
|
||||
|
@ -27,7 +27,7 @@ bool agent_exists(void)
|
||||
|
||||
void agent_cancel_query(agent_pending_query *q)
|
||||
{
|
||||
assert(0 && "Windows agent queries are never asynchronous!");
|
||||
unreachable("Windows agent queries are never asynchronous!");
|
||||
}
|
||||
|
||||
agent_pending_query *agent_query(
|
||||
|
Reference in New Issue
Block a user