1
0
mirror of https://git.tartarus.org/simon/putty.git synced 2025-07-01 03:22:48 -05:00

Convert a few more universal asserts to unreachable().

When I introduced the unreachable() macro in commit 0112936ef, I
searched the source code for assert(0) and assert(false), together
with their variant form assert(0 && "explanatory text"). But I didn't
search for assert(!"explanatory text"), which is the form I used to
use before finding that assert(0 && "text") seemed to be preferred in
other code bases.

So, here's a belated replacement of all the assert(!"stuff") macros
with further instances of unreachable().
This commit is contained in:
Simon Tatham
2019-09-09 19:07:55 +01:00
parent 5d718ef64b
commit 00112549bf
7 changed files with 20 additions and 40 deletions

View File

@ -1658,9 +1658,7 @@ void winctrl_layout(struct dlgparam *dp, struct winctrls *wc,
sfree(escaped);
break;
default:
assert(!"Can't happen");
num_ids = 0; /* placate gcc */
break;
unreachable("bad control type in winctrl_layout");
}
/*
@ -2096,8 +2094,7 @@ int dlg_radiobutton_get(union control *ctrl, dlgparam *dp)
for (i = 0; i < c->ctrl->radio.nbuttons; i++)
if (IsDlgButtonChecked(dp->hwnd, c->base_id + 1 + i))
return i;
assert(!"No radio button was checked?!");
return 0;
unreachable("no radio button was checked");
}
void dlg_checkbox_set(union control *ctrl, dlgparam *dp, bool checked)
@ -2286,8 +2283,7 @@ void dlg_label_change(union control *ctrl, dlgparam *dp, char const *text)
id = c->base_id;
break;
default:
assert(!"Can't happen");
break;
unreachable("bad control type in label_change");
}
if (escaped) {
SetDlgItemText(dp->hwnd, id, escaped);

View File

@ -1119,14 +1119,10 @@ void spawn_cmd(const char *cmdline, const char *args, int show)
}
}
/*
* This is a can't-happen stub, since Pageant never makes
* asynchronous agent requests.
*/
void agent_schedule_callback(void (*callback)(void *, void *, int),
void *callback_ctx, void *data, int len)
{
assert(!"We shouldn't get here");
unreachable("all Pageant's own agent requests should be synchronous");
}
void cleanup_exit(int code)