diff options
author | Marc-André Lureau <marcandre.lureau@redhat.com> | 2019-11-21 15:03:14 +0400 |
---|---|---|
committer | Marc-André Lureau <marcandre.lureau@redhat.com> | 2019-11-21 15:32:28 +0400 |
commit | ab9a34aa417ac948671121c3eb2078b6cc5c48fc (patch) | |
tree | 4bb129d7ed042a3d9d1c250a081c03094e791658 | |
parent | 3a494648526be4eb96cba739a816a60e933ffd14 (diff) | |
download | slirp-ab9a34aa417ac948671121c3eb2078b6cc5c48fc.zip slirp-ab9a34aa417ac948671121c3eb2078b6cc5c48fc.tar.gz slirp-ab9a34aa417ac948671121c3eb2078b6cc5c48fc.tar.bz2 |
tcp_attach() can no longer fail
Now that tcp_newtcpcb() always returns != NULL.
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
-rw-r--r-- | src/slirp.h | 2 | ||||
-rw-r--r-- | src/state.c | 5 | ||||
-rw-r--r-- | src/tcp_input.c | 5 | ||||
-rw-r--r-- | src/tcp_subr.c | 13 |
4 files changed, 7 insertions, 18 deletions
diff --git a/src/slirp.h b/src/slirp.h index 5e68d9d..a231eb2 100644 --- a/src/slirp.h +++ b/src/slirp.h @@ -266,7 +266,7 @@ struct tcpcb *tcp_close(register struct tcpcb *); void tcp_sockclosed(struct tcpcb *); int tcp_fconnect(struct socket *, unsigned short af); void tcp_connect(struct socket *); -int tcp_attach(struct socket *); +void tcp_attach(struct socket *); uint8_t tcp_tos(struct socket *); int tcp_emu(struct socket *, struct mbuf *); int tcp_ctl(struct socket *); diff --git a/src/state.c b/src/state.c index 4a9824e..40794e8 100644 --- a/src/state.c +++ b/src/state.c @@ -159,9 +159,8 @@ static bool slirp_family_inet(void *opaque, int version_id) static int slirp_socket_pre_load(void *opaque) { struct socket *so = opaque; - if (tcp_attach(so) < 0) { - return -ENOMEM; - } + + tcp_attach(so); /* Older versions don't load these fields */ so->so_ffamily = AF_INET; so->so_lfamily = AF_INET; diff --git a/src/tcp_input.c b/src/tcp_input.c index 30265d6..d55b0c8 100644 --- a/src/tcp_input.c +++ b/src/tcp_input.c @@ -408,10 +408,7 @@ findso: goto dropwithreset; so = socreate(slirp); - if (tcp_attach(so) < 0) { - g_free(so); /* Not sofree (if it failed, it's not insqued) */ - goto dropwithreset; - } + tcp_attach(so); sbreserve(&so->so_snd, TCP_SNDSPACE); sbreserve(&so->so_rcv, TCP_RCVSPACE); diff --git a/src/tcp_subr.c b/src/tcp_subr.c index e54f8fa..180b491 100644 --- a/src/tcp_subr.c +++ b/src/tcp_subr.c @@ -470,10 +470,7 @@ void tcp_connect(struct socket *inso) so = inso; } else { so = socreate(slirp); - if (tcp_attach(so) < 0) { - g_free(so); /* NOT sofree */ - return; - } + tcp_attach(so); so->lhost = inso->lhost; so->so_ffamily = inso->so_ffamily; } @@ -524,14 +521,10 @@ void tcp_connect(struct socket *inso) /* * Attach a TCPCB to a socket. */ -int tcp_attach(struct socket *so) +void tcp_attach(struct socket *so) { - if ((so->so_tcpcb = tcp_newtcpcb(so)) == NULL) - return -1; - + so->so_tcpcb = tcp_newtcpcb(so); insque(so, &so->slirp->tcb); - - return 0; } /* |