From patchwork Wed Dec 7 15:01:48 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Hajnoczi X-Patchwork-Id: 129978 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [140.186.70.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 4547C1007D5 for ; Thu, 8 Dec 2011 02:02:29 +1100 (EST) Received: from localhost ([::1]:41381 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RYJ0q-0001ne-Hy for incoming@patchwork.ozlabs.org; Wed, 07 Dec 2011 10:02:24 -0500 Received: from eggs.gnu.org ([140.186.70.92]:60637) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RYJ0Y-0001An-SK for qemu-devel@nongnu.org; Wed, 07 Dec 2011 10:02:08 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RYJ0S-0006sZ-Hc for qemu-devel@nongnu.org; Wed, 07 Dec 2011 10:02:06 -0500 Received: from e06smtp11.uk.ibm.com ([195.75.94.107]:45835) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RYJ0S-0006rn-6Y for qemu-devel@nongnu.org; Wed, 07 Dec 2011 10:02:00 -0500 Received: from /spool/local by e06smtp11.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 7 Dec 2011 15:01:57 -0000 Received: from d06nrmr1507.portsmouth.uk.ibm.com ([9.149.38.233]) by e06smtp11.uk.ibm.com ([192.168.101.141]) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Wed, 7 Dec 2011 15:01:56 -0000 Received: from d06av11.portsmouth.uk.ibm.com (d06av11.portsmouth.uk.ibm.com [9.149.37.252]) by d06nrmr1507.portsmouth.uk.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id pB7F1tKg2318368 for ; Wed, 7 Dec 2011 15:01:55 GMT Received: from d06av11.portsmouth.uk.ibm.com (loopback [127.0.0.1]) by d06av11.portsmouth.uk.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id pB7F1sBr006402 for ; Wed, 7 Dec 2011 08:01:55 -0700 Received: from localhost (sig-9-145-136-175.de.ibm.com [9.145.136.175]) by d06av11.portsmouth.uk.ibm.com (8.14.4/8.13.1/NCO v10.0 AVin) with ESMTP id pB7F1sbo006370; Wed, 7 Dec 2011 08:01:54 -0700 From: Stefan Hajnoczi To: Date: Wed, 7 Dec 2011 15:01:48 +0000 Message-Id: <1323270109-24265-2-git-send-email-stefanha@linux.vnet.ibm.com> X-Mailer: git-send-email 1.7.7.3 In-Reply-To: <1323270109-24265-1-git-send-email-stefanha@linux.vnet.ibm.com> References: <1323270109-24265-1-git-send-email-stefanha@linux.vnet.ibm.com> x-cbid: 11120715-5024-0000-0000-00000106B344 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 195.75.94.107 Cc: Stefan Hajnoczi Subject: [Qemu-devel] [PATCH 1/2] net: expand tabs in net/socket.c X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org In order to make later patches sane, expand the tab characters and conform to QEMU coding style now. Signed-off-by: Stefan Hajnoczi --- net/socket.c | 79 ++++++++++++++++++++++++++++++---------------------------- 1 files changed, 41 insertions(+), 38 deletions(-) diff --git a/net/socket.c b/net/socket.c index e9ef128..613a7ef 100644 --- a/net/socket.c +++ b/net/socket.c @@ -161,10 +161,11 @@ static int net_socket_mcast_create(struct sockaddr_in *mcastaddr, struct in_addr #endif if (!IN_MULTICAST(ntohl(mcastaddr->sin_addr.s_addr))) { - fprintf(stderr, "qemu: error: specified mcastaddr \"%s\" (0x%08x) does not contain a multicast address\n", - inet_ntoa(mcastaddr->sin_addr), + fprintf(stderr, "qemu: error: specified mcastaddr \"%s\" (0x%08x) " + "does not contain a multicast address\n", + inet_ntoa(mcastaddr->sin_addr), (int)ntohl(mcastaddr->sin_addr.s_addr)); - return -1; + return -1; } fd = qemu_socket(PF_INET, SOCK_DGRAM, 0); @@ -177,8 +178,8 @@ static int net_socket_mcast_create(struct sockaddr_in *mcastaddr, struct in_addr ret=setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, (const char *)&val, sizeof(val)); if (ret < 0) { - perror("setsockopt(SOL_SOCKET, SO_REUSEADDR)"); - goto fail; + perror("setsockopt(SOL_SOCKET, SO_REUSEADDR)"); + goto fail; } ret = bind(fd, (struct sockaddr *)mcastaddr, sizeof(*mcastaddr)); @@ -198,8 +199,8 @@ static int net_socket_mcast_create(struct sockaddr_in *mcastaddr, struct in_addr ret = setsockopt(fd, IPPROTO_IP, IP_ADD_MEMBERSHIP, (const char *)&imr, sizeof(struct ip_mreq)); if (ret < 0) { - perror("setsockopt(IP_ADD_MEMBERSHIP)"); - goto fail; + perror("setsockopt(IP_ADD_MEMBERSHIP)"); + goto fail; } /* Force mcast msgs to loopback (eg. several QEMUs in same host */ @@ -207,8 +208,8 @@ static int net_socket_mcast_create(struct sockaddr_in *mcastaddr, struct in_addr ret=setsockopt(fd, IPPROTO_IP, IP_MULTICAST_LOOP, (const char *)&loop, sizeof(loop)); if (ret < 0) { - perror("setsockopt(SOL_IP, IP_MULTICAST_LOOP)"); - goto fail; + perror("setsockopt(SOL_IP, IP_MULTICAST_LOOP)"); + goto fail; } /* If a bind address is given, only send packets from that address */ @@ -260,37 +261,38 @@ static NetSocketState *net_socket_fd_init_dgram(VLANState *vlan, */ if (is_connected) { - if (getsockname(fd, (struct sockaddr *) &saddr, &saddr_len) == 0) { - /* must be bound */ - if (saddr.sin_addr.s_addr==0) { - fprintf(stderr, "qemu: error: init_dgram: fd=%d unbound, cannot setup multicast dst addr\n", - fd); - return NULL; - } - /* clone dgram socket */ - newfd = net_socket_mcast_create(&saddr, NULL); - if (newfd < 0) { - /* error already reported by net_socket_mcast_create() */ - close(fd); - return NULL; - } - /* clone newfd to fd, close newfd */ - dup2(newfd, fd); - close(newfd); - - } else { - fprintf(stderr, "qemu: error: init_dgram: fd=%d failed getsockname(): %s\n", - fd, strerror(errno)); - return NULL; - } + if (getsockname(fd, (struct sockaddr *) &saddr, &saddr_len) == 0) { + /* must be bound */ + if (saddr.sin_addr.s_addr == 0) { + fprintf(stderr, "qemu: error: init_dgram: fd=%d unbound, " + "cannot setup multicast dst addr\n", fd); + return NULL; + } + /* clone dgram socket */ + newfd = net_socket_mcast_create(&saddr, NULL); + if (newfd < 0) { + /* error already reported by net_socket_mcast_create() */ + close(fd); + return NULL; + } + /* clone newfd to fd, close newfd */ + dup2(newfd, fd); + close(newfd); + + } else { + fprintf(stderr, + "qemu: error: init_dgram: fd=%d failed getsockname(): %s\n", + fd, strerror(errno)); + return NULL; + } } nc = qemu_new_net_client(&net_dgram_socket_info, vlan, NULL, model, name); snprintf(nc->info_str, sizeof(nc->info_str), - "socket: fd=%d (%s mcast=%s:%d)", - fd, is_connected ? "cloned" : "", - inet_ntoa(saddr.sin_addr), ntohs(saddr.sin_port)); + "socket: fd=%d (%s mcast=%s:%d)", + fd, is_connected ? "cloned" : "", + inet_ntoa(saddr.sin_addr), ntohs(saddr.sin_port)); s = DO_UPCAST(NetSocketState, nc, nc); @@ -349,8 +351,9 @@ static NetSocketState *net_socket_fd_init(VLANState *vlan, if(getsockopt(fd, SOL_SOCKET, SO_TYPE, (char *)&so_type, (socklen_t *)&optlen)< 0) { - fprintf(stderr, "qemu: error: getsockopt(SO_TYPE) for fd=%d failed\n", fd); - return NULL; + fprintf(stderr, "qemu: error: getsockopt(SO_TYPE) for fd=%d failed\n", + fd); + return NULL; } switch(so_type) { case SOCK_DGRAM: @@ -509,7 +512,7 @@ static int net_socket_mcast_init(VLANState *vlan, fd = net_socket_mcast_create(&saddr, param_localaddr); if (fd < 0) - return -1; + return -1; s = net_socket_fd_init(vlan, model, name, fd, 0); if (!s)