Make plug receive and closing functions return void instead of int.

Nothing was paying attention to their return values any more anyway.
This commit is contained in:
Ben Harris 2016-06-02 23:03:24 +01:00
Родитель 0d9c7d82e8
Коммит 0d57b8a4d9
11 изменённых файлов: 73 добавлений и 98 удалений

Просмотреть файл

@ -64,12 +64,12 @@ struct plug_function_table {
* proxy command, so the receiver should probably prefix it to
* indicate this.
*/
int (*closing)
void (*closing)
(Plug p, const char *error_msg, int error_code, int calling_back);
/* error_msg is NULL iff it is not an error (ie it closed normally) */
/* calling_back != 0 iff there is a Plug function */
/* currently running (would cure the fixme in try_send()) */
int (*receive) (Plug p, int urgent, char *data, int len);
void (*receive) (Plug p, int urgent, char *data, int len);
/*
* - urgent==0. `data' points to `len' bytes of perfectly
* ordinary data.

Просмотреть файл

@ -964,11 +964,11 @@ int pageant_delete_ssh2_key(struct ssh2_userkey *skey)
* Coroutine macros similar to, but simplified from, those in ssh.c.
*/
#define crBegin(v) { int *crLine = &v; switch(v) { case 0:;
#define crFinish(z) } *crLine = 0; return (z); }
#define crFinishV } *crLine = 0; return; }
#define crGetChar(c) do \
{ \
while (len == 0) { \
*crLine =__LINE__; return 1; case __LINE__:; \
*crLine =__LINE__; return; case __LINE__:; \
} \
len--; \
(c) = (unsigned char)*data++; \
@ -987,8 +987,8 @@ struct pageant_conn_state {
int crLine; /* for coroutine in pageant_conn_receive */
};
static int pageant_conn_closing(Plug plug, const char *error_msg,
int error_code, int calling_back)
static void pageant_conn_closing(Plug plug, const char *error_msg,
int error_code, int calling_back)
{
struct pageant_conn_state *pc = (struct pageant_conn_state *)plug;
if (error_msg)
@ -997,7 +997,6 @@ static int pageant_conn_closing(Plug plug, const char *error_msg,
plog(pc->logctx, pc->logfn, "%p: connection closed", pc);
sk_close(pc->connsock);
sfree(pc);
return 1;
}
static void pageant_conn_sent(Plug plug, int bufsize)
@ -1021,7 +1020,7 @@ static void pageant_conn_log(void *logctx, const char *fmt, va_list ap)
sfree(formatted);
}
static int pageant_conn_receive(Plug plug, int urgent, char *data, int len)
static void pageant_conn_receive(Plug plug, int urgent, char *data, int len)
{
struct pageant_conn_state *pc = (struct pageant_conn_state *)plug;
char c;
@ -1065,7 +1064,7 @@ static int pageant_conn_receive(Plug plug, int urgent, char *data, int len)
}
}
crFinish(1);
crFinishV;
}
struct pageant_listen_state {
@ -1077,15 +1076,14 @@ struct pageant_listen_state {
pageant_logfn_t logfn;
};
static int pageant_listen_closing(Plug plug, const char *error_msg,
int error_code, int calling_back)
static void pageant_listen_closing(Plug plug, const char *error_msg,
int error_code, int calling_back)
{
struct pageant_listen_state *pl = (struct pageant_listen_state *)plug;
if (error_msg)
plog(pl->logctx, pl->logfn, "listening socket: error: %s", error_msg);
sk_close(pl->listensock);
pl->listensock = NULL;
return 1;
}
static int pageant_listen_accepting(Plug plug,

Просмотреть файл

@ -117,8 +117,8 @@ static void pfl_log(Plug plug, int type, SockAddr addr, int port,
/* we have to dump these since we have no interface to logging.c */
}
static int pfd_closing(Plug plug, const char *error_msg, int error_code,
int calling_back)
static void pfd_closing(Plug plug, const char *error_msg, int error_code,
int calling_back)
{
struct PortForwarding *pf = (struct PortForwarding *) plug;
@ -145,16 +145,13 @@ static int pfd_closing(Plug plug, const char *error_msg, int error_code,
if (pf->c)
sshfwd_write_eof(pf->c);
}
return 1;
}
static int pfl_closing(Plug plug, const char *error_msg, int error_code,
int calling_back)
static void pfl_closing(Plug plug, const char *error_msg, int error_code,
int calling_back)
{
struct PortListener *pl = (struct PortListener *) plug;
pfl_terminate(pl);
return 1;
}
static void wrap_send_port_open(void *channel, const char *hostname, int port,
@ -172,7 +169,7 @@ static void wrap_send_port_open(void *channel, const char *hostname, int port,
sfree(description);
}
static int pfd_receive(Plug plug, int urgent, char *data, int len)
static void pfd_receive(Plug plug, int urgent, char *data, int len)
{
struct PortForwarding *pf = (struct PortForwarding *) plug;
if (pf->dynamic) {
@ -204,7 +201,7 @@ static int pfd_receive(Plug plug, int urgent, char *data, int len)
data[1] = 91; /* generic `request rejected' */
sk_write(pf->s, data, 8);
pfd_close(pf);
return 1;
return;
}
if (pf->sockslen <= 8)
continue; /* haven't started user/hostname */
@ -320,7 +317,7 @@ static int pfd_receive(Plug plug, int urgent, char *data, int len)
reply[1] = 1; /* generic failure */
sk_write(pf->s, (char *) reply, lenof(reply));
pfd_close(pf);
return 1;
return;
}
/*
* Now we have a viable connect request. Switch
@ -350,7 +347,7 @@ static int pfd_receive(Plug plug, int urgent, char *data, int len)
reply[1] = 8; /* atype not supported */
sk_write(pf->s, (char *) reply, lenof(reply));
pfd_close(pf);
return 1;
return;
}
}
}
@ -362,9 +359,8 @@ static int pfd_receive(Plug plug, int urgent, char *data, int len)
* close the connection rudely.
*/
pfd_close(pf);
return 1;
}
return 1;
return;
/*
* We come here when we're ready to make an actual
@ -383,7 +379,7 @@ static int pfd_receive(Plug plug, int urgent, char *data, int len)
pf->c = new_sock_channel(pf->backhandle, pf);
if (pf->c == NULL) {
pfd_close(pf);
return 1;
return;
} else {
/* asks to forward to the specified host/port for this */
wrap_send_port_open(pf->c, pf->hostname, pf->port, pf->s);
@ -406,7 +402,6 @@ static int pfd_receive(Plug plug, int urgent, char *data, int len)
sk_set_frozen(pf->s, 1);
}
}
return 1;
}
static void pfd_sent(Plug plug, int bufsize)

41
proxy.c
Просмотреть файл

@ -201,8 +201,8 @@ static void plug_proxy_log(Plug plug, int type, SockAddr addr, int port,
plug_log(ps->plug, type, addr, port, error_msg, error_code);
}
static int plug_proxy_closing (Plug p, const char *error_msg,
int error_code, int calling_back)
static void plug_proxy_closing (Plug p, const char *error_msg,
int error_code, int calling_back)
{
Proxy_Plug pp = (Proxy_Plug) p;
Proxy_Socket ps = pp->proxy_socket;
@ -211,13 +211,13 @@ static int plug_proxy_closing (Plug p, const char *error_msg,
ps->closing_error_msg = error_msg;
ps->closing_error_code = error_code;
ps->closing_calling_back = calling_back;
return ps->negotiate(ps, PROXY_CHANGE_CLOSING);
ps->negotiate(ps, PROXY_CHANGE_CLOSING);
} else {
plug_closing(ps->plug, error_msg, error_code, calling_back);
}
return plug_closing(ps->plug, error_msg,
error_code, calling_back);
}
static int plug_proxy_receive (Plug p, int urgent, char *data, int len)
static void plug_proxy_receive (Plug p, int urgent, char *data, int len)
{
Proxy_Plug pp = (Proxy_Plug) p;
Proxy_Socket ps = pp->proxy_socket;
@ -231,9 +231,10 @@ static int plug_proxy_receive (Plug p, int urgent, char *data, int len)
ps->receive_urgent = urgent;
ps->receive_data = data;
ps->receive_len = len;
return ps->negotiate(ps, PROXY_CHANGE_RECEIVE);
ps->negotiate(ps, PROXY_CHANGE_RECEIVE);
} else {
plug_receive(ps->plug, urgent, data, len);
}
return plug_receive(ps->plug, urgent, data, len);
}
static void plug_proxy_sent (Plug p, int bufsize)
@ -644,9 +645,9 @@ int proxy_http_negotiate (Proxy_Socket p, int change)
* a socket close, then some error must have occurred. we'll
* just pass those errors up to the backend.
*/
return plug_closing(p->plug, p->closing_error_msg,
p->closing_error_code,
p->closing_calling_back);
plug_closing(p->plug, p->closing_error_msg, p->closing_error_code,
p->closing_calling_back);
return 0; /* ignored */
}
if (change == PROXY_CHANGE_SENT) {
@ -847,9 +848,9 @@ int proxy_socks4_negotiate (Proxy_Socket p, int change)
* a socket close, then some error must have occurred. we'll
* just pass those errors up to the backend.
*/
return plug_closing(p->plug, p->closing_error_msg,
p->closing_error_code,
p->closing_calling_back);
plug_closing(p->plug, p->closing_error_msg, p->closing_error_code,
p->closing_calling_back);
return 0; /* ignored */
}
if (change == PROXY_CHANGE_SENT) {
@ -987,9 +988,9 @@ int proxy_socks5_negotiate (Proxy_Socket p, int change)
* a socket close, then some error must have occurred. we'll
* just pass those errors up to the backend.
*/
return plug_closing(p->plug, p->closing_error_msg,
p->closing_error_code,
p->closing_calling_back);
plug_closing(p->plug, p->closing_error_msg, p->closing_error_code,
p->closing_calling_back);
return 0; /* ignored */
}
if (change == PROXY_CHANGE_SENT) {
@ -1561,9 +1562,9 @@ int proxy_telnet_negotiate (Proxy_Socket p, int change)
* a socket close, then some error must have occurred. we'll
* just pass those errors up to the backend.
*/
return plug_closing(p->plug, p->closing_error_msg,
p->closing_error_code,
p->closing_calling_back);
plug_closing(p->plug, p->closing_error_msg, p->closing_error_code,
p->closing_calling_back);
return 0; /* ignored */
}
if (change == PROXY_CHANGE_SENT) {

8
raw.c
Просмотреть файл

@ -61,8 +61,8 @@ static void raw_check_close(Raw raw)
}
}
static int raw_closing(Plug plug, const char *error_msg, int error_code,
int calling_back)
static void raw_closing(Plug plug, const char *error_msg, int error_code,
int calling_back)
{
Raw raw = (Raw) plug;
@ -92,17 +92,15 @@ static int raw_closing(Plug plug, const char *error_msg, int error_code,
raw->sent_console_eof = TRUE;
raw_check_close(raw);
}
return 0;
}
static int raw_receive(Plug plug, int urgent, char *data, int len)
static void raw_receive(Plug plug, int urgent, char *data, int len)
{
Raw raw = (Raw) plug;
c_write(raw, data, len);
/* We count 'session start', for proxy logging purposes, as being
* when data is received from the network and printed. */
raw->session_started = TRUE;
return 1;
}
static void raw_sent(Plug plug, int bufsize)

Просмотреть файл

@ -53,8 +53,8 @@ static void rlogin_log(Plug plug, int type, SockAddr addr, int port,
rlogin->conf, !rlogin->firstbyte);
}
static int rlogin_closing(Plug plug, const char *error_msg, int error_code,
int calling_back)
static void rlogin_closing(Plug plug, const char *error_msg, int error_code,
int calling_back)
{
Rlogin rlogin = (Rlogin) plug;
@ -76,10 +76,9 @@ static int rlogin_closing(Plug plug, const char *error_msg, int error_code,
logevent(rlogin->frontend, error_msg);
connection_fatal(rlogin->frontend, "%s", error_msg);
} /* Otherwise, the remote side closed the connection normally. */
return 0;
}
static int rlogin_receive(Plug plug, int urgent, char *data, int len)
static void rlogin_receive(Plug plug, int urgent, char *data, int len)
{
Rlogin rlogin = (Rlogin) plug;
if (urgent == 2) {
@ -113,7 +112,6 @@ static int rlogin_receive(Plug plug, int urgent, char *data, int len)
if (len > 0)
c_write(rlogin, data, len);
}
return 1;
}
static void rlogin_sent(Plug plug, int bufsize)

9
ssh.c
Просмотреть файл

@ -3560,8 +3560,8 @@ void ssh_connshare_log(Ssh ssh, int event, const char *logtext,
}
}
static int ssh_closing(Plug plug, const char *error_msg, int error_code,
int calling_back)
static void ssh_closing(Plug plug, const char *error_msg, int error_code,
int calling_back)
{
Ssh ssh = (Ssh) plug;
int need_notify = ssh_do_close(ssh, FALSE);
@ -3583,18 +3583,15 @@ static int ssh_closing(Plug plug, const char *error_msg, int error_code,
logevent(error_msg);
if (!ssh->close_expected || !ssh->clean_exit)
connection_fatal(ssh->frontend, "%s", error_msg);
return 0;
}
static int ssh_receive(Plug plug, int urgent, char *data, int len)
static void ssh_receive(Plug plug, int urgent, char *data, int len)
{
Ssh ssh = (Ssh) plug;
ssh_gotdata(ssh, (unsigned char *)data, len);
if (ssh->state == SSH_STATE_CLOSED) {
ssh_do_close(ssh, TRUE);
return 0;
}
return 1;
}
static void ssh_sent(Plug plug, int bufsize)

Просмотреть файл

@ -911,8 +911,8 @@ static void share_disconnect(struct ssh_sharing_connstate *cs,
share_begin_cleanup(cs);
}
static int share_closing(Plug plug, const char *error_msg, int error_code,
int calling_back)
static void share_closing(Plug plug, const char *error_msg, int error_code,
int calling_back)
{
struct ssh_sharing_connstate *cs = (struct ssh_sharing_connstate *)plug;
@ -935,7 +935,6 @@ static int share_closing(Plug plug, const char *error_msg, int error_code,
"Socket error: %s", error_msg);
}
share_begin_cleanup(cs);
return 1;
}
static int getstring_inner(const void *vdata, int datalen,
@ -1775,17 +1774,17 @@ static void share_got_pkt_from_downstream(struct ssh_sharing_connstate *cs,
* Coroutine macros similar to, but simplified from, those in ssh.c.
*/
#define crBegin(v) { int *crLine = &v; switch(v) { case 0:;
#define crFinish(z) } *crLine = 0; return (z); }
#define crFinishV } *crLine = 0; return; }
#define crGetChar(c) do \
{ \
while (len == 0) { \
*crLine =__LINE__; return 1; case __LINE__:; \
*crLine =__LINE__; return; case __LINE__:; \
} \
len--; \
(c) = (unsigned char)*data++; \
} while (0)
static int share_receive(Plug plug, int urgent, char *data, int len)
static void share_receive(Plug plug, int urgent, char *data, int len)
{
struct ssh_sharing_connstate *cs = (struct ssh_sharing_connstate *)plug;
static const char expected_verstring_prefix[] =
@ -1858,7 +1857,7 @@ static int share_receive(Plug plug, int urgent, char *data, int len)
}
dead:;
crFinish(1);
crFinishV;
}
static void share_sent(Plug plug, int bufsize)
@ -1875,8 +1874,8 @@ static void share_sent(Plug plug, int bufsize)
*/
}
static int share_listen_closing(Plug plug, const char *error_msg,
int error_code, int calling_back)
static void share_listen_closing(Plug plug, const char *error_msg,
int error_code, int calling_back)
{
struct ssh_sharing_state *sharestate = (struct ssh_sharing_state *)plug;
if (error_msg)
@ -1884,7 +1883,6 @@ static int share_listen_closing(Plug plug, const char *error_msg,
"listening socket: %s", error_msg);
sk_close(sharestate->listensock);
sharestate->listensock = NULL;
return 1;
}
static void share_send_verstring(struct ssh_sharing_connstate *cs)
@ -2047,10 +2045,9 @@ char *ssh_share_sockname(const char *host, int port, Conf *conf)
static void nullplug_socket_log(Plug plug, int type, SockAddr addr, int port,
const char *error_msg, int error_code) {}
static int nullplug_closing(Plug plug, const char *error_msg, int error_code,
int calling_back) { return 0; }
static int nullplug_receive(Plug plug, int urgent, char *data,
int len) { return 0; }
static void nullplug_closing(Plug plug, const char *error_msg, int error_code,
int calling_back) {}
static void nullplug_receive(Plug plug, int urgent, char *data, int len) {}
static void nullplug_sent(Plug plug, int bufsize) {}
int ssh_share_test_for_upstream(const char *host, int port, Conf *conf)

Просмотреть файл

@ -658,8 +658,8 @@ static void telnet_log(Plug plug, int type, SockAddr addr, int port,
telnet->session_started);
}
static int telnet_closing(Plug plug, const char *error_msg, int error_code,
int calling_back)
static void telnet_closing(Plug plug, const char *error_msg, int error_code,
int calling_back)
{
Telnet telnet = (Telnet) plug;
@ -681,17 +681,15 @@ static int telnet_closing(Plug plug, const char *error_msg, int error_code,
connection_fatal(telnet->frontend, "%s", error_msg);
}
/* Otherwise, the remote side closed the connection normally. */
return 0;
}
static int telnet_receive(Plug plug, int urgent, char *data, int len)
static void telnet_receive(Plug plug, int urgent, char *data, int len)
{
Telnet telnet = (Telnet) plug;
if (urgent)
telnet->in_synch = TRUE;
telnet->session_started = TRUE;
do_telnet_read(telnet, data, len);
return 1;
}
static void telnet_sent(Plug plug, int bufsize)

Просмотреть файл

@ -183,13 +183,12 @@ void sshfwd_x11_is_local(struct ssh_channel *c) {}
*/
static void x11_log(Plug p, int type, SockAddr addr, int port,
const char *error_msg, int error_code) {}
static int x11_receive(Plug plug, int urgent, char *data, int len) {return 0;}
static void x11_receive(Plug plug, int urgent, char *data, int len) {}
static void x11_sent(Plug plug, int bufsize) {}
static int x11_closing(Plug plug, const char *error_msg, int error_code,
int calling_back)
static void x11_closing(Plug plug, const char *error_msg, int error_code,
int calling_back)
{
time_to_die = TRUE;
return 1;
}
struct X11Connection {
const struct plug_function_table *fn;

Просмотреть файл

@ -58,11 +58,9 @@ static int xdmseen_cmp(void *a, void *b)
* independent network.c or something */
static void dummy_plug_log(Plug p, int type, SockAddr addr, int port,
const char *error_msg, int error_code) { }
static int dummy_plug_closing
(Plug p, const char *error_msg, int error_code, int calling_back)
{ return 1; }
static int dummy_plug_receive(Plug p, int urgent, char *data, int len)
{ return 1; }
static void dummy_plug_closing
(Plug p, const char *error_msg, int error_code, int calling_back) { }
static void dummy_plug_receive(Plug p, int urgent, char *data, int len) { }
static void dummy_plug_sent(Plug p, int bufsize) { }
static int dummy_plug_accepting(Plug p, accept_fn_t constructor, accept_ctx_t ctx) { return 1; }
static const struct plug_function_table dummy_plug = {
@ -616,8 +614,8 @@ static void x11_log(Plug p, int type, SockAddr addr, int port,
static void x11_send_init_error(struct X11Connection *conn,
const char *err_message);
static int x11_closing(Plug plug, const char *error_msg, int error_code,
int calling_back)
static void x11_closing(Plug plug, const char *error_msg, int error_code,
int calling_back)
{
struct X11Connection *xconn = (struct X11Connection *) plug;
@ -646,11 +644,9 @@ static int x11_closing(Plug plug, const char *error_msg, int error_code,
if (xconn->c)
sshfwd_write_eof(xconn->c);
}
return 1;
}
static int x11_receive(Plug plug, int urgent, char *data, int len)
static void x11_receive(Plug plug, int urgent, char *data, int len)
{
struct X11Connection *xconn = (struct X11Connection *) plug;
@ -659,8 +655,6 @@ static int x11_receive(Plug plug, int urgent, char *data, int len)
xconn->no_data_sent_to_x_client = FALSE;
sk_set_frozen(xconn->s, 1);
}
return 1;
}
static void x11_sent(Plug plug, int bufsize)