| Submitter | MORITA Kazutaka |
|---|---|
| Date | Jan. 21, 2013, 12:23 a.m. |
| Message ID | <1358727810-24055-2-git-send-email-morita.kazutaka@lab.ntt.co.jp> |
| Download | mbox | patch |
| Permalink | /patch/214018/ |
| State | New |
| Headers | show |
Comments
On Mon, Jan 21, 2013 at 09:23:28AM +0900, MORITA Kazutaka wrote: > diff --git a/slirp/tcp_subr.c b/slirp/tcp_subr.c > index 1542e43..abc6662 100644 > --- a/slirp/tcp_subr.c > +++ b/slirp/tcp_subr.c > @@ -429,8 +429,7 @@ tcp_connect(struct socket *inso) > setsockopt(s,SOL_SOCKET,SO_REUSEADDR,(char *)&opt,sizeof(int)); > opt = 1; > setsockopt(s,SOL_SOCKET,SO_OOBINLINE,(char *)&opt,sizeof(int)); > - opt = 1; > - setsockopt(s,IPPROTO_TCP,TCP_NODELAY,(char *)&opt,sizeof(int)); > + socket_set_nodelay(s); This function still uses tabs for indentation. The line you added uses 4 spaces (QEMU coding style) but now this single line may be inconsistent. I suggest using tab for this line so it fits in with the existing code.
On Tue, Jan 22, 2013 at 9:36 AM, Stefan Hajnoczi <stefanha@gmail.com> wrote: > On Mon, Jan 21, 2013 at 09:23:28AM +0900, MORITA Kazutaka wrote: >> diff --git a/slirp/tcp_subr.c b/slirp/tcp_subr.c >> index 1542e43..abc6662 100644 >> --- a/slirp/tcp_subr.c >> +++ b/slirp/tcp_subr.c >> @@ -429,8 +429,7 @@ tcp_connect(struct socket *inso) >> setsockopt(s,SOL_SOCKET,SO_REUSEADDR,(char *)&opt,sizeof(int)); >> opt = 1; >> setsockopt(s,SOL_SOCKET,SO_OOBINLINE,(char *)&opt,sizeof(int)); >> - opt = 1; >> - setsockopt(s,IPPROTO_TCP,TCP_NODELAY,(char *)&opt,sizeof(int)); >> + socket_set_nodelay(s); > > This function still uses tabs for indentation. The line you added uses > 4 spaces (QEMU coding style) but now this single line may be > inconsistent. I suggest using tab for this line so it fits in with the > existing code. Don't use tabs but please convert the function to using spaces. There should be a space after commas too.
Patch
diff --git a/block/sheepdog.c b/block/sheepdog.c index 3e49bb8..9746037 100644 --- a/block/sheepdog.c +++ b/block/sheepdog.c @@ -787,15 +787,6 @@ static int aio_flush_request(void *opaque) !QLIST_EMPTY(&s->pending_aio_head); } -static int set_nodelay(int fd) -{ - int ret, opt; - - opt = 1; - ret = setsockopt(fd, IPPROTO_TCP, TCP_NODELAY, (char *)&opt, sizeof(opt)); - return ret; -} - /* * Return a socket discriptor to read/write objects. * @@ -814,7 +805,7 @@ static int get_sheep_fd(BDRVSheepdogState *s) socket_set_nonblock(fd); - ret = set_nodelay(fd); + ret = socket_set_nodelay(fd); if (ret) { error_report("%s", strerror(errno)); closesocket(fd); diff --git a/gdbstub.c b/gdbstub.c index 6cd26f1..4cc1812 100644 --- a/gdbstub.c +++ b/gdbstub.c @@ -2837,7 +2837,7 @@ static void gdb_accept(void) GDBState *s; struct sockaddr_in sockaddr; socklen_t len; - int val, fd; + int fd; for(;;) { len = sizeof(sockaddr); @@ -2854,8 +2854,7 @@ static void gdb_accept(void) } /* set short latency */ - val = 1; - setsockopt(fd, IPPROTO_TCP, TCP_NODELAY, (char *)&val, sizeof(val)); + socket_set_nodelay(fd); s = g_malloc0(sizeof(GDBState)); s->c_cpu = first_cpu; diff --git a/include/qemu/sockets.h b/include/qemu/sockets.h index 803ae17..6125bf7 100644 --- a/include/qemu/sockets.h +++ b/include/qemu/sockets.h @@ -34,6 +34,7 @@ int inet_aton(const char *cp, struct in_addr *ia); int qemu_socket(int domain, int type, int protocol); int qemu_accept(int s, struct sockaddr *addr, socklen_t *addrlen); int socket_set_cork(int fd, int v); +int socket_set_nodelay(int fd); void socket_set_block(int fd); void socket_set_nonblock(int fd); int send_all(int fd, const void *buf, int len1); diff --git a/qemu-char.c b/qemu-char.c index 9ba0573..156164c 100644 --- a/qemu-char.c +++ b/qemu-char.c @@ -2365,12 +2365,6 @@ static void tcp_chr_telnet_init(int fd) send(fd, (char *)buf, 3, 0); } -static void socket_set_nodelay(int fd) -{ - int val = 1; - setsockopt(fd, IPPROTO_TCP, TCP_NODELAY, (char *)&val, sizeof(val)); -} - static int tcp_chr_add_client(CharDriverState *chr, int fd) { TCPCharDriver *s = chr->opaque; diff --git a/slirp/tcp_subr.c b/slirp/tcp_subr.c index 1542e43..abc6662 100644 --- a/slirp/tcp_subr.c +++ b/slirp/tcp_subr.c @@ -429,8 +429,7 @@ tcp_connect(struct socket *inso) setsockopt(s,SOL_SOCKET,SO_REUSEADDR,(char *)&opt,sizeof(int)); opt = 1; setsockopt(s,SOL_SOCKET,SO_OOBINLINE,(char *)&opt,sizeof(int)); - opt = 1; - setsockopt(s,IPPROTO_TCP,TCP_NODELAY,(char *)&opt,sizeof(int)); + socket_set_nodelay(s); so->so_fport = addr.sin_port; so->so_faddr = addr.sin_addr; diff --git a/util/osdep.c b/util/osdep.c index 5b51a03..c408261 100644 --- a/util/osdep.c +++ b/util/osdep.c @@ -63,6 +63,12 @@ int socket_set_cork(int fd, int v) #endif } +int socket_set_nodelay(int fd) +{ + int v = 1; + return setsockopt(fd, IPPROTO_TCP, TCP_NODELAY, &v, sizeof(v)); +} + int qemu_madvise(void *addr, size_t len, int advice) { if (advice == QEMU_MADV_INVALID) {
Signed-off-by: MORITA Kazutaka <morita.kazutaka@lab.ntt.co.jp> --- block/sheepdog.c | 11 +---------- gdbstub.c | 5 ++--- include/qemu/sockets.h | 1 + qemu-char.c | 6 ------ slirp/tcp_subr.c | 3 +-- util/osdep.c | 6 ++++++ 6 files changed, 11 insertions(+), 21 deletions(-)