slirp: slirp/slirp.c coding style cleanup

The slirp glue code uses tabs in some places.  Since the next patch will
modify the file, convert tabs to spaces and fix checkpatch.pl issues.

Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
Message-id: 1361356113-11049-5-git-send-email-stefanha@redhat.com
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
This commit is contained in:
Stefan Hajnoczi 2013-02-20 11:28:27 +01:00 committed by Anthony Liguori
parent 48ce11ff97
commit cf1d078e4e
1 changed files with 304 additions and 290 deletions

View File

@ -307,15 +307,17 @@ void slirp_select_fill(int *pnfds,
/* /*
* See if we need a tcp_fasttimo * See if we need a tcp_fasttimo
*/ */
if (time_fasttimo == 0 && so->so_tcpcb->t_flags & TF_DELACK) if (time_fasttimo == 0 && so->so_tcpcb->t_flags & TF_DELACK) {
time_fasttimo = curtime; /* Flag when we want a fasttimo */ time_fasttimo = curtime; /* Flag when we want a fasttimo */
}
/* /*
* NOFDREF can include still connecting to local-host, * NOFDREF can include still connecting to local-host,
* newly socreated() sockets etc. Don't want to select these. * newly socreated() sockets etc. Don't want to select these.
*/ */
if (so->so_state & SS_NOFDREF || so->s == -1) if (so->so_state & SS_NOFDREF || so->s == -1) {
continue; continue;
}
/* /*
* Set for reading sockets which are accepting * Set for reading sockets which are accepting
@ -348,7 +350,8 @@ void slirp_select_fill(int *pnfds,
* Set for reading (and urgent data) if we are connected, can * Set for reading (and urgent data) if we are connected, can
* receive more, and we have room for it XXX /2 ? * receive more, and we have room for it XXX /2 ?
*/ */
if (CONN_CANFRCV(so) && (so->so_snd.sb_cc < (so->so_snd.sb_datalen/2))) { if (CONN_CANFRCV(so) &&
(so->so_snd.sb_cc < (so->so_snd.sb_datalen/2))) {
FD_SET(so->s, readfds); FD_SET(so->s, readfds);
FD_SET(so->s, xfds); FD_SET(so->s, xfds);
UPD_NFDS(so->s); UPD_NFDS(so->s);
@ -369,9 +372,10 @@ void slirp_select_fill(int *pnfds,
if (so->so_expire <= curtime) { if (so->so_expire <= curtime) {
udp_detach(so); udp_detach(so);
continue; continue;
} else } else {
do_slowtimo = 1; /* Let socket expire */ do_slowtimo = 1; /* Let socket expire */
} }
}
/* /*
* When UDP packets are received from over the * When UDP packets are received from over the
@ -464,16 +468,18 @@ void slirp_select_poll(fd_set *readfds, fd_set *writefds, fd_set *xfds,
* FD_ISSET is meaningless on these sockets * FD_ISSET is meaningless on these sockets
* (and they can crash the program) * (and they can crash the program)
*/ */
if (so->so_state & SS_NOFDREF || so->s == -1) if (so->so_state & SS_NOFDREF || so->s == -1) {
continue; continue;
}
/* /*
* Check for URG data * Check for URG data
* This will soread as well, so no need to * This will soread as well, so no need to
* test for readfds below if this succeeds * test for readfds below if this succeeds
*/ */
if (FD_ISSET(so->s, xfds)) if (FD_ISSET(so->s, xfds)) {
sorecvoob(so); sorecvoob(so);
}
/* /*
* Check sockets for reading * Check sockets for reading
*/ */
@ -488,9 +494,10 @@ void slirp_select_poll(fd_set *readfds, fd_set *writefds, fd_set *xfds,
ret = soread(so); ret = soread(so);
/* Output it if we read something */ /* Output it if we read something */
if (ret > 0) if (ret > 0) {
tcp_output(sototcpcb(so)); tcp_output(sototcpcb(so));
} }
}
/* /*
* Check sockets for writing * Check sockets for writing
@ -507,8 +514,9 @@ void slirp_select_poll(fd_set *readfds, fd_set *writefds, fd_set *xfds,
if (ret < 0) { if (ret < 0) {
/* XXXXX Must fix, zero bytes is a NOP */ /* XXXXX Must fix, zero bytes is a NOP */
if (errno == EAGAIN || errno == EWOULDBLOCK || if (errno == EAGAIN || errno == EWOULDBLOCK ||
errno == EINPROGRESS || errno == ENOTCONN) errno == EINPROGRESS || errno == ENOTCONN) {
continue; continue;
}
/* else failed */ /* else failed */
so->so_state &= SS_PERSISTENT_MASK; so->so_state &= SS_PERSISTENT_MASK;
@ -521,8 +529,9 @@ void slirp_select_poll(fd_set *readfds, fd_set *writefds, fd_set *xfds,
*/ */
tcp_input((struct mbuf *)NULL, sizeof(struct ip), so); tcp_input((struct mbuf *)NULL, sizeof(struct ip), so);
/* continue; */ /* continue; */
} else } else {
ret = sowrite(so); ret = sowrite(so);
}
/* /*
* XXXXX If we wrote something (a lot), there * XXXXX If we wrote something (a lot), there
* could be a need for a window update. * could be a need for a window update.
@ -537,13 +546,14 @@ void slirp_select_poll(fd_set *readfds, fd_set *writefds, fd_set *xfds,
*/ */
#ifdef PROBE_CONN #ifdef PROBE_CONN
if (so->so_state & SS_ISFCONNECTING) { if (so->so_state & SS_ISFCONNECTING) {
ret = qemu_recv(so->s, &ret, 0,0); ret = qemu_recv(so->s, &ret, 0, 0);
if (ret < 0) { if (ret < 0) {
/* XXX */ /* XXX */
if (errno == EAGAIN || errno == EWOULDBLOCK || if (errno == EAGAIN || errno == EWOULDBLOCK ||
errno == EINPROGRESS || errno == ENOTCONN) errno == EINPROGRESS || errno == ENOTCONN) {
continue; /* Still connecting, continue */ continue; /* Still connecting, continue */
}
/* else failed */ /* else failed */
so->so_state &= SS_PERSISTENT_MASK; so->so_state &= SS_PERSISTENT_MASK;
@ -551,20 +561,22 @@ void slirp_select_poll(fd_set *readfds, fd_set *writefds, fd_set *xfds,
/* tcp_input will take care of it */ /* tcp_input will take care of it */
} else { } else {
ret = send(so->s, &ret, 0,0); ret = send(so->s, &ret, 0, 0);
if (ret < 0) { if (ret < 0) {
/* XXX */ /* XXX */
if (errno == EAGAIN || errno == EWOULDBLOCK || if (errno == EAGAIN || errno == EWOULDBLOCK ||
errno == EINPROGRESS || errno == ENOTCONN) errno == EINPROGRESS || errno == ENOTCONN) {
continue; continue;
}
/* else failed */ /* else failed */
so->so_state &= SS_PERSISTENT_MASK; so->so_state &= SS_PERSISTENT_MASK;
so->so_state |= SS_NOFDREF; so->so_state |= SS_NOFDREF;
} else } else {
so->so_state &= ~SS_ISFCONNECTING; so->so_state &= ~SS_ISFCONNECTING;
}
} }
tcp_input((struct mbuf *)NULL, sizeof(struct ip),so); tcp_input((struct mbuf *)NULL, sizeof(struct ip), so);
} /* SS_ISFCONNECTING */ } /* SS_ISFCONNECTING */
#endif #endif
} }
@ -857,11 +869,13 @@ size_t slirp_socket_can_recv(Slirp *slirp, struct in_addr guest_addr,
so = slirp_find_ctl_socket(slirp, guest_addr, guest_port); so = slirp_find_ctl_socket(slirp, guest_addr, guest_port);
if (!so || so->so_state & SS_NOFDREF) if (!so || so->so_state & SS_NOFDREF) {
return 0; return 0;
}
if (!CONN_CANFRCV(so) || so->so_snd.sb_cc >= (so->so_snd.sb_datalen/2)) if (!CONN_CANFRCV(so) || so->so_snd.sb_cc >= (so->so_snd.sb_datalen/2)) {
return 0; return 0;
}
return sopreprbuf(so, iov, NULL); return sopreprbuf(so, iov, NULL);
} }