mirror of
https://git.tartarus.org/simon/putty.git
synced 2025-07-14 17:47:33 -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:
@ -342,12 +342,12 @@ static bool zombiechan_want_close(Channel *chan, bool sent_eof, bool rcvd_eof)
|
||||
|
||||
void chan_remotely_opened_confirmation(Channel *chan)
|
||||
{
|
||||
assert(0 && "this channel type should never receive OPEN_CONFIRMATION");
|
||||
unreachable("this channel type should never receive OPEN_CONFIRMATION");
|
||||
}
|
||||
|
||||
void chan_remotely_opened_failure(Channel *chan, const char *errtext)
|
||||
{
|
||||
assert(0 && "this channel type should never receive OPEN_FAILURE");
|
||||
unreachable("this channel type should never receive OPEN_FAILURE");
|
||||
}
|
||||
|
||||
bool chan_default_want_close(
|
||||
@ -435,7 +435,7 @@ bool chan_no_change_window_size(
|
||||
|
||||
void chan_no_request_response(Channel *chan, bool success)
|
||||
{
|
||||
assert(0 && "this channel type should never send a want-reply request");
|
||||
unreachable("this channel type should never send a want-reply request");
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
@ -556,7 +556,7 @@ struct ssh_ttymodes get_ttymodes_from_conf(Seat *seat, Conf *conf)
|
||||
ival = (atoi(sval) != 0);
|
||||
break;
|
||||
default:
|
||||
assert(0 && "Bad mode->type");
|
||||
unreachable("Bad mode->type");
|
||||
}
|
||||
|
||||
modes.have_mode[mode->opcode] = true;
|
||||
|
Reference in New Issue
Block a user