From patchwork Tue Dec 22 08:23:32 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "zhanghan (J)" X-Patchwork-Id: 1419386 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=huawei.com Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4D0dDg01XBz9sVj for ; Wed, 23 Dec 2020 00:56:50 +1100 (AEDT) Received: from localhost ([::1]:55508 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kri9g-0000oU-M7 for incoming@patchwork.ozlabs.org; Tue, 22 Dec 2020 08:56:48 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:41624) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1krdBZ-0001mC-F9; Tue, 22 Dec 2020 03:38:25 -0500 Received: from szxga07-in.huawei.com ([45.249.212.35]:2623) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1krdBW-0002j7-Dq; Tue, 22 Dec 2020 03:38:25 -0500 Received: from DGGEMS414-HUB.china.huawei.com (unknown [172.30.72.59]) by szxga07-in.huawei.com (SkyGuard) with ESMTP id 4D0V7y5gtwz7JcZ; Tue, 22 Dec 2020 16:37:18 +0800 (CST) Received: from huawei.com (10.175.124.27) by DGGEMS414-HUB.china.huawei.com (10.3.19.214) with Microsoft SMTP Server id 14.3.498.0; Tue, 22 Dec 2020 16:37:51 +0800 From: Zhang Han To: Subject: [PATCH 1/9] net: Add spaces around operator/delete redundant spaces Date: Tue, 22 Dec 2020 16:23:32 +0800 Message-ID: <20201222082340.67405-2-zhanghan64@huawei.com> X-Mailer: git-send-email 2.29.1.59.gf9b6481aed In-Reply-To: <20201222082340.67405-1-zhanghan64@huawei.com> References: <20201222082340.67405-1-zhanghan64@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.124.27] X-CFilter-Loop: Reflected Received-SPF: pass client-ip=45.249.212.35; envelope-from=zhanghan64@huawei.com; helo=szxga07-in.huawei.com X-Spam_score_int: -41 X-Spam_score: -4.2 X-Spam_bar: ---- X-Spam_report: (-4.2 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Mailman-Approved-At: Tue, 22 Dec 2020 08:55:42 -0500 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: alex.chen@huawei.com, hunongda@huawei.com, qemu-trivial@nongnu.org, hang.zhanghailiang@huawei.com, qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" Fix problems about spaces: -operator needs spaces around it, add them. -somespaces are redundant, remove them. Signed-off-by: Zhang Han --- net/checksum.c | 4 +-- net/eth.c | 2 +- net/net.c | 2 +- net/queue.c | 2 +- net/socket.c | 12 +++---- net/tap-solaris.c | 42 +++++++++++----------- net/tap-win32.c | 90 +++++++++++++++++++++++------------------------ net/vde.c | 2 +- net/vhost-user.c | 2 +- 9 files changed, 79 insertions(+), 79 deletions(-) diff --git a/net/checksum.c b/net/checksum.c index aaa4000238..f65ac3ea9f 100644 --- a/net/checksum.c +++ b/net/checksum.c @@ -41,8 +41,8 @@ uint32_t net_checksum_add_cont(int len, uint8_t *buf, int seq) uint16_t net_checksum_finish(uint32_t sum) { - while (sum>>16) - sum = (sum & 0xFFFF)+(sum >> 16); + while (sum >> 16) + sum = (sum & 0xFFFF) + (sum >> 16); return ~sum; } diff --git a/net/eth.c b/net/eth.c index 1e0821c5f8..725de18272 100644 --- a/net/eth.c +++ b/net/eth.c @@ -334,7 +334,7 @@ eth_setup_ip4_fragmentation(const void *l2hdr, size_t l2hdr_len, assert(frag_offset % IP_FRAG_UNIT_SIZE == 0); assert((frag_off_units & ~IP_OFFMASK) == 0); - orig_flags = be16_to_cpu(iphdr->ip_off) & ~(IP_OFFMASK|IP_MF); + orig_flags = be16_to_cpu(iphdr->ip_off) & ~(IP_OFFMASK | IP_MF); new_ip_off = frag_off_units | orig_flags | (more_frags ? IP_MF : 0); iphdr->ip_off = cpu_to_be16(new_ip_off); iphdr->ip_len = cpu_to_be16(l3payload_len + l3hdr_len); diff --git a/net/net.c b/net/net.c index e1035f21d1..a835759266 100644 --- a/net/net.c +++ b/net/net.c @@ -179,7 +179,7 @@ static int qemu_macaddr_get_free(void) void qemu_macaddr_default_if_unset(MACAddr *macaddr) { - static const MACAddr zero = { .a = { 0,0,0,0,0,0 } }; + static const MACAddr zero = { .a = { 0, 0, 0, 0, 0, 0 } }; static const MACAddr base = { .a = { 0x52, 0x54, 0x00, 0x12, 0x34, 0 } }; if (memcmp(macaddr, &zero, sizeof(zero)) != 0) { diff --git a/net/queue.c b/net/queue.c index 19e32c80fd..fd0e4e66e1 100644 --- a/net/queue.c +++ b/net/queue.c @@ -57,7 +57,7 @@ struct NetQueue { QTAILQ_HEAD(, NetPacket) packets; - unsigned delivering : 1; + unsigned delivering:1; }; NetQueue *qemu_new_net_queue(NetQueueDeliverFunc *deliver, void *opaque) diff --git a/net/socket.c b/net/socket.c index 15b410e8d8..282264bbcb 100644 --- a/net/socket.c +++ b/net/socket.c @@ -455,15 +455,15 @@ static NetSocketState *net_socket_fd_init(NetClientState *peer, int fd, int is_connected, const char *mc, Error **errp) { - int so_type = -1, optlen=sizeof(so_type); + int so_type = -1, optlen = sizeof(so_type); - if(getsockopt(fd, SOL_SOCKET, SO_TYPE, (char *)&so_type, - (socklen_t *)&optlen)< 0) { + if (getsockopt(fd, SOL_SOCKET, SO_TYPE, (char *)&so_type, + (socklen_t *)&optlen) < 0) { error_setg(errp, "can't get socket option SO_TYPE"); closesocket(fd); return NULL; } - switch(so_type) { + switch (so_type) { case SOCK_DGRAM: return net_socket_fd_init_dgram(peer, model, name, fd, is_connected, mc, errp); @@ -484,7 +484,7 @@ static void net_socket_accept(void *opaque) socklen_t len; int fd; - for(;;) { + for (;;) { len = sizeof(saddr); fd = qemu_accept(s->listen_fd, (struct sockaddr *)&saddr, &len); if (fd < 0 && errno != EINTR) { @@ -574,7 +574,7 @@ static int net_socket_connect_init(NetClientState *peer, qemu_set_nonblock(fd); connected = 0; - for(;;) { + for (;;) { ret = connect(fd, (struct sockaddr *)&saddr, sizeof(saddr)); if (ret < 0) { if (errno == EINTR || errno == EWOULDBLOCK) { diff --git a/net/tap-solaris.c b/net/tap-solaris.c index 0475a58207..dcfe92bf17 100644 --- a/net/tap-solaris.c +++ b/net/tap-solaris.c @@ -53,7 +53,7 @@ ssize_t tap_read_packet(int tapfd, uint8_t *buf, int maxlen) return getmsg(tapfd, NULL, &sbuf, &f) >= 0 ? sbuf.len : -1; } -#define TUNNEWPPA (('T'<<16) | 0x0001) +#define TUNNEWPPA (('T' << 16) | 0x0001) /* * Allocate TAP device, returns opened fd. * Stores dev name in the first arg(must be large enough). @@ -75,14 +75,14 @@ static int tap_alloc(char *dev, size_t dev_size, Error **errp) memset(&ifr, 0x0, sizeof(ifr)); - if( *dev ){ + if (*dev) { ptr = dev; - while( *ptr && !qemu_isdigit((int)*ptr) ) ptr++; + while (*ptr && !qemu_isdigit((int)*ptr)) ptr++; ppa = atoi(ptr); } /* Check if IP device was opened */ - if( ip_fd ) + if (ip_fd) close(ip_fd); TFR(ip_fd = open("/dev/udp", O_RDWR, 0)); @@ -102,7 +102,7 @@ static int tap_alloc(char *dev, size_t dev_size, Error **errp) strioc_ppa.ic_timout = 0; strioc_ppa.ic_len = sizeof(ppa); strioc_ppa.ic_dp = (char *)&ppa; - if ((ppa = ioctl (tap_fd, I_STR, &strioc_ppa)) < 0) + if ((ppa = ioctl(tap_fd, I_STR, &strioc_ppa)) < 0) error_report("Can't assign new interface"); TFR(if_fd = open("/dev/tap", O_RDWR, 0)); @@ -110,7 +110,7 @@ static int tap_alloc(char *dev, size_t dev_size, Error **errp) error_setg(errp, "Can't open /dev/tap (2)"); return -1; } - if(ioctl(if_fd, I_PUSH, "ip") < 0){ + if (ioctl(if_fd, I_PUSH, "ip") < 0) { error_setg(errp, "Can't push IP module"); return -1; } @@ -118,27 +118,27 @@ static int tap_alloc(char *dev, size_t dev_size, Error **errp) if (ioctl(if_fd, SIOCGLIFFLAGS, &ifr) < 0) error_report("Can't get flags"); - snprintf (actual_name, 32, "tap%d", ppa); + snprintf(actual_name, 32, "tap%d", ppa); pstrcpy(ifr.lifr_name, sizeof(ifr.lifr_name), actual_name); ifr.lifr_ppa = ppa; /* Assign ppa according to the unit number returned by tun device */ - if (ioctl (if_fd, SIOCSLIFNAME, &ifr) < 0) + if (ioctl(if_fd, SIOCSLIFNAME, &ifr) < 0) error_report("Can't set PPA %d", ppa); - if (ioctl(if_fd, SIOCGLIFFLAGS, &ifr) <0) + if (ioctl(if_fd, SIOCGLIFFLAGS, &ifr) < 0) error_report("Can't get flags"); /* Push arp module to if_fd */ - if (ioctl (if_fd, I_PUSH, "arp") < 0) + if (ioctl(if_fd, I_PUSH, "arp") < 0) error_report("Can't push ARP module (2)"); /* Push arp module to ip_fd */ - if (ioctl (ip_fd, I_POP, NULL) < 0) + if (ioctl(ip_fd, I_POP, NULL) < 0) error_report("I_POP failed"); - if (ioctl (ip_fd, I_PUSH, "arp") < 0) + if (ioctl(ip_fd, I_PUSH, "arp") < 0) error_report("Can't push ARP module (3)"); /* Open arp_fd */ - TFR(arp_fd = open ("/dev/tap", O_RDWR, 0)); + TFR(arp_fd = open("/dev/tap", O_RDWR, 0)); if (arp_fd < 0) error_report("Can't open %s", "/dev/tap"); @@ -147,29 +147,29 @@ static int tap_alloc(char *dev, size_t dev_size, Error **errp) strioc_if.ic_timout = 0; strioc_if.ic_len = sizeof(ifr); strioc_if.ic_dp = (char *)𝔦 - if (ioctl(arp_fd, I_STR, &strioc_if) < 0){ + if (ioctl(arp_fd, I_STR, &strioc_if) < 0) { error_report("Can't set ifname to arp"); } - if((ip_muxid = ioctl(ip_fd, I_LINK, if_fd)) < 0){ + if ((ip_muxid = ioctl(ip_fd, I_LINK, if_fd)) < 0) { error_setg(errp, "Can't link TAP device to IP"); return -1; } - if ((arp_muxid = ioctl (ip_fd, link_type, arp_fd)) < 0) + if ((arp_muxid = ioctl(ip_fd, link_type, arp_fd)) < 0) error_report("Can't link TAP device to ARP"); - close (if_fd); + close(if_fd); memset(&ifr, 0x0, sizeof(ifr)); pstrcpy(ifr.lifr_name, sizeof(ifr.lifr_name), actual_name); ifr.lifr_ip_muxid = ip_muxid; ifr.lifr_arp_muxid = arp_muxid; - if (ioctl (ip_fd, SIOCSLIFMUXID, &ifr) < 0) + if (ioctl(ip_fd, SIOCSLIFMUXID, &ifr) < 0) { - ioctl (ip_fd, I_PUNLINK , arp_muxid); - ioctl (ip_fd, I_PUNLINK, ip_muxid); + ioctl(ip_fd, I_PUNLINK , arp_muxid); + ioctl(ip_fd, I_PUNLINK, ip_muxid); error_report("Can't set multiplexor id"); } @@ -180,7 +180,7 @@ static int tap_alloc(char *dev, size_t dev_size, Error **errp) int tap_open(char *ifname, int ifname_size, int *vnet_hdr, int vnet_hdr_required, int mq_required, Error **errp) { - char dev[10]=""; + char dev[10] = ""; int fd; fd = tap_alloc(dev, sizeof(dev), errp); diff --git a/net/tap-win32.c b/net/tap-win32.c index 2b5dcda36e..2c8fc9c36b 100644 --- a/net/tap-win32.c +++ b/net/tap-win32.c @@ -42,18 +42,18 @@ // TAP IOCTLs //============= -#define TAP_CONTROL_CODE(request,method) \ - CTL_CODE (FILE_DEVICE_UNKNOWN, request, method, FILE_ANY_ACCESS) - -#define TAP_IOCTL_GET_MAC TAP_CONTROL_CODE (1, METHOD_BUFFERED) -#define TAP_IOCTL_GET_VERSION TAP_CONTROL_CODE (2, METHOD_BUFFERED) -#define TAP_IOCTL_GET_MTU TAP_CONTROL_CODE (3, METHOD_BUFFERED) -#define TAP_IOCTL_GET_INFO TAP_CONTROL_CODE (4, METHOD_BUFFERED) -#define TAP_IOCTL_CONFIG_POINT_TO_POINT TAP_CONTROL_CODE (5, METHOD_BUFFERED) -#define TAP_IOCTL_SET_MEDIA_STATUS TAP_CONTROL_CODE (6, METHOD_BUFFERED) -#define TAP_IOCTL_CONFIG_DHCP_MASQ TAP_CONTROL_CODE (7, METHOD_BUFFERED) -#define TAP_IOCTL_GET_LOG_LINE TAP_CONTROL_CODE (8, METHOD_BUFFERED) -#define TAP_IOCTL_CONFIG_DHCP_SET_OPT TAP_CONTROL_CODE (9, METHOD_BUFFERED) +#define TAP_CONTROL_CODE(request, method) \ + CTL_CODE(FILE_DEVICE_UNKNOWN, request, method, FILE_ANY_ACCESS) + +#define TAP_IOCTL_GET_MAC TAP_CONTROL_CODE(1, METHOD_BUFFERED) +#define TAP_IOCTL_GET_VERSION TAP_CONTROL_CODE(2, METHOD_BUFFERED) +#define TAP_IOCTL_GET_MTU TAP_CONTROL_CODE(3, METHOD_BUFFERED) +#define TAP_IOCTL_GET_INFO TAP_CONTROL_CODE(4, METHOD_BUFFERED) +#define TAP_IOCTL_CONFIG_POINT_TO_POINT TAP_CONTROL_CODE(5, METHOD_BUFFERED) +#define TAP_IOCTL_SET_MEDIA_STATUS TAP_CONTROL_CODE(6, METHOD_BUFFERED) +#define TAP_IOCTL_CONFIG_DHCP_MASQ TAP_CONTROL_CODE(7, METHOD_BUFFERED) +#define TAP_IOCTL_GET_LOG_LINE TAP_CONTROL_CODE(8, METHOD_BUFFERED) +#define TAP_IOCTL_CONFIG_DHCP_SET_OPT TAP_CONTROL_CODE(9, METHOD_BUFFERED) //================= // Registry keys @@ -92,7 +92,7 @@ * structure. See the function, tap_win32_free_buffer. */ typedef struct tun_buffer_s { - unsigned char buffer [TUN_BUFFER_SIZE]; + unsigned char buffer[TUN_BUFFER_SIZE]; unsigned long read_size; struct tun_buffer_s* next; } tun_buffer_t; @@ -155,7 +155,7 @@ static tun_buffer_t* get_buffer_from_output_queue(tap_win32_overlapped_t* const buffer = overlapped->output_queue_front; overlapped->output_queue_front = buffer->next; - if(overlapped->output_queue_front == NULL) { + if (overlapped->output_queue_front == NULL) { overlapped->output_queue_back = NULL; } @@ -171,7 +171,7 @@ static tun_buffer_t* get_buffer_from_output_queue(tap_win32_overlapped_t* const return buffer; } -static tun_buffer_t* get_buffer_from_output_queue_immediate (tap_win32_overlapped_t* const overlapped) +static tun_buffer_t* get_buffer_from_output_queue_immediate(tap_win32_overlapped_t* const overlapped) { return get_buffer_from_output_queue(overlapped, 0); } @@ -180,7 +180,7 @@ static void put_buffer_on_output_queue(tap_win32_overlapped_t* const overlapped, { EnterCriticalSection(&overlapped->output_queue_cs); - if(overlapped->output_queue_front == NULL && overlapped->output_queue_back == NULL) { + if (overlapped->output_queue_front == NULL && overlapped->output_queue_back == NULL) { overlapped->output_queue_front = overlapped->output_queue_back = buffer; } else { buffer->next = NULL; @@ -222,7 +222,7 @@ static int is_tap_win32_dev(const char *guid) char net_cfg_instance_id[256]; DWORD data_type; - len = sizeof (enum_name); + len = sizeof(enum_name); status = RegEnumKeyEx( netcard_key, i, @@ -239,7 +239,7 @@ static int is_tap_win32_dev(const char *guid) return FALSE; } - snprintf (unit_string, sizeof(unit_string), "%s\\%s", + snprintf(unit_string, sizeof(unit_string), "%s\\%s", ADAPTER_KEY, enum_name); status = RegOpenKeyEx( @@ -252,7 +252,7 @@ static int is_tap_win32_dev(const char *guid) if (status != ERROR_SUCCESS) { return FALSE; } else { - len = sizeof (component_id); + len = sizeof(component_id); status = RegQueryValueEx( unit_key, component_id_string, @@ -262,7 +262,7 @@ static int is_tap_win32_dev(const char *guid) &len); if (!(status != ERROR_SUCCESS || data_type != REG_SZ)) { - len = sizeof (net_cfg_instance_id); + len = sizeof(net_cfg_instance_id); status = RegQueryValueEx( unit_key, net_cfg_instance_id_string, @@ -273,7 +273,7 @@ static int is_tap_win32_dev(const char *guid) if (status == ERROR_SUCCESS && data_type == REG_SZ) { if (/* !strcmp (component_id, TAP_COMPONENT_ID) &&*/ - !strcmp (net_cfg_instance_id, guid)) { + !strcmp(net_cfg_instance_id, guid)) { RegCloseKey (unit_key); RegCloseKey (netcard_key); return TRUE; @@ -321,7 +321,7 @@ static int get_device_guid( DWORD name_type; const char name_string[] = "Name"; - len = sizeof (enum_name); + len = sizeof(enum_name); status = RegEnumKeyEx( control_net_key, i, @@ -351,7 +351,7 @@ static int get_device_guid( &connection_key); if (status == ERROR_SUCCESS) { - len = sizeof (name_data); + len = sizeof(name_data); status = RegQueryValueEx( connection_key, name_string, @@ -401,8 +401,8 @@ static int tap_win32_set_status(HANDLE handle, int status) unsigned long len = 0; return DeviceIoControl(handle, TAP_IOCTL_SET_MEDIA_STATUS, - &status, sizeof (status), - &status, sizeof (status), &len, NULL); + &status, sizeof(status), + &status, sizeof(status), &len, NULL); } static void tap_win32_overlapped_init(tap_win32_overlapped_t* const overlapped, const HANDLE handle) @@ -429,7 +429,7 @@ static void tap_win32_overlapped_init(tap_win32_overlapped_t* const overlapped, TUN_MAX_BUFFER_COUNT, // maximum count NULL); // unnamed semaphore - if(!overlapped->output_queue_semaphore) { + if (!overlapped->output_queue_semaphore) { fprintf(stderr, "error creating output queue semaphore!\n"); } @@ -439,7 +439,7 @@ static void tap_win32_overlapped_init(tap_win32_overlapped_t* const overlapped, TUN_MAX_BUFFER_COUNT, // maximum count NULL); // unnamed semaphore - if(!overlapped->free_list_semaphore) { + if (!overlapped->free_list_semaphore) { fprintf(stderr, "error creating free list semaphore!\n"); } @@ -447,7 +447,7 @@ static void tap_win32_overlapped_init(tap_win32_overlapped_t* const overlapped, { unsigned index; - for(index = 0; index < TUN_MAX_BUFFER_COUNT; index++) { + for (index = 0; index < TUN_MAX_BUFFER_COUNT; index++) { tun_buffer_t* element = &overlapped->buffers[index]; element->next = overlapped->free_list; overlapped->free_list = element; @@ -455,7 +455,7 @@ static void tap_win32_overlapped_init(tap_win32_overlapped_t* const overlapped, } /* To count buffers, initially no-signal. */ overlapped->tap_semaphore = CreateSemaphore(NULL, 0, TUN_MAX_BUFFER_COUNT, NULL); - if(!overlapped->tap_semaphore) + if (!overlapped->tap_semaphore) fprintf(stderr, "error creating tap_semaphore.\n"); } @@ -467,7 +467,7 @@ static int tap_win32_write(tap_win32_overlapped_t *overlapped, DWORD error; #ifdef TUN_ASYNCHRONOUS_WRITES - result = GetOverlappedResult( overlapped->handle, &overlapped->write_overlapped, + result = GetOverlappedResult(overlapped->handle, &overlapped->write_overlapped, &write_size, FALSE); if (!result && GetLastError() == ERROR_IO_INCOMPLETE) @@ -500,7 +500,7 @@ static int tap_win32_write(tap_win32_overlapped_t *overlapped, #ifdef DEBUG_TAP_WIN32 LPTSTR msgbuf; error = GetLastError(); - FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER|FORMAT_MESSAGE_FROM_SYSTEM, + FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM, NULL, error, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), &msgbuf, 0, NULL); fprintf(stderr, "Tap-Win32: Error WriteFile %d - %s\n", error, msgbuf); @@ -531,32 +531,32 @@ static DWORD WINAPI tap_win32_thread_entry(LPVOID param) dwError = GetLastError(); if (dwError == ERROR_IO_PENDING) { WaitForSingleObject(overlapped->read_event, INFINITE); - result = GetOverlappedResult( overlapped->handle, &overlapped->read_overlapped, + result = GetOverlappedResult(overlapped->handle, &overlapped->read_overlapped, &read_size, FALSE); if (!result) { #ifdef DEBUG_TAP_WIN32 LPVOID lpBuffer; dwError = GetLastError(); - FormatMessage( FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM, + FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM, NULL, dwError, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), - (LPTSTR) & lpBuffer, 0, NULL ); + (LPTSTR) &lpBuffer, 0, NULL); fprintf(stderr, "Tap-Win32: Error GetOverlappedResult %d - %s\n", dwError, lpBuffer); - LocalFree( lpBuffer ); + LocalFree(lpBuffer); #endif } } else { #ifdef DEBUG_TAP_WIN32 LPVOID lpBuffer; - FormatMessage( FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM, + FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM, NULL, dwError, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), - (LPTSTR) & lpBuffer, 0, NULL ); + (LPTSTR) &lpBuffer, 0, NULL); fprintf(stderr, "Tap-Win32: Error ReadFile %d - %s\n", dwError, lpBuffer); - LocalFree( lpBuffer ); + LocalFree(lpBuffer); #endif } } - if(read_size > 0) { + if (read_size > 0) { buffer->read_size = read_size; put_buffer_on_output_queue(overlapped, buffer); ReleaseSemaphore(overlapped->tap_semaphore, 1, NULL); @@ -574,10 +574,10 @@ static int tap_win32_read(tap_win32_overlapped_t *overlapped, tun_buffer_t* buffer = get_buffer_from_output_queue_immediate(overlapped); - if(buffer != NULL) { + if (buffer != NULL) { *pbuf = buffer->buffer; size = (int)buffer->read_size; - if(size > max_size) { + if (size > max_size) { size = max_size; } } @@ -617,7 +617,7 @@ static int tap_win32_open(tap_win32_overlapped_t **phandle, if (rc) return -1; - snprintf (device_path, sizeof(device_path), "%s%s%s", + snprintf(device_path, sizeof(device_path), "%s%s%s", USERMODEDEVICEDIR, device_guid, TAPSUFFIX); @@ -629,15 +629,15 @@ static int tap_win32_open(tap_win32_overlapped_t **phandle, 0, OPEN_EXISTING, FILE_ATTRIBUTE_SYSTEM | FILE_FLAG_OVERLAPPED, - 0 ); + 0); if (handle == INVALID_HANDLE_VALUE) { return -1; } bret = DeviceIoControl(handle, TAP_IOCTL_GET_VERSION, - &version, sizeof (version), - &version, sizeof (version), &version_len, NULL); + &version, sizeof(version), + &version, sizeof(version), &version_len, NULL); if (bret == FALSE) { CloseHandle(handle); diff --git a/net/vde.c b/net/vde.c index 99189cccb6..0b06464f4d 100644 --- a/net/vde.c +++ b/net/vde.c @@ -92,7 +92,7 @@ static int net_vde_init(NetClientState *peer, const char *model, }; vde = vde_open(init_sock, (char *)"QEMU", &args); - if (!vde){ + if (!vde) { error_setg_errno(errp, errno, "Could not open vde"); return -1; } diff --git a/net/vhost-user.c b/net/vhost-user.c index ffbd94d944..1cf1af1ab9 100644 --- a/net/vhost-user.c +++ b/net/vhost-user.c @@ -235,7 +235,7 @@ static void chr_closed_bh(void *opaque) s = DO_UPCAST(NetVhostUserState, nc, ncs[0]); - for (i = queues -1; i >= 0; i--) { + for (i = queues - 1; i >= 0; i--) { s = DO_UPCAST(NetVhostUserState, nc, ncs[i]); if (s->vhost_net) { From patchwork Tue Dec 22 08:23:33 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "zhanghan (J)" X-Patchwork-Id: 1419393 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=huawei.com Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4D0dLx2lQLz9sVj for ; Wed, 23 Dec 2020 01:02:17 +1100 (AEDT) Received: from localhost ([::1]:45008 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kriEx-0008Do-9E for incoming@patchwork.ozlabs.org; Tue, 22 Dec 2020 09:02:15 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:41658) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1krdBb-0001oO-T9; Tue, 22 Dec 2020 03:38:27 -0500 Received: from szxga07-in.huawei.com ([45.249.212.35]:2626) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1krdBY-0002kF-79; Tue, 22 Dec 2020 03:38:27 -0500 Received: from DGGEMS414-HUB.china.huawei.com (unknown [172.30.72.59]) by szxga07-in.huawei.com (SkyGuard) with ESMTP id 4D0V7y6XQdz7Jcl; Tue, 22 Dec 2020 16:37:18 +0800 (CST) Received: from huawei.com (10.175.124.27) by DGGEMS414-HUB.china.huawei.com (10.3.19.214) with Microsoft SMTP Server id 14.3.498.0; Tue, 22 Dec 2020 16:37:52 +0800 From: Zhang Han To: Subject: [PATCH 2/9] net: Add braces for statements/fix braces' position Date: Tue, 22 Dec 2020 16:23:33 +0800 Message-ID: <20201222082340.67405-3-zhanghan64@huawei.com> X-Mailer: git-send-email 2.29.1.59.gf9b6481aed In-Reply-To: <20201222082340.67405-1-zhanghan64@huawei.com> References: <20201222082340.67405-1-zhanghan64@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.124.27] X-CFilter-Loop: Reflected Received-SPF: pass client-ip=45.249.212.35; envelope-from=zhanghan64@huawei.com; helo=szxga07-in.huawei.com X-Spam_score_int: -41 X-Spam_score: -4.2 X-Spam_bar: ---- X-Spam_report: (-4.2 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Mailman-Approved-At: Tue, 22 Dec 2020 08:55:42 -0500 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: alex.chen@huawei.com, hunongda@huawei.com, qemu-trivial@nongnu.org, hang.zhanghailiang@huawei.com, qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" Fix problems about braces: -braces are necessary for all arms of if/for/while statements -open brace { should follow if/for/while statements on the same line -else should follow close brace '}' Signed-off-by: Zhang Han --- net/checksum.c | 3 ++- net/net.c | 24 ++++++++++++++++-------- net/queue.c | 3 ++- net/slirp.c | 6 ++++-- net/socket.c | 9 ++++++--- net/tap-bsd.c | 3 +-- net/tap-linux.c | 20 +++++++++++++------- net/tap-solaris.c | 37 ++++++++++++++++++++++++------------- net/tap-win32.c | 33 ++++++++++++++++----------------- 9 files changed, 84 insertions(+), 54 deletions(-) diff --git a/net/checksum.c b/net/checksum.c index f65ac3ea9f..b78bf15098 100644 --- a/net/checksum.c +++ b/net/checksum.c @@ -41,8 +41,9 @@ uint32_t net_checksum_add_cont(int len, uint8_t *buf, int seq) uint16_t net_checksum_finish(uint32_t sum) { - while (sum >> 16) + while (sum >> 16) { sum = (sum & 0xFFFF) + (sum >> 16); + } return ~sum; } diff --git a/net/net.c b/net/net.c index a835759266..626f1fe99a 100644 --- a/net/net.c +++ b/net/net.c @@ -794,8 +794,9 @@ NetClientState *qemu_find_netdev(const char *id) NetClientState *nc; QTAILQ_FOREACH(nc, &net_clients, next) { - if (nc->info->type == NET_CLIENT_DRIVER_NIC) + if (nc->info->type == NET_CLIENT_DRIVER_NIC) { continue; + } if (!strcmp(nc->name, id)) { return nc; } @@ -829,9 +830,11 @@ static int nic_get_free_idx(void) { int index; - for (index = 0; index < MAX_NICS; index++) - if (!nd_table[index].used) + for (index = 0; index < MAX_NICS; index++) { + if (!nd_table[index].used) { return index; + } + } return -1; } @@ -857,10 +860,12 @@ void qemu_check_nic_model(NICInfo *nd, const char *model) models[0] = model; models[1] = NULL; - if (qemu_show_nic_models(nd->model, models)) + if (qemu_show_nic_models(nd->model, models)) { exit(0); - if (qemu_find_nic_model(nd, models, model) < 0) + } + if (qemu_find_nic_model(nd, models, model) < 0) { exit(1); + } } int qemu_find_nic_model(NICInfo *nd, const char * const *models, @@ -868,12 +873,14 @@ int qemu_find_nic_model(NICInfo *nd, const char * const *models, { int i; - if (!nd->model) + if (!nd->model) { nd->model = g_strdup(default_model); + } for (i = 0 ; models[i]; i++) { - if (strcmp(nd->model, models[i]) == 0) + if (strcmp(nd->model, models[i]) == 0) { return i; + } } error_report("Unsupported NIC model: %s", nd->model); @@ -1219,8 +1226,9 @@ RxFilterInfoList *qmp_query_rx_filter(bool has_name, const char *name, /* only query information on queue 0 since the info is per nic, * not per queue */ - if (nc->queue_index != 0) + if (nc->queue_index != 0) { continue; + } if (nc->info->query_rx_filter) { info = nc->info->query_rx_filter(nc); diff --git a/net/queue.c b/net/queue.c index fd0e4e66e1..6b19271e2d 100644 --- a/net/queue.c +++ b/net/queue.c @@ -250,8 +250,9 @@ void qemu_net_queue_purge(NetQueue *queue, NetClientState *from) bool qemu_net_queue_flush(NetQueue *queue) { - if (queue->delivering) + if (queue->delivering) { return false; + } while (!QTAILQ_EMPTY(&queue->packets)) { NetPacket *packet; diff --git a/net/slirp.c b/net/slirp.c index 77042e6df7..61a9e3071e 100644 --- a/net/slirp.c +++ b/net/slirp.c @@ -53,13 +53,15 @@ static int get_str_sep(char *buf, int buf_size, const char **pp, int sep) int len; p = *pp; p1 = strchr(p, sep); - if (!p1) + if (!p1) { return -1; + } len = p1 - p; p1++; if (buf_size > 0) { - if (len > buf_size - 1) + if (len > buf_size - 1) { len = buf_size - 1; + } memcpy(buf, p, len); buf[len] = '\0'; } diff --git a/net/socket.c b/net/socket.c index 282264bbcb..61671e41e3 100644 --- a/net/socket.c +++ b/net/socket.c @@ -165,8 +165,9 @@ static void net_socket_send(void *opaque) size = qemu_recv(s->fd, buf1, sizeof(buf1), 0); if (size < 0) { - if (errno != EWOULDBLOCK) + if (errno != EWOULDBLOCK) { goto eoc; + } } else if (size == 0) { /* end of connection */ eoc: @@ -199,8 +200,9 @@ static void net_socket_send_dgram(void *opaque) int size; size = qemu_recv(s->fd, s->rs.buf, sizeof(s->rs.buf), 0); - if (size < 0) + if (size < 0) { return; + } if (size == 0) { /* end of connection */ net_socket_read_poll(s, false); @@ -301,8 +303,9 @@ static int net_socket_mcast_create(struct sockaddr_in *mcastaddr, qemu_set_nonblock(fd); return fd; fail: - if (fd >= 0) + if (fd >= 0) { closesocket(fd); + } return -1; } diff --git a/net/tap-bsd.c b/net/tap-bsd.c index 77aaf674b1..dc8f9c8658 100644 --- a/net/tap-bsd.c +++ b/net/tap-bsd.c @@ -68,8 +68,7 @@ int tap_open(char *ifname, int ifname_size, int *vnet_hdr, TFR(fd = open(dname, O_RDWR)); if (fd >= 0) { break; - } - else if (errno == ENXIO || errno == ENOENT) { + } else if (errno == ENXIO || errno == ENOENT) { break; } if (*ifname) { diff --git a/net/tap-linux.c b/net/tap-linux.c index b0635e9e32..6aff7023a6 100644 --- a/net/tap-linux.c +++ b/net/tap-linux.c @@ -97,10 +97,11 @@ int tap_open(char *ifname, int ifname_size, int *vnet_hdr, } } - if (ifname[0] != '\0') + if (ifname[0] != '\0') { pstrcpy(ifr.ifr_name, IFNAMSIZ, ifname); - else + } else { pstrcpy(ifr.ifr_name, IFNAMSIZ, "tap%d"); + } ret = ioctl(fd, TUNSETIFF, (void *) &ifr); if (ret != 0) { if (ifname[0] != '\0') { @@ -167,8 +168,9 @@ int tap_probe_has_ufo(int fd) offload = TUN_F_CSUM | TUN_F_UFO; - if (ioctl(fd, TUNSETOFFLOAD, offload) < 0) + if (ioctl(fd, TUNSETOFFLOAD, offload) < 0) { return 0; + } return 1; } @@ -248,14 +250,18 @@ void tap_fd_set_offload(int fd, int csum, int tso4, if (csum) { offload |= TUN_F_CSUM; - if (tso4) + if (tso4) { offload |= TUN_F_TSO4; - if (tso6) + } + if (tso6) { offload |= TUN_F_TSO6; - if ((tso4 || tso6) && ecn) + } + if ((tso4 || tso6) && ecn) { offload |= TUN_F_TSO_ECN; - if (ufo) + } + if (ufo) { offload |= TUN_F_UFO; + } } if (ioctl(fd, TUNSETOFFLOAD, offload) != 0) { diff --git a/net/tap-solaris.c b/net/tap-solaris.c index dcfe92bf17..1c8d5f7982 100644 --- a/net/tap-solaris.c +++ b/net/tap-solaris.c @@ -77,13 +77,16 @@ static int tap_alloc(char *dev, size_t dev_size, Error **errp) if (*dev) { ptr = dev; - while (*ptr && !qemu_isdigit((int)*ptr)) ptr++; + while (*ptr && !qemu_isdigit((int)*ptr)) { + ptr++; + } ppa = atoi(ptr); } /* Check if IP device was opened */ - if (ip_fd) + if (ip_fd) { close(ip_fd); + } TFR(ip_fd = open("/dev/udp", O_RDWR, 0)); if (ip_fd < 0) { @@ -102,8 +105,9 @@ static int tap_alloc(char *dev, size_t dev_size, Error **errp) strioc_ppa.ic_timout = 0; strioc_ppa.ic_len = sizeof(ppa); strioc_ppa.ic_dp = (char *)&ppa; - if ((ppa = ioctl(tap_fd, I_STR, &strioc_ppa)) < 0) + if ((ppa = ioctl(tap_fd, I_STR, &strioc_ppa)) < 0) { error_report("Can't assign new interface"); + } TFR(if_fd = open("/dev/tap", O_RDWR, 0)); if (if_fd < 0) { @@ -115,8 +119,9 @@ static int tap_alloc(char *dev, size_t dev_size, Error **errp) return -1; } - if (ioctl(if_fd, SIOCGLIFFLAGS, &ifr) < 0) + if (ioctl(if_fd, SIOCGLIFFLAGS, &ifr) < 0) { error_report("Can't get flags"); + } snprintf(actual_name, 32, "tap%d", ppa); pstrcpy(ifr.lifr_name, sizeof(ifr.lifr_name), actual_name); @@ -124,23 +129,29 @@ static int tap_alloc(char *dev, size_t dev_size, Error **errp) ifr.lifr_ppa = ppa; /* Assign ppa according to the unit number returned by tun device */ - if (ioctl(if_fd, SIOCSLIFNAME, &ifr) < 0) + if (ioctl(if_fd, SIOCSLIFNAME, &ifr) < 0) { error_report("Can't set PPA %d", ppa); - if (ioctl(if_fd, SIOCGLIFFLAGS, &ifr) < 0) + } + if (ioctl(if_fd, SIOCGLIFFLAGS, &ifr) < 0) { error_report("Can't get flags"); + } /* Push arp module to if_fd */ - if (ioctl(if_fd, I_PUSH, "arp") < 0) + if (ioctl(if_fd, I_PUSH, "arp") < 0) { error_report("Can't push ARP module (2)"); + } /* Push arp module to ip_fd */ - if (ioctl(ip_fd, I_POP, NULL) < 0) + if (ioctl(ip_fd, I_POP, NULL) < 0) { error_report("I_POP failed"); - if (ioctl(ip_fd, I_PUSH, "arp") < 0) + } + if (ioctl(ip_fd, I_PUSH, "arp") < 0) { error_report("Can't push ARP module (3)"); + } /* Open arp_fd */ TFR(arp_fd = open("/dev/tap", O_RDWR, 0)); - if (arp_fd < 0) + if (arp_fd < 0) { error_report("Can't open %s", "/dev/tap"); + } /* Set ifname to arp */ strioc_if.ic_cmd = SIOCSLIFNAME; @@ -156,8 +167,9 @@ static int tap_alloc(char *dev, size_t dev_size, Error **errp) return -1; } - if ((arp_muxid = ioctl(ip_fd, link_type, arp_fd)) < 0) + if ((arp_muxid = ioctl(ip_fd, link_type, arp_fd)) < 0) { error_report("Can't link TAP device to ARP"); + } close(if_fd); @@ -166,8 +178,7 @@ static int tap_alloc(char *dev, size_t dev_size, Error **errp) ifr.lifr_ip_muxid = ip_muxid; ifr.lifr_arp_muxid = arp_muxid; - if (ioctl(ip_fd, SIOCSLIFMUXID, &ifr) < 0) - { + if (ioctl(ip_fd, SIOCSLIFMUXID, &ifr) < 0) { ioctl(ip_fd, I_PUNLINK , arp_muxid); ioctl(ip_fd, I_PUNLINK, ip_muxid); error_report("Can't set multiplexor id"); diff --git a/net/tap-win32.c b/net/tap-win32.c index 2c8fc9c36b..0a5252ab55 100644 --- a/net/tap-win32.c +++ b/net/tap-win32.c @@ -70,7 +70,6 @@ #define USERMODEDEVICEDIR "\\\\.\\Global\\" #define TAPSUFFIX ".tap" - //====================== // Compile time configuration //====================== @@ -146,8 +145,7 @@ static tun_buffer_t* get_buffer_from_output_queue(tap_win32_overlapped_t* const // Non-blocking call result = WaitForSingleObject(overlapped->output_queue_semaphore, timeout); - switch (result) - { + switch (result) { // The semaphore object was signaled. case WAIT_OBJECT_0: EnterCriticalSection(&overlapped->output_queue_cs); @@ -233,9 +231,9 @@ static int is_tap_win32_dev(const char *guid) NULL, NULL); - if (status == ERROR_NO_MORE_ITEMS) + if (status == ERROR_NO_MORE_ITEMS) { break; - else if (status != ERROR_SUCCESS) { + } else if (status != ERROR_SUCCESS) { return FALSE; } @@ -312,8 +310,7 @@ static int get_device_guid( return -1; } - while (!stop) - { + while (!stop) { char enum_name[256]; char connection_string[256]; HKEY connection_key; @@ -332,9 +329,9 @@ static int get_device_guid( NULL, NULL); - if (status == ERROR_NO_MORE_ITEMS) + if (status == ERROR_NO_MORE_ITEMS) { break; - else if (status != ERROR_SUCCESS) { + } else if (status != ERROR_SUCCESS) { return -1; } @@ -363,8 +360,7 @@ static int get_device_guid( if (status != ERROR_SUCCESS || name_type != REG_SZ) { ++i; continue; - } - else { + } else { if (is_tap_win32_dev(enum_name)) { snprintf(name, name_size, "%s", enum_name); if (actual_name) { @@ -374,8 +370,7 @@ static int get_device_guid( ++i; continue; } - } - else { + } else { snprintf(actual_name, actual_name_size, "%s", name_data); } } @@ -390,8 +385,9 @@ static int get_device_guid( RegCloseKey (control_net_key); - if (stop == 0) + if (stop == 0) { return -1; + } return 0; } @@ -455,8 +451,9 @@ static void tap_win32_overlapped_init(tap_win32_overlapped_t* const overlapped, } /* To count buffers, initially no-signal. */ overlapped->tap_semaphore = CreateSemaphore(NULL, 0, TUN_MAX_BUFFER_COUNT, NULL); - if (!overlapped->tap_semaphore) + if (!overlapped->tap_semaphore) { fprintf(stderr, "error creating tap_semaphore.\n"); + } } static int tap_win32_write(tap_win32_overlapped_t *overlapped, @@ -470,8 +467,9 @@ static int tap_win32_write(tap_win32_overlapped_t *overlapped, result = GetOverlappedResult(overlapped->handle, &overlapped->write_overlapped, &write_size, FALSE); - if (!result && GetLastError() == ERROR_IO_INCOMPLETE) + if (!result && GetLastError() == ERROR_IO_INCOMPLETE) { WaitForSingleObject(overlapped->write_event, INFINITE); + } #endif result = WriteFile(overlapped->handle, buffer, size, @@ -614,8 +612,9 @@ static int tap_win32_open(tap_win32_overlapped_t **phandle, } rc = get_device_guid(device_guid, sizeof(device_guid), name_buffer, sizeof(name_buffer)); - if (rc) + if (rc) { return -1; + } snprintf(device_path, sizeof(device_path), "%s%s%s", USERMODEDEVICEDIR, From patchwork Tue Dec 22 08:23:34 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "zhanghan (J)" X-Patchwork-Id: 1419394 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=huawei.com Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4D0dM549lBz9sVk for ; Wed, 23 Dec 2020 01:02:24 +1100 (AEDT) Received: from localhost ([::1]:44256 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kriF4-0007sv-Ep for incoming@patchwork.ozlabs.org; Tue, 22 Dec 2020 09:02:22 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:41582) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1krdBX-0001kM-Jb; Tue, 22 Dec 2020 03:38:23 -0500 Received: from szxga07-in.huawei.com ([45.249.212.35]:2619) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1krdBS-0002cY-1z; Tue, 22 Dec 2020 03:38:23 -0500 Received: from DGGEMS414-HUB.china.huawei.com (unknown [172.30.72.59]) by szxga07-in.huawei.com (SkyGuard) with ESMTP id 4D0V7y50Lmz7JYl; Tue, 22 Dec 2020 16:37:18 +0800 (CST) Received: from huawei.com (10.175.124.27) by DGGEMS414-HUB.china.huawei.com (10.3.19.214) with Microsoft SMTP Server id 14.3.498.0; Tue, 22 Dec 2020 16:37:52 +0800 From: Zhang Han To: Subject: [PATCH 3/9] net: Transfer // comments to /**/ Date: Tue, 22 Dec 2020 16:23:34 +0800 Message-ID: <20201222082340.67405-4-zhanghan64@huawei.com> X-Mailer: git-send-email 2.29.1.59.gf9b6481aed In-Reply-To: <20201222082340.67405-1-zhanghan64@huawei.com> References: <20201222082340.67405-1-zhanghan64@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.124.27] X-CFilter-Loop: Reflected Received-SPF: pass client-ip=45.249.212.35; envelope-from=zhanghan64@huawei.com; helo=szxga07-in.huawei.com X-Spam_score_int: -41 X-Spam_score: -4.2 X-Spam_bar: ---- X-Spam_report: (-4.2 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Mailman-Approved-At: Tue, 22 Dec 2020 08:55:42 -0500 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: alex.chen@huawei.com, hunongda@huawei.com, qemu-trivial@nongnu.org, hang.zhanghailiang@huawei.com, qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" Do not use C99 // comments, thransfer // to /**/ Signed-off-by: Zhang Han --- net/checksum.c | 6 ++--- net/tap-solaris.c | 2 +- net/tap-win32.c | 60 +++++++++++++++++++++++++++-------------------- 3 files changed, 38 insertions(+), 30 deletions(-) diff --git a/net/checksum.c b/net/checksum.c index b78bf15098..eb2eff5fa4 100644 --- a/net/checksum.c +++ b/net/checksum.c @@ -52,9 +52,9 @@ uint16_t net_checksum_tcpudp(uint16_t length, uint16_t proto, { uint32_t sum = 0; - sum += net_checksum_add(length, buf); // payload - sum += net_checksum_add(8, addrs); // src + dst address - sum += proto + length; // protocol & length + sum += net_checksum_add(length, buf); /* payload */ + sum += net_checksum_add(8, addrs); /* src + dst address */ + sum += proto + length; /* protocol & length */ return net_checksum_finish(sum); } diff --git a/net/tap-solaris.c b/net/tap-solaris.c index 1c8d5f7982..a0a5456ab6 100644 --- a/net/tap-solaris.c +++ b/net/tap-solaris.c @@ -35,7 +35,7 @@ #include #include #include -#include // must come after ip.h +#include /* must come after ip.h */ #include #include #include diff --git a/net/tap-win32.c b/net/tap-win32.c index 0a5252ab55..0f0d95cdbb 100644 --- a/net/tap-win32.c +++ b/net/tap-win32.c @@ -38,9 +38,11 @@ #include #include -//============= -// TAP IOCTLs -//============= +/* + * ============= + * TAP IOCTLs + * ============= + */ #define TAP_CONTROL_CODE(request, method) \ CTL_CODE(FILE_DEVICE_UNKNOWN, request, method, FILE_ANY_ACCESS) @@ -55,26 +57,32 @@ #define TAP_IOCTL_GET_LOG_LINE TAP_CONTROL_CODE(8, METHOD_BUFFERED) #define TAP_IOCTL_CONFIG_DHCP_SET_OPT TAP_CONTROL_CODE(9, METHOD_BUFFERED) -//================= -// Registry keys -//================= +/* + * ================= + * Registry keys + * ================= + */ #define ADAPTER_KEY "SYSTEM\\CurrentControlSet\\Control\\Class\\{4D36E972-E325-11CE-BFC1-08002BE10318}" #define NETWORK_CONNECTIONS_KEY "SYSTEM\\CurrentControlSet\\Control\\Network\\{4D36E972-E325-11CE-BFC1-08002BE10318}" -//====================== -// Filesystem prefixes -//====================== +/* + * ====================== + * Filesystem prefixes + * ====================== + */ #define USERMODEDEVICEDIR "\\\\.\\Global\\" #define TAPSUFFIX ".tap" -//====================== -// Compile time configuration -//====================== +/* + * ====================== + * Compile time configuration + * ====================== + */ -//#define DEBUG_TAP_WIN32 +/* #define DEBUG_TAP_WIN32 */ /* FIXME: The asynch write path appears to be broken at * present. WriteFile() ignores the lpNumberOfBytesWritten parameter @@ -121,7 +129,7 @@ static tun_buffer_t* get_buffer_from_free_list(tap_win32_overlapped_t* const ove WaitForSingleObject(overlapped->free_list_semaphore, INFINITE); EnterCriticalSection(&overlapped->free_list_cs); buffer = overlapped->free_list; -// assert(buffer != NULL); + /* assert(buffer != NULL); */ overlapped->free_list = buffer->next; LeaveCriticalSection(&overlapped->free_list_cs); buffer->next = NULL; @@ -142,11 +150,11 @@ static tun_buffer_t* get_buffer_from_output_queue(tap_win32_overlapped_t* const tun_buffer_t* buffer = NULL; DWORD result, timeout = block ? INFINITE : 0L; - // Non-blocking call + /* Non-blocking call */ result = WaitForSingleObject(overlapped->output_queue_semaphore, timeout); switch (result) { - // The semaphore object was signaled. + /* The semaphore object was signaled. */ case WAIT_OBJECT_0: EnterCriticalSection(&overlapped->output_queue_cs); @@ -160,9 +168,9 @@ static tun_buffer_t* get_buffer_from_output_queue(tap_win32_overlapped_t* const LeaveCriticalSection(&overlapped->output_queue_cs); break; - // Semaphore was nonsignaled, so a time-out occurred. + /* Semaphore was nonsignaled, so a time-out occurred. */ case WAIT_TIMEOUT: - // Cannot open another window. + /* Cannot open another window. */ break; } @@ -420,20 +428,20 @@ static void tap_win32_overlapped_init(tap_win32_overlapped_t* const overlapped, InitializeCriticalSection(&overlapped->free_list_cs); overlapped->output_queue_semaphore = CreateSemaphore( - NULL, // default security attributes - 0, // initial count - TUN_MAX_BUFFER_COUNT, // maximum count - NULL); // unnamed semaphore + NULL, /* default security attributes */ + 0, /* initial count */ + TUN_MAX_BUFFER_COUNT, /* maximum count */ + NULL); /* unnamed semaphore */ if (!overlapped->output_queue_semaphore) { fprintf(stderr, "error creating output queue semaphore!\n"); } overlapped->free_list_semaphore = CreateSemaphore( - NULL, // default security attributes - TUN_MAX_BUFFER_COUNT, // initial count - TUN_MAX_BUFFER_COUNT, // maximum count - NULL); // unnamed semaphore + NULL, /* default security attributes */ + TUN_MAX_BUFFER_COUNT, /* initial count */ + TUN_MAX_BUFFER_COUNT, /* maximum count */ + NULL); /* unnamed semaphore */ if (!overlapped->free_list_semaphore) { fprintf(stderr, "error creating free list semaphore!\n"); From patchwork Tue Dec 22 08:23:35 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "zhanghan (J)" X-Patchwork-Id: 1419390 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=huawei.com Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4D0dHm3mxZz9sVk for ; Wed, 23 Dec 2020 00:59:32 +1100 (AEDT) Received: from localhost ([::1]:35858 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kriCI-0004RL-91 for incoming@patchwork.ozlabs.org; Tue, 22 Dec 2020 08:59:30 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:41512) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1krdBT-0001i7-Lx; Tue, 22 Dec 2020 03:38:19 -0500 Received: from szxga07-in.huawei.com ([45.249.212.35]:2620) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1krdBR-0002cW-4D; Tue, 22 Dec 2020 03:38:19 -0500 Received: from DGGEMS414-HUB.china.huawei.com (unknown [172.30.72.59]) by szxga07-in.huawei.com (SkyGuard) with ESMTP id 4D0V7y5R6rz7JcV; Tue, 22 Dec 2020 16:37:18 +0800 (CST) Received: from huawei.com (10.175.124.27) by DGGEMS414-HUB.china.huawei.com (10.3.19.214) with Microsoft SMTP Server id 14.3.498.0; Tue, 22 Dec 2020 16:37:53 +0800 From: Zhang Han To: Subject: [PATCH 4/9] net: Transfer "foo* " to "foo *" Date: Tue, 22 Dec 2020 16:23:35 +0800 Message-ID: <20201222082340.67405-5-zhanghan64@huawei.com> X-Mailer: git-send-email 2.29.1.59.gf9b6481aed In-Reply-To: <20201222082340.67405-1-zhanghan64@huawei.com> References: <20201222082340.67405-1-zhanghan64@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.124.27] X-CFilter-Loop: Reflected Received-SPF: pass client-ip=45.249.212.35; envelope-from=zhanghan64@huawei.com; helo=szxga07-in.huawei.com X-Spam_score_int: -41 X-Spam_score: -4.2 X-Spam_bar: ---- X-Spam_report: (-4.2 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Mailman-Approved-At: Tue, 22 Dec 2020 08:55:38 -0500 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: alex.chen@huawei.com, hunongda@huawei.com, qemu-trivial@nongnu.org, hang.zhanghailiang@huawei.com, qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" Fix style problems about "foo*" -"foo* bar" should be "foo *bar". -"foo* const bar" should be "foo * const bar". -"(foo*)" should be "(foo *)" Signed-off-by: Zhang Han --- net/slirp.c | 2 +- net/tap-win32.c | 34 +++++++++++++++++----------------- 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/net/slirp.c b/net/slirp.c index 61a9e3071e..772b3c35f2 100644 --- a/net/slirp.c +++ b/net/slirp.c @@ -809,7 +809,7 @@ static void slirp_smb_cleanup(SlirpState *s) } } -static int slirp_smb(SlirpState* s, const char *exported_dir, +static int slirp_smb(SlirpState *s, const char *exported_dir, struct in_addr vserver_addr, Error **errp) { char *smb_conf; diff --git a/net/tap-win32.c b/net/tap-win32.c index 0f0d95cdbb..ac139e9ec9 100644 --- a/net/tap-win32.c +++ b/net/tap-win32.c @@ -101,7 +101,7 @@ typedef struct tun_buffer_s { unsigned char buffer[TUN_BUFFER_SIZE]; unsigned long read_size; - struct tun_buffer_s* next; + struct tun_buffer_s *next; } tun_buffer_t; typedef struct tap_win32_overlapped { @@ -116,16 +116,16 @@ typedef struct tap_win32_overlapped { OVERLAPPED read_overlapped; OVERLAPPED write_overlapped; tun_buffer_t buffers[TUN_MAX_BUFFER_COUNT]; - tun_buffer_t* free_list; - tun_buffer_t* output_queue_front; - tun_buffer_t* output_queue_back; + tun_buffer_t *free_list; + tun_buffer_t *output_queue_front; + tun_buffer_t *output_queue_back; } tap_win32_overlapped_t; static tap_win32_overlapped_t tap_overlapped; -static tun_buffer_t* get_buffer_from_free_list(tap_win32_overlapped_t* const overlapped) +static tun_buffer_t *get_buffer_from_free_list(tap_win32_overlapped_t *const overlapped) { - tun_buffer_t* buffer = NULL; + tun_buffer_t *buffer = NULL; WaitForSingleObject(overlapped->free_list_semaphore, INFINITE); EnterCriticalSection(&overlapped->free_list_cs); buffer = overlapped->free_list; @@ -136,7 +136,7 @@ static tun_buffer_t* get_buffer_from_free_list(tap_win32_overlapped_t* const ove return buffer; } -static void put_buffer_on_free_list(tap_win32_overlapped_t* const overlapped, tun_buffer_t* const buffer) +static void put_buffer_on_free_list(tap_win32_overlapped_t *const overlapped, tun_buffer_t *const buffer) { EnterCriticalSection(&overlapped->free_list_cs); buffer->next = overlapped->free_list; @@ -145,9 +145,9 @@ static void put_buffer_on_free_list(tap_win32_overlapped_t* const overlapped, tu ReleaseSemaphore(overlapped->free_list_semaphore, 1, NULL); } -static tun_buffer_t* get_buffer_from_output_queue(tap_win32_overlapped_t* const overlapped, const int block) +static tun_buffer_t *get_buffer_from_output_queue(tap_win32_overlapped_t *const overlapped, const int block) { - tun_buffer_t* buffer = NULL; + tun_buffer_t *buffer = NULL; DWORD result, timeout = block ? INFINITE : 0L; /* Non-blocking call */ @@ -177,12 +177,12 @@ static tun_buffer_t* get_buffer_from_output_queue(tap_win32_overlapped_t* const return buffer; } -static tun_buffer_t* get_buffer_from_output_queue_immediate(tap_win32_overlapped_t* const overlapped) +static tun_buffer_t *get_buffer_from_output_queue_immediate(tap_win32_overlapped_t *const overlapped) { return get_buffer_from_output_queue(overlapped, 0); } -static void put_buffer_on_output_queue(tap_win32_overlapped_t* const overlapped, tun_buffer_t* const buffer) +static void put_buffer_on_output_queue(tap_win32_overlapped_t *const overlapped, tun_buffer_t *const buffer) { EnterCriticalSection(&overlapped->output_queue_cs); @@ -409,7 +409,7 @@ static int tap_win32_set_status(HANDLE handle, int status) &status, sizeof(status), &len, NULL); } -static void tap_win32_overlapped_init(tap_win32_overlapped_t* const overlapped, const HANDLE handle) +static void tap_win32_overlapped_init(tap_win32_overlapped_t *const overlapped, const HANDLE handle) { overlapped->handle = handle; @@ -452,7 +452,7 @@ static void tap_win32_overlapped_init(tap_win32_overlapped_t* const overlapped, { unsigned index; for (index = 0; index < TUN_MAX_BUFFER_COUNT; index++) { - tun_buffer_t* element = &overlapped->buffers[index]; + tun_buffer_t *element = &overlapped->buffers[index]; element->next = overlapped->free_list; overlapped->free_list = element; } @@ -520,11 +520,11 @@ static int tap_win32_write(tap_win32_overlapped_t *overlapped, static DWORD WINAPI tap_win32_thread_entry(LPVOID param) { - tap_win32_overlapped_t *overlapped = (tap_win32_overlapped_t*)param; + tap_win32_overlapped_t *overlapped = (tap_win32_overlapped_t *)param; unsigned long read_size; BOOL result; DWORD dwError; - tun_buffer_t* buffer = get_buffer_from_free_list(overlapped); + tun_buffer_t *buffer = get_buffer_from_free_list(overlapped); for (;;) { @@ -578,7 +578,7 @@ static int tap_win32_read(tap_win32_overlapped_t *overlapped, { int size = 0; - tun_buffer_t* buffer = get_buffer_from_output_queue_immediate(overlapped); + tun_buffer_t *buffer = get_buffer_from_output_queue_immediate(overlapped); if (buffer != NULL) { *pbuf = buffer->buffer; @@ -594,7 +594,7 @@ static int tap_win32_read(tap_win32_overlapped_t *overlapped, static void tap_win32_free_buffer(tap_win32_overlapped_t *overlapped, uint8_t *pbuf) { - tun_buffer_t* buffer = (tun_buffer_t*)pbuf; + tun_buffer_t *buffer = (tun_buffer_t *)pbuf; put_buffer_on_free_list(overlapped, buffer); } From patchwork Tue Dec 22 08:23:36 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "zhanghan (J)" X-Patchwork-Id: 1419385 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=huawei.com Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4D0dDf3jQWz9sVk for ; Wed, 23 Dec 2020 00:56:49 +1100 (AEDT) Received: from localhost ([::1]:55482 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kri9f-0000nZ-Jb for incoming@patchwork.ozlabs.org; Tue, 22 Dec 2020 08:56:47 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:41546) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1krdBV-0001ie-8y; Tue, 22 Dec 2020 03:38:21 -0500 Received: from szxga07-in.huawei.com ([45.249.212.35]:2622) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1krdBS-0002cV-Kj; Tue, 22 Dec 2020 03:38:21 -0500 Received: from DGGEMS414-HUB.china.huawei.com (unknown [172.30.72.59]) by szxga07-in.huawei.com (SkyGuard) with ESMTP id 4D0V7y6D8zz7Jcj; Tue, 22 Dec 2020 16:37:18 +0800 (CST) Received: from huawei.com (10.175.124.27) by DGGEMS414-HUB.china.huawei.com (10.3.19.214) with Microsoft SMTP Server id 14.3.498.0; Tue, 22 Dec 2020 16:37:53 +0800 From: Zhang Han To: Subject: [PATCH 5/9] net: Fix lines over 90 characters Date: Tue, 22 Dec 2020 16:23:36 +0800 Message-ID: <20201222082340.67405-6-zhanghan64@huawei.com> X-Mailer: git-send-email 2.29.1.59.gf9b6481aed In-Reply-To: <20201222082340.67405-1-zhanghan64@huawei.com> References: <20201222082340.67405-1-zhanghan64@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.124.27] X-CFilter-Loop: Reflected Received-SPF: pass client-ip=45.249.212.35; envelope-from=zhanghan64@huawei.com; helo=szxga07-in.huawei.com X-Spam_score_int: -41 X-Spam_score: -4.2 X-Spam_bar: ---- X-Spam_report: (-4.2 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Mailman-Approved-At: Tue, 22 Dec 2020 08:55:42 -0500 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: alex.chen@huawei.com, hunongda@huawei.com, qemu-trivial@nongnu.org, hang.zhanghailiang@huawei.com, qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" Fix the line width of code. Signed-off-by: Zhang Han --- net/socket.c | 11 +++++++---- net/tap-win32.c | 39 ++++++++++++++++++++++++++------------- 2 files changed, 33 insertions(+), 17 deletions(-) diff --git a/net/socket.c b/net/socket.c index 61671e41e3..0093ed2794 100644 --- a/net/socket.c +++ b/net/socket.c @@ -113,7 +113,9 @@ static ssize_t net_socket_receive(NetClientState *nc, const uint8_t *buf, size_t return size; } -static ssize_t net_socket_receive_dgram(NetClientState *nc, const uint8_t *buf, size_t size) +static ssize_t net_socket_receive_dgram(NetClientState *nc, + const uint8_t *buf, + size_t size) { NetSocketState *s = DO_UPCAST(NetSocketState, nc, nc); ssize_t ret; @@ -353,9 +355,10 @@ static NetSocketState *net_socket_fd_init_dgram(NetClientState *peer, sa_type = sa->type; qapi_free_SocketAddress(sa); - /* fd passed: multicast: "learn" dgram_dst address from bound address and save it - * Because this may be "shared" socket from a "master" process, datagrams would be recv() - * by ONLY ONE process: we must "clone" this dgram socket --jjo + /* fd passed: multicast: "learn" dgram_dst address from bound address + * and save it. Because this may be "shared" socket from a "master" process, + * datagrams would be recv() by ONLY ONE process: we must "clone" + * this dgram socket --jjo */ if (is_connected && mcast != NULL) { diff --git a/net/tap-win32.c b/net/tap-win32.c index ac139e9ec9..107027aa24 100644 --- a/net/tap-win32.c +++ b/net/tap-win32.c @@ -63,9 +63,11 @@ * ================= */ -#define ADAPTER_KEY "SYSTEM\\CurrentControlSet\\Control\\Class\\{4D36E972-E325-11CE-BFC1-08002BE10318}" +#define ADAPTER_KEY \ + "SYSTEM\\CurrentControlSet\\Control\\Class\\{4D36E972-E325-11CE-BFC1-08002BE10318}" -#define NETWORK_CONNECTIONS_KEY "SYSTEM\\CurrentControlSet\\Control\\Network\\{4D36E972-E325-11CE-BFC1-08002BE10318}" +#define NETWORK_CONNECTIONS_KEY \ + "SYSTEM\\CurrentControlSet\\Control\\Network\\{4D36E972-E325-11CE-BFC1-08002BE10318}" /* * ====================== @@ -136,7 +138,8 @@ static tun_buffer_t *get_buffer_from_free_list(tap_win32_overlapped_t *const ove return buffer; } -static void put_buffer_on_free_list(tap_win32_overlapped_t *const overlapped, tun_buffer_t *const buffer) +static void put_buffer_on_free_list(tap_win32_overlapped_t *const overlapped, + tun_buffer_t *const buffer) { EnterCriticalSection(&overlapped->free_list_cs); buffer->next = overlapped->free_list; @@ -145,7 +148,8 @@ static void put_buffer_on_free_list(tap_win32_overlapped_t *const overlapped, tu ReleaseSemaphore(overlapped->free_list_semaphore, 1, NULL); } -static tun_buffer_t *get_buffer_from_output_queue(tap_win32_overlapped_t *const overlapped, const int block) +static tun_buffer_t *get_buffer_from_output_queue(tap_win32_overlapped_t *const overlapped, + const int block) { tun_buffer_t *buffer = NULL; DWORD result, timeout = block ? INFINITE : 0L; @@ -182,7 +186,8 @@ static tun_buffer_t *get_buffer_from_output_queue_immediate(tap_win32_overlapped return get_buffer_from_output_queue(overlapped, 0); } -static void put_buffer_on_output_queue(tap_win32_overlapped_t *const overlapped, tun_buffer_t *const buffer) +static void put_buffer_on_output_queue(tap_win32_overlapped_t *const overlapped, + tun_buffer_t *const buffer) { EnterCriticalSection(&overlapped->output_queue_cs); @@ -194,7 +199,7 @@ static void put_buffer_on_output_queue(tap_win32_overlapped_t *const overlapped, overlapped->output_queue_back = buffer; } - LeaveCriticalSection(&overlapped->output_queue_cs); + LeaveCriticalSection(&overlapped->ou412tput_queue_cs); ReleaseSemaphore(overlapped->output_queue_semaphore, 1, NULL); } @@ -409,7 +414,8 @@ static int tap_win32_set_status(HANDLE handle, int status) &status, sizeof(status), &len, NULL); } -static void tap_win32_overlapped_init(tap_win32_overlapped_t *const overlapped, const HANDLE handle) +static void tap_win32_overlapped_init(tap_win32_overlapped_t *const overlapped, + const HANDLE handle) { overlapped->handle = handle; @@ -447,7 +453,9 @@ static void tap_win32_overlapped_init(tap_win32_overlapped_t *const overlapped, fprintf(stderr, "error creating free list semaphore!\n"); } - overlapped->free_list = overlapped->output_queue_front = overlapped->output_queue_back = NULL; + overlapped->free_list = overlapped->output_queue_front = + overlapped->output_queue_back = + NULL; { unsigned index; @@ -537,16 +545,20 @@ static DWORD WINAPI tap_win32_thread_entry(LPVOID param) dwError = GetLastError(); if (dwError == ERROR_IO_PENDING) { WaitForSingleObject(overlapped->read_event, INFINITE); - result = GetOverlappedResult(overlapped->handle, &overlapped->read_overlapped, + result = GetOverlappedResult(overlapped->handle, + &overlapped->read_overlapped, &read_size, FALSE); if (!result) { #ifdef DEBUG_TAP_WIN32 LPVOID lpBuffer; dwError = GetLastError(); - FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM, - NULL, dwError, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), + FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | + FORMAT_MESSAGE_FROM_SYSTEM, + NULL, dwError, + MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPTSTR) &lpBuffer, 0, NULL); - fprintf(stderr, "Tap-Win32: Error GetOverlappedResult %d - %s\n", dwError, lpBuffer); + fprintf(stderr, "Tap-Win32: Error GetOverlappedResult %d - %s\n", + dwError, lpBuffer); LocalFree(lpBuffer); #endif } @@ -619,7 +631,8 @@ static int tap_win32_open(tap_win32_overlapped_t **phandle, snprintf(name_buffer, sizeof(name_buffer), "%s", preferred_name); } - rc = get_device_guid(device_guid, sizeof(device_guid), name_buffer, sizeof(name_buffer)); + rc = get_device_guid(device_guid, sizeof(device_guid), + name_buffer, sizeof(name_buffer)); if (rc) { return -1; } From patchwork Tue Dec 22 08:23:37 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "zhanghan (J)" X-Patchwork-Id: 1419389 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=huawei.com Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4D0dHk4P5Vz9sVk for ; Wed, 23 Dec 2020 00:59:30 +1100 (AEDT) Received: from localhost ([::1]:36646 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kriCG-0004l3-7O for incoming@patchwork.ozlabs.org; Tue, 22 Dec 2020 08:59:28 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:41628) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1krdBZ-0001mi-QP; Tue, 22 Dec 2020 03:38:25 -0500 Received: from szxga07-in.huawei.com ([45.249.212.35]:2625) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1krdBY-0002kE-6C; Tue, 22 Dec 2020 03:38:25 -0500 Received: from DGGEMS414-HUB.china.huawei.com (unknown [172.30.72.59]) by szxga07-in.huawei.com (SkyGuard) with ESMTP id 4D0V7y60kbz7Jcd; Tue, 22 Dec 2020 16:37:18 +0800 (CST) Received: from huawei.com (10.175.124.27) by DGGEMS414-HUB.china.huawei.com (10.3.19.214) with Microsoft SMTP Server id 14.3.498.0; Tue, 22 Dec 2020 16:37:53 +0800 From: Zhang Han To: Subject: [PATCH 6/9] net: Transfer tabs to spcaes Date: Tue, 22 Dec 2020 16:23:37 +0800 Message-ID: <20201222082340.67405-7-zhanghan64@huawei.com> X-Mailer: git-send-email 2.29.1.59.gf9b6481aed In-Reply-To: <20201222082340.67405-1-zhanghan64@huawei.com> References: <20201222082340.67405-1-zhanghan64@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.124.27] X-CFilter-Loop: Reflected Received-SPF: pass client-ip=45.249.212.35; envelope-from=zhanghan64@huawei.com; helo=szxga07-in.huawei.com X-Spam_score_int: -41 X-Spam_score: -4.2 X-Spam_bar: ---- X-Spam_report: (-4.2 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Mailman-Approved-At: Tue, 22 Dec 2020 08:55:42 -0500 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: alex.chen@huawei.com, hunongda@huawei.com, qemu-trivial@nongnu.org, hang.zhanghailiang@huawei.com, qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" Code indent use spaces instead of tabs. Signed-off-by: Zhang Han --- net/tap-linux.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/net/tap-linux.h b/net/tap-linux.h index 2f36d100fc..db72960c19 100644 --- a/net/tap-linux.h +++ b/net/tap-linux.h @@ -44,10 +44,10 @@ #define IFF_DETACH_QUEUE 0x0400 /* Features for GSO (TUNSETOFFLOAD). */ -#define TUN_F_CSUM 0x01 /* You can hand me unchecksummed packets. */ -#define TUN_F_TSO4 0x02 /* I can handle TSO for IPv4 packets */ -#define TUN_F_TSO6 0x04 /* I can handle TSO for IPv6 packets */ -#define TUN_F_TSO_ECN 0x08 /* I can handle TSO with ECN bits. */ -#define TUN_F_UFO 0x10 /* I can handle UFO packets */ +#define TUN_F_CSUM 0x01 /* You can hand me unchecksummed packets. */ +#define TUN_F_TSO4 0x02 /* I can handle TSO for IPv4 packets */ +#define TUN_F_TSO6 0x04 /* I can handle TSO for IPv6 packets */ +#define TUN_F_TSO_ECN 0x08 /* I can handle TSO with ECN bits. */ +#define TUN_F_UFO 0x10 /* I can handle UFO packets */ #endif /* QEMU_TAP_LINUX_H */ From patchwork Tue Dec 22 08:23:38 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "zhanghan (J)" X-Patchwork-Id: 1419396 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=huawei.com Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4D0dPx4vd6z9sT5 for ; Wed, 23 Dec 2020 01:04:53 +1100 (AEDT) Received: from localhost ([::1]:52638 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kriHT-0002v9-M1 for incoming@patchwork.ozlabs.org; Tue, 22 Dec 2020 09:04:51 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:41568) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1krdBW-0001jW-GB; Tue, 22 Dec 2020 03:38:22 -0500 Received: from szxga07-in.huawei.com ([45.249.212.35]:2621) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1krdBU-0002cX-U4; Tue, 22 Dec 2020 03:38:22 -0500 Received: from DGGEMS414-HUB.china.huawei.com (unknown [172.30.72.59]) by szxga07-in.huawei.com (SkyGuard) with ESMTP id 4D0V7y4dmJz7JXT; Tue, 22 Dec 2020 16:37:18 +0800 (CST) Received: from huawei.com (10.175.124.27) by DGGEMS414-HUB.china.huawei.com (10.3.19.214) with Microsoft SMTP Server id 14.3.498.0; Tue, 22 Dec 2020 16:37:54 +0800 From: Zhang Han To: Subject: [PATCH 7/9] net: Remove assignment in if condition Date: Tue, 22 Dec 2020 16:23:38 +0800 Message-ID: <20201222082340.67405-8-zhanghan64@huawei.com> X-Mailer: git-send-email 2.29.1.59.gf9b6481aed In-Reply-To: <20201222082340.67405-1-zhanghan64@huawei.com> References: <20201222082340.67405-1-zhanghan64@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.124.27] X-CFilter-Loop: Reflected Received-SPF: pass client-ip=45.249.212.35; envelope-from=zhanghan64@huawei.com; helo=szxga07-in.huawei.com X-Spam_score_int: -41 X-Spam_score: -4.2 X-Spam_bar: ---- X-Spam_report: (-4.2 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Mailman-Approved-At: Tue, 22 Dec 2020 08:55:42 -0500 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: alex.chen@huawei.com, hunongda@huawei.com, qemu-trivial@nongnu.org, hang.zhanghailiang@huawei.com, qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" Put the assignment before the if condition Signed-off-by: Zhang Han Reviewed-by: Philippe Mathieu-Daudé --- net/tap-bsd.c | 3 ++- net/tap-solaris.c | 9 ++++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/net/tap-bsd.c b/net/tap-bsd.c index dc8f9c8658..d1dca793f9 100644 --- a/net/tap-bsd.c +++ b/net/tap-bsd.c @@ -176,7 +176,8 @@ int tap_open(char *ifname, int ifname_size, int *vnet_hdr, if (fd < 0) { /* Tap device not specified or does not exist. */ - if ((fd = tap_open_clone(ifname, ifname_size, errp)) < 0) { + fd = tap_open_clone(ifname, ifname_size, errp); + if (fd < 0) { return -1; } } diff --git a/net/tap-solaris.c b/net/tap-solaris.c index a0a5456ab6..d5af4efd60 100644 --- a/net/tap-solaris.c +++ b/net/tap-solaris.c @@ -105,7 +105,8 @@ static int tap_alloc(char *dev, size_t dev_size, Error **errp) strioc_ppa.ic_timout = 0; strioc_ppa.ic_len = sizeof(ppa); strioc_ppa.ic_dp = (char *)&ppa; - if ((ppa = ioctl(tap_fd, I_STR, &strioc_ppa)) < 0) { + ppa = ioctl(tap_fd, I_STR, &strioc_ppa)); + if (ppa < 0) { error_report("Can't assign new interface"); } @@ -162,12 +163,14 @@ static int tap_alloc(char *dev, size_t dev_size, Error **errp) error_report("Can't set ifname to arp"); } - if ((ip_muxid = ioctl(ip_fd, I_LINK, if_fd)) < 0) { + ip_muxid = ioctl(ip_fd, I_LINK, if_fd); + if (ip_muxid < 0) { error_setg(errp, "Can't link TAP device to IP"); return -1; } - if ((arp_muxid = ioctl(ip_fd, link_type, arp_fd)) < 0) { + arp_muxid = ioctl(ip_fd, link_type, arp_fd); + if (arp_muxid < 0) { error_report("Can't link TAP device to ARP"); } From patchwork Tue Dec 22 08:23:39 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "zhanghan (J)" X-Patchwork-Id: 1419392 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=huawei.com Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4D0dLd263sz9sWS for ; Wed, 23 Dec 2020 01:02:00 +1100 (AEDT) Received: from localhost ([::1]:44348 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kriEg-0007vA-0C for incoming@patchwork.ozlabs.org; Tue, 22 Dec 2020 09:01:58 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:41544) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1krdBU-0001iQ-SG; Tue, 22 Dec 2020 03:38:20 -0500 Received: from szxga07-in.huawei.com ([45.249.212.35]:2618) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1krdBR-0002cZ-Uu; Tue, 22 Dec 2020 03:38:20 -0500 Received: from DGGEMS414-HUB.china.huawei.com (unknown [172.30.72.59]) by szxga07-in.huawei.com (SkyGuard) with ESMTP id 4D0V7y4qPJz7JYV; Tue, 22 Dec 2020 16:37:18 +0800 (CST) Received: from huawei.com (10.175.124.27) by DGGEMS414-HUB.china.huawei.com (10.3.19.214) with Microsoft SMTP Server id 14.3.498.0; Tue, 22 Dec 2020 16:37:54 +0800 From: Zhang Han To: Subject: [PATCH 8/9] net: Remove initialization of static ints Date: Tue, 22 Dec 2020 16:23:39 +0800 Message-ID: <20201222082340.67405-9-zhanghan64@huawei.com> X-Mailer: git-send-email 2.29.1.59.gf9b6481aed In-Reply-To: <20201222082340.67405-1-zhanghan64@huawei.com> References: <20201222082340.67405-1-zhanghan64@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.124.27] X-CFilter-Loop: Reflected Received-SPF: pass client-ip=45.249.212.35; envelope-from=zhanghan64@huawei.com; helo=szxga07-in.huawei.com X-Spam_score_int: -41 X-Spam_score: -4.2 X-Spam_bar: ---- X-Spam_report: (-4.2 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Mailman-Approved-At: Tue, 22 Dec 2020 08:55:40 -0500 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: alex.chen@huawei.com, hunongda@huawei.com, qemu-trivial@nongnu.org, hang.zhanghailiang@huawei.com, qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" Do not initialise statics to 0 or NULL Signed-off-by: Zhang Han --- net/tap-solaris.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/net/tap-solaris.c b/net/tap-solaris.c index d5af4efd60..0b4f709abc 100644 --- a/net/tap-solaris.c +++ b/net/tap-solaris.c @@ -63,10 +63,10 @@ static int tap_alloc(char *dev, size_t dev_size, Error **errp) /* FIXME leaks like a sieve on error paths */ /* FIXME suspicious: many errors are reported, then ignored */ int tap_fd, if_fd, ppa = -1; - static int ip_fd = 0; + static int ip_fd; char *ptr; - static int arp_fd = 0; + static int arp_fd; int ip_muxid, arp_muxid; struct strioctl strioc_if, strioc_ppa; int link_type = I_PLINK; From patchwork Tue Dec 22 08:23:40 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "zhanghan (J)" X-Patchwork-Id: 1419384 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=huawei.com Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4D0dDR4QHRz9sVj for ; Wed, 23 Dec 2020 00:56:39 +1100 (AEDT) Received: from localhost ([::1]:56044 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kri9V-00014T-LR for incoming@patchwork.ozlabs.org; Tue, 22 Dec 2020 08:56:37 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:41518) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1krdBT-0001i9-PR; Tue, 22 Dec 2020 03:38:19 -0500 Received: from szxga05-in.huawei.com ([45.249.212.191]:2919) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1krdBR-0002dx-3p; Tue, 22 Dec 2020 03:38:19 -0500 Received: from DGGEMS414-HUB.china.huawei.com (unknown [172.30.72.58]) by szxga05-in.huawei.com (SkyGuard) with ESMTP id 4D0V7q1rf2zM7G1; Tue, 22 Dec 2020 16:37:11 +0800 (CST) Received: from huawei.com (10.175.124.27) by DGGEMS414-HUB.china.huawei.com (10.3.19.214) with Microsoft SMTP Server id 14.3.498.0; Tue, 22 Dec 2020 16:37:55 +0800 From: Zhang Han To: Subject: [PATCH 9/9] net: Fix the indent problems Date: Tue, 22 Dec 2020 16:23:40 +0800 Message-ID: <20201222082340.67405-10-zhanghan64@huawei.com> X-Mailer: git-send-email 2.29.1.59.gf9b6481aed In-Reply-To: <20201222082340.67405-1-zhanghan64@huawei.com> References: <20201222082340.67405-1-zhanghan64@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.124.27] X-CFilter-Loop: Reflected Received-SPF: pass client-ip=45.249.212.191; envelope-from=zhanghan64@huawei.com; helo=szxga05-in.huawei.com X-Spam_score_int: -41 X-Spam_score: -4.2 X-Spam_bar: ---- X-Spam_report: (-4.2 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Mailman-Approved-At: Tue, 22 Dec 2020 08:55:39 -0500 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: alex.chen@huawei.com, hunongda@huawei.com, qemu-trivial@nongnu.org, hang.zhanghailiang@huawei.com, qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" Fix Suspect code indent for statements Signed-off-by: Zhang Han --- net/tap-solaris.c | 18 +++++++++--------- net/tap-win32.c | 28 ++++++++++++++-------------- net/vde.c | 2 +- 3 files changed, 24 insertions(+), 24 deletions(-) diff --git a/net/tap-solaris.c b/net/tap-solaris.c index 0b4f709abc..fc1e796f70 100644 --- a/net/tap-solaris.c +++ b/net/tap-solaris.c @@ -76,16 +76,16 @@ static int tap_alloc(char *dev, size_t dev_size, Error **errp) memset(&ifr, 0x0, sizeof(ifr)); if (*dev) { - ptr = dev; - while (*ptr && !qemu_isdigit((int)*ptr)) { - ptr++; - } - ppa = atoi(ptr); + ptr = dev; + while (*ptr && !qemu_isdigit((int)*ptr)) { + ptr++; + } + ppa = atoi(ptr); } /* Check if IP device was opened */ if (ip_fd) { - close(ip_fd); + close(ip_fd); } TFR(ip_fd = open("/dev/udp", O_RDWR, 0)); @@ -182,9 +182,9 @@ static int tap_alloc(char *dev, size_t dev_size, Error **errp) ifr.lifr_arp_muxid = arp_muxid; if (ioctl(ip_fd, SIOCSLIFMUXID, &ifr) < 0) { - ioctl(ip_fd, I_PUNLINK , arp_muxid); - ioctl(ip_fd, I_PUNLINK, ip_muxid); - error_report("Can't set multiplexor id"); + ioctl(ip_fd, I_PUNLINK , arp_muxid); + ioctl(ip_fd, I_PUNLINK, ip_muxid); + error_report("Can't set multiplexor id"); } snprintf(dev, dev_size, "tap%d", ppa); diff --git a/net/tap-win32.c b/net/tap-win32.c index 107027aa24..b3af8fcba9 100644 --- a/net/tap-win32.c +++ b/net/tap-win32.c @@ -158,24 +158,24 @@ static tun_buffer_t *get_buffer_from_output_queue(tap_win32_overlapped_t *const result = WaitForSingleObject(overlapped->output_queue_semaphore, timeout); switch (result) { - /* The semaphore object was signaled. */ - case WAIT_OBJECT_0: - EnterCriticalSection(&overlapped->output_queue_cs); + /* The semaphore object was signaled. */ + case WAIT_OBJECT_0: + EnterCriticalSection(&overlapped->output_queue_cs); - buffer = overlapped->output_queue_front; - overlapped->output_queue_front = buffer->next; + buffer = overlapped->output_queue_front; + overlapped->output_queue_front = buffer->next; - if (overlapped->output_queue_front == NULL) { - overlapped->output_queue_back = NULL; - } + if (overlapped->output_queue_front == NULL) { + overlapped->output_queue_back = NULL; + } - LeaveCriticalSection(&overlapped->output_queue_cs); - break; + LeaveCriticalSection(&overlapped->output_queue_cs); + break; - /* Semaphore was nonsignaled, so a time-out occurred. */ - case WAIT_TIMEOUT: - /* Cannot open another window. */ - break; + /* Semaphore was nonsignaled, so a time-out occurred. */ + case WAIT_TIMEOUT: + /* Cannot open another window. */ + break; } return buffer; diff --git a/net/vde.c b/net/vde.c index 0b06464f4d..9ccedddc63 100644 --- a/net/vde.c +++ b/net/vde.c @@ -55,7 +55,7 @@ static ssize_t vde_receive(NetClientState *nc, const uint8_t *buf, size_t size) ssize_t ret; do { - ret = vde_send(s->vde, (const char *)buf, size, 0); + ret = vde_send(s->vde, (const char *)buf, size, 0); } while (ret < 0 && errno == EINTR); return ret;