mirror of
https://git.tartarus.org/simon/putty.git
synced 2025-07-03 12:32:47 -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:
@ -304,14 +304,12 @@ SshChannel *ssh2_session_open(ConnectionLayer *cl, Channel *chan)
|
||||
SshChannel *ssh2_serverside_x11_open(
|
||||
ConnectionLayer *cl, Channel *chan, const SocketPeerInfo *pi)
|
||||
{
|
||||
assert(false && "Should never be called in the client");
|
||||
return 0; /* placate optimiser */
|
||||
unreachable("Should never be called in the client");
|
||||
}
|
||||
|
||||
SshChannel *ssh2_serverside_agent_open(ConnectionLayer *cl, Channel *chan)
|
||||
{
|
||||
assert(false && "Should never be called in the client");
|
||||
return 0; /* placate optimiser */
|
||||
unreachable("Should never be called in the client");
|
||||
}
|
||||
|
||||
static void ssh2_channel_response(
|
||||
@ -358,19 +356,19 @@ bool ssh2channel_start_subsystem(
|
||||
|
||||
void ssh2channel_send_exit_status(SshChannel *sc, int status)
|
||||
{
|
||||
assert(false && "Should never be called in the client");
|
||||
unreachable("Should never be called in the client");
|
||||
}
|
||||
|
||||
void ssh2channel_send_exit_signal(
|
||||
SshChannel *sc, ptrlen signame, bool core_dumped, ptrlen msg)
|
||||
{
|
||||
assert(false && "Should never be called in the client");
|
||||
unreachable("Should never be called in the client");
|
||||
}
|
||||
|
||||
void ssh2channel_send_exit_signal_numeric(
|
||||
SshChannel *sc, int signum, bool core_dumped, ptrlen msg)
|
||||
{
|
||||
assert(false && "Should never be called in the client");
|
||||
unreachable("Should never be called in the client");
|
||||
}
|
||||
|
||||
void ssh2channel_request_x11_forwarding(
|
||||
|
Reference in New Issue
Block a user