mirror of
https://git.tartarus.org/simon/putty.git
synced 2025-01-09 17:38:00 +00: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:
parent
5d718ef64b
commit
00112549bf
6
pscp.c
6
pscp.c
@ -127,14 +127,10 @@ static void tell_user(FILE *stream, const char *fmt, ...)
|
||||
sfree(str2);
|
||||
}
|
||||
|
||||
/*
|
||||
* In pscp, all agent requests should be synchronous, so this is a
|
||||
* never-called stub.
|
||||
*/
|
||||
void agent_schedule_callback(void (*callback)(void *, void *, int),
|
||||
void *callback_ctx, void *data, int len)
|
||||
{
|
||||
assert(!"We shouldn't be here");
|
||||
unreachable("all PSCP agent requests should be synchronous");
|
||||
}
|
||||
|
||||
/*
|
||||
|
6
psftp.c
6
psftp.c
@ -2428,14 +2428,10 @@ static bool verbose = false;
|
||||
|
||||
void ldisc_echoedit_update(Ldisc *ldisc) { }
|
||||
|
||||
/*
|
||||
* In psftp, all agent requests should be synchronous, so this is a
|
||||
* never-called stub.
|
||||
*/
|
||||
void agent_schedule_callback(void (*callback)(void *, void *, int),
|
||||
void *callback_ctx, void *data, int len)
|
||||
{
|
||||
assert(!"We shouldn't be here");
|
||||
unreachable("all PSFTP agent requests should be synchronous");
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -314,8 +314,8 @@ static struct kexinit_algorithm *ssh2_kexinit_addalg(struct kexinit_algorithm
|
||||
list[i].name = name;
|
||||
return &list[i];
|
||||
}
|
||||
assert(!"No space in KEXINIT list");
|
||||
return NULL;
|
||||
|
||||
unreachable("Should never run out of space in KEXINIT list");
|
||||
}
|
||||
|
||||
bool ssh2_common_filter_queue(PacketProtocolLayer *ppl)
|
||||
|
@ -1292,8 +1292,7 @@ void share_got_pkt_from_server(ssh_sharing_connstate *cs, int type,
|
||||
break;
|
||||
|
||||
default:
|
||||
assert(!"This packet type should never have come from ssh.c");
|
||||
break;
|
||||
unreachable("This packet type should never have come from ssh.c");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -357,7 +357,7 @@ char *dlg_editbox_get(union control *ctrl, dlgparam *dp)
|
||||
return dupstr(gtk_entry_get_text(GTK_ENTRY(uc->entry)));
|
||||
}
|
||||
|
||||
assert(!"We shouldn't get here");
|
||||
unreachable("bad control type in editbox_get");
|
||||
}
|
||||
|
||||
#if !GTK_CHECK_VERSION(2,4,0)
|
||||
@ -395,7 +395,7 @@ void dlg_listbox_clear(union control *ctrl, dlgparam *dp)
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
assert(!"We shouldn't get here");
|
||||
unreachable("bad control type in listbox_clear");
|
||||
}
|
||||
|
||||
void dlg_listbox_del(union control *ctrl, dlgparam *dp, int index)
|
||||
@ -429,7 +429,7 @@ void dlg_listbox_del(union control *ctrl, dlgparam *dp, int index)
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
assert(!"We shouldn't get here");
|
||||
unreachable("bad control type in listbox_del");
|
||||
}
|
||||
|
||||
void dlg_listbox_add(union control *ctrl, dlgparam *dp, char const *text)
|
||||
@ -587,7 +587,7 @@ void dlg_listbox_addwithid(union control *ctrl, dlgparam *dp,
|
||||
goto done;
|
||||
}
|
||||
#endif
|
||||
assert(!"We shouldn't get here");
|
||||
unreachable("bad control type in listbox_addwithid");
|
||||
done:
|
||||
dp->flags &= ~FLAG_UPDATING_COMBO_LIST;
|
||||
}
|
||||
@ -626,7 +626,7 @@ int dlg_listbox_getid(union control *ctrl, dlgparam *dp, int index)
|
||||
return ret;
|
||||
}
|
||||
#endif
|
||||
assert(!"We shouldn't get here");
|
||||
unreachable("bad control type in listbox_getid");
|
||||
return -1; /* placate dataflow analysis */
|
||||
}
|
||||
|
||||
@ -711,7 +711,7 @@ int dlg_listbox_index(union control *ctrl, dlgparam *dp)
|
||||
return ret;
|
||||
}
|
||||
#endif
|
||||
assert(!"We shouldn't get here");
|
||||
unreachable("bad control type in listbox_index");
|
||||
return -1; /* placate dataflow analysis */
|
||||
}
|
||||
|
||||
@ -768,7 +768,7 @@ bool dlg_listbox_issel(union control *ctrl, dlgparam *dp, int index)
|
||||
return ret;
|
||||
}
|
||||
#endif
|
||||
assert(!"We shouldn't get here");
|
||||
unreachable("bad control type in listbox_issel");
|
||||
return false; /* placate dataflow analysis */
|
||||
}
|
||||
|
||||
@ -837,7 +837,7 @@ void dlg_listbox_select(union control *ctrl, dlgparam *dp, int index)
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
assert(!"We shouldn't get here");
|
||||
unreachable("bad control type in listbox_select");
|
||||
}
|
||||
|
||||
void dlg_text_set(union control *ctrl, dlgparam *dp, char const *text)
|
||||
@ -884,8 +884,7 @@ void dlg_label_change(union control *ctrl, dlgparam *dp, char const *text)
|
||||
shortcut_highlight(uc->label, ctrl->listbox.shortcut);
|
||||
break;
|
||||
default:
|
||||
assert(!"This shouldn't happen");
|
||||
break;
|
||||
unreachable("bad control type in label_change");
|
||||
}
|
||||
}
|
||||
|
||||
@ -1016,8 +1015,7 @@ void dlg_set_focus(union control *ctrl, dlgparam *dp)
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
assert(!"We shouldn't get here");
|
||||
break;
|
||||
unreachable("bad control type in set_focus");
|
||||
}
|
||||
}
|
||||
|
||||
@ -2730,8 +2728,7 @@ gint win_key_press(GtkWidget *widget, GdkEventKey *event, gpointer data)
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
assert(!"We shouldn't get here");
|
||||
break;
|
||||
unreachable("bad listbox type in win_key_press");
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -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);
|
||||
|
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user