* [PATCH 0/9] Fix some style problems in net
@ 2020-12-22 8:23 Zhang Han
2020-12-22 8:23 ` [PATCH 1/9] net: Add spaces around operator/delete redundant spaces Zhang Han
` (9 more replies)
0 siblings, 10 replies; 15+ messages in thread
From: Zhang Han @ 2020-12-22 8:23 UTC (permalink / raw)
To: jasowang
Cc: alex.chen, hunongda, qemu-trivial, hang.zhanghailiang, qemu-devel
Some style problems in net directory are found by checkpatch.pl. Fix these
style problems.
Zhang Han (9):
net: Add spaces around operator/delete redundant spaces
net: Add braces for statements/fix braces' position
net: transfer // comments to /**/
net: transfer "foo* bar" to "foo *"
net: fix lines over 90 characters
net: Transfer tabs to spcaes
net: remove assignment in if condition
net: Remove initialization of static ints
net: Fix the indent problems
net/checksum.c | 11 +-
net/eth.c | 2 +-
net/net.c | 26 +++--
net/queue.c | 5 +-
net/slirp.c | 8 +-
net/socket.c | 32 +++---
net/tap-bsd.c | 6 +-
net/tap-linux.c | 20 ++--
net/tap-linux.h | 10 +-
net/tap-solaris.c | 76 ++++++++------
net/tap-win32.c | 258 +++++++++++++++++++++++++---------------------
net/vde.c | 4 +-
net/vhost-user.c | 2 +-
13 files changed, 259 insertions(+), 201 deletions(-)
--
2.29.1.59.gf9b6481aed
^ permalink raw reply [flat|nested] 15+ messages in thread
* [PATCH 1/9] net: Add spaces around operator/delete redundant spaces
2020-12-22 8:23 [PATCH 0/9] Fix some style problems in net Zhang Han
@ 2020-12-22 8:23 ` Zhang Han
2020-12-22 8:23 ` [PATCH 2/9] net: Add braces for statements/fix braces' position Zhang Han
` (8 subsequent siblings)
9 siblings, 0 replies; 15+ messages in thread
From: Zhang Han @ 2020-12-22 8:23 UTC (permalink / raw)
To: jasowang
Cc: alex.chen, hunongda, qemu-trivial, hang.zhanghailiang, qemu-devel
Fix problems about spaces:
-operator needs spaces around it, add them.
-somespaces are redundant, remove them.
Signed-off-by: Zhang Han <zhanghan64@huawei.com>
---
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) {
--
2.29.1.59.gf9b6481aed
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH 2/9] net: Add braces for statements/fix braces' position
2020-12-22 8:23 [PATCH 0/9] Fix some style problems in net Zhang Han
2020-12-22 8:23 ` [PATCH 1/9] net: Add spaces around operator/delete redundant spaces Zhang Han
@ 2020-12-22 8:23 ` Zhang Han
2020-12-22 8:23 ` [PATCH 3/9] net: Transfer // comments to /**/ Zhang Han
` (7 subsequent siblings)
9 siblings, 0 replies; 15+ messages in thread
From: Zhang Han @ 2020-12-22 8:23 UTC (permalink / raw)
To: jasowang
Cc: alex.chen, hunongda, qemu-trivial, hang.zhanghailiang, 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 <zhanghan64@huawei.com>
---
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,
--
2.29.1.59.gf9b6481aed
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH 3/9] net: Transfer // comments to /**/
2020-12-22 8:23 [PATCH 0/9] Fix some style problems in net Zhang Han
2020-12-22 8:23 ` [PATCH 1/9] net: Add spaces around operator/delete redundant spaces Zhang Han
2020-12-22 8:23 ` [PATCH 2/9] net: Add braces for statements/fix braces' position Zhang Han
@ 2020-12-22 8:23 ` Zhang Han
2020-12-22 8:23 ` [PATCH 4/9] net: Transfer "foo* " to "foo *" Zhang Han
` (6 subsequent siblings)
9 siblings, 0 replies; 15+ messages in thread
From: Zhang Han @ 2020-12-22 8:23 UTC (permalink / raw)
To: jasowang
Cc: alex.chen, hunongda, qemu-trivial, hang.zhanghailiang, qemu-devel
Do not use C99 // comments, thransfer // to /**/
Signed-off-by: Zhang Han <zhanghan64@huawei.com>
---
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 <netinet/in.h>
#include <netinet/in_systm.h>
#include <netinet/ip.h>
-#include <netinet/ip_icmp.h> // must come after ip.h
+#include <netinet/ip_icmp.h> /* must come after ip.h */
#include <netinet/udp.h>
#include <netinet/tcp.h>
#include <net/if.h>
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 <windows.h>
#include <winioctl.h>
-//=============
-// 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");
--
2.29.1.59.gf9b6481aed
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH 4/9] net: Transfer "foo* " to "foo *"
2020-12-22 8:23 [PATCH 0/9] Fix some style problems in net Zhang Han
` (2 preceding siblings ...)
2020-12-22 8:23 ` [PATCH 3/9] net: Transfer // comments to /**/ Zhang Han
@ 2020-12-22 8:23 ` Zhang Han
2020-12-22 8:23 ` [PATCH 5/9] net: Fix lines over 90 characters Zhang Han
` (5 subsequent siblings)
9 siblings, 0 replies; 15+ messages in thread
From: Zhang Han @ 2020-12-22 8:23 UTC (permalink / raw)
To: jasowang
Cc: alex.chen, hunongda, qemu-trivial, hang.zhanghailiang, 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 <zhanghan64@huawei.com>
---
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);
}
--
2.29.1.59.gf9b6481aed
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH 5/9] net: Fix lines over 90 characters
2020-12-22 8:23 [PATCH 0/9] Fix some style problems in net Zhang Han
` (3 preceding siblings ...)
2020-12-22 8:23 ` [PATCH 4/9] net: Transfer "foo* " to "foo *" Zhang Han
@ 2020-12-22 8:23 ` Zhang Han
2020-12-22 8:23 ` [PATCH 6/9] net: Transfer tabs to spcaes Zhang Han
` (4 subsequent siblings)
9 siblings, 0 replies; 15+ messages in thread
From: Zhang Han @ 2020-12-22 8:23 UTC (permalink / raw)
To: jasowang
Cc: alex.chen, hunongda, qemu-trivial, hang.zhanghailiang, qemu-devel
Fix the line width of code.
Signed-off-by: Zhang Han <zhanghan64@huawei.com>
---
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;
}
--
2.29.1.59.gf9b6481aed
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH 6/9] net: Transfer tabs to spcaes
2020-12-22 8:23 [PATCH 0/9] Fix some style problems in net Zhang Han
` (4 preceding siblings ...)
2020-12-22 8:23 ` [PATCH 5/9] net: Fix lines over 90 characters Zhang Han
@ 2020-12-22 8:23 ` Zhang Han
2021-01-14 11:34 ` Philippe Mathieu-Daudé
2020-12-22 8:23 ` [PATCH 7/9] net: Remove assignment in if condition Zhang Han
` (3 subsequent siblings)
9 siblings, 1 reply; 15+ messages in thread
From: Zhang Han @ 2020-12-22 8:23 UTC (permalink / raw)
To: jasowang
Cc: alex.chen, hunongda, qemu-trivial, hang.zhanghailiang, qemu-devel
Code indent use spaces instead of tabs.
Signed-off-by: Zhang Han <zhanghan64@huawei.com>
---
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 */
--
2.29.1.59.gf9b6481aed
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH 7/9] net: Remove assignment in if condition
2020-12-22 8:23 [PATCH 0/9] Fix some style problems in net Zhang Han
` (5 preceding siblings ...)
2020-12-22 8:23 ` [PATCH 6/9] net: Transfer tabs to spcaes Zhang Han
@ 2020-12-22 8:23 ` Zhang Han
2021-01-14 11:35 ` Philippe Mathieu-Daudé
2020-12-22 8:23 ` [PATCH 8/9] net: Remove initialization of static ints Zhang Han
` (2 subsequent siblings)
9 siblings, 1 reply; 15+ messages in thread
From: Zhang Han @ 2020-12-22 8:23 UTC (permalink / raw)
To: jasowang
Cc: alex.chen, hunongda, qemu-trivial, hang.zhanghailiang, qemu-devel
Put the assignment before the if condition
Signed-off-by: Zhang Han <zhanghan64@huawei.com>
---
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");
}
--
2.29.1.59.gf9b6481aed
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH 8/9] net: Remove initialization of static ints
2020-12-22 8:23 [PATCH 0/9] Fix some style problems in net Zhang Han
` (6 preceding siblings ...)
2020-12-22 8:23 ` [PATCH 7/9] net: Remove assignment in if condition Zhang Han
@ 2020-12-22 8:23 ` Zhang Han
2020-12-22 8:23 ` [PATCH 9/9] net: Fix the indent problems Zhang Han
2020-12-22 17:00 ` [PATCH 0/9] Fix some style problems in net no-reply
9 siblings, 0 replies; 15+ messages in thread
From: Zhang Han @ 2020-12-22 8:23 UTC (permalink / raw)
To: jasowang
Cc: alex.chen, hunongda, qemu-trivial, hang.zhanghailiang, qemu-devel
Do not initialise statics to 0 or NULL
Signed-off-by: Zhang Han <zhanghan64@huawei.com>
---
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;
--
2.29.1.59.gf9b6481aed
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH 9/9] net: Fix the indent problems
2020-12-22 8:23 [PATCH 0/9] Fix some style problems in net Zhang Han
` (7 preceding siblings ...)
2020-12-22 8:23 ` [PATCH 8/9] net: Remove initialization of static ints Zhang Han
@ 2020-12-22 8:23 ` Zhang Han
2020-12-22 17:00 ` [PATCH 0/9] Fix some style problems in net no-reply
9 siblings, 0 replies; 15+ messages in thread
From: Zhang Han @ 2020-12-22 8:23 UTC (permalink / raw)
To: jasowang
Cc: alex.chen, hunongda, qemu-trivial, hang.zhanghailiang, qemu-devel
Fix Suspect code indent for statements
Signed-off-by: Zhang Han <zhanghan64@huawei.com>
---
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;
--
2.29.1.59.gf9b6481aed
^ permalink raw reply related [flat|nested] 15+ messages in thread
* Re: [PATCH 0/9] Fix some style problems in net
2020-12-22 8:23 [PATCH 0/9] Fix some style problems in net Zhang Han
` (8 preceding siblings ...)
2020-12-22 8:23 ` [PATCH 9/9] net: Fix the indent problems Zhang Han
@ 2020-12-22 17:00 ` no-reply
2021-01-14 2:34 ` zhanghan (J)
9 siblings, 1 reply; 15+ messages in thread
From: no-reply @ 2020-12-22 17:00 UTC (permalink / raw)
To: zhanghan64
Cc: hang.zhanghailiang, hunongda, qemu-trivial, jasowang, qemu-devel,
alex.chen
Patchew URL: https://patchew.org/QEMU/20201222082340.67405-1-zhanghan64@huawei.com/
Hi,
This series seems to have some coding style problems. See output below for
more information:
Type: series
Message-id: 20201222082340.67405-1-zhanghan64@huawei.com
Subject: [PATCH 0/9] Fix some style problems in net
=== TEST SCRIPT BEGIN ===
#!/bin/bash
git rev-parse base > /dev/null || exit 0
git config --local diff.renamelimit 0
git config --local diff.renames True
git config --local diff.algorithm histogram
./scripts/checkpatch.pl --mailback base..
=== TEST SCRIPT END ===
Updating 3c8cf5a9c21ff8782164d1def7f44bd888713384
From https://github.com/patchew-project/qemu
- [tag update] patchew/20201221134931.1194806-1-david.edmondson@oracle.com -> patchew/20201221134931.1194806-1-david.edmondson@oracle.com
* [new tag] patchew/20201222082340.67405-1-zhanghan64@huawei.com -> patchew/20201222082340.67405-1-zhanghan64@huawei.com
Switched to a new branch 'test'
a1e8031 net: Fix the indent problems
3a9a235 net: Remove initialization of static ints
e1c36e1 net: Remove assignment in if condition
55fc567 net: Transfer tabs to spcaes
c96ec8e net: Fix lines over 90 characters
a9b2502 net: Transfer "foo* " to "foo *"
9dd5b80 net: Transfer // comments to /**/
cb5a663 net: Add braces for statements/fix braces' position
3256d58 net: Add spaces around operator/delete redundant spaces
=== OUTPUT BEGIN ===
1/9 Checking commit 3256d589d47c (net: Add spaces around operator/delete redundant spaces)
ERROR: braces {} are necessary for all arms of this statement
#24: FILE: net/checksum.c:44:
+ while (sum >> 16)
[...]
ERROR: suspect code indent for conditional statements (4, 7)
#128: FILE: net/tap-solaris.c:78:
+ if (*dev) {
ptr = dev;
ERROR: trailing statements should be on next line
#131: FILE: net/tap-solaris.c:80:
+ while (*ptr && !qemu_isdigit((int)*ptr)) ptr++;
ERROR: braces {} are necessary for all arms of this statement
#131: FILE: net/tap-solaris.c:80:
+ while (*ptr && !qemu_isdigit((int)*ptr)) ptr++;
[...]
ERROR: suspect code indent for conditional statements (4, 7)
#137: FILE: net/tap-solaris.c:85:
+ if (ip_fd)
close(ip_fd);
ERROR: braces {} are necessary for all arms of this statement
#137: FILE: net/tap-solaris.c:85:
+ if (ip_fd)
[...]
ERROR: do not use assignment in if condition
#146: FILE: net/tap-solaris.c:105:
+ if ((ppa = ioctl(tap_fd, I_STR, &strioc_ppa)) < 0)
ERROR: braces {} are necessary for all arms of this statement
#146: FILE: net/tap-solaris.c:105:
+ if ((ppa = ioctl(tap_fd, I_STR, &strioc_ppa)) < 0)
[...]
ERROR: braces {} are necessary for all arms of this statement
#171: FILE: net/tap-solaris.c:127:
+ if (ioctl(if_fd, SIOCSLIFNAME, &ifr) < 0)
[...]
ERROR: braces {} are necessary for all arms of this statement
#174: FILE: net/tap-solaris.c:129:
+ if (ioctl(if_fd, SIOCGLIFFLAGS, &ifr) < 0)
[...]
ERROR: braces {} are necessary for all arms of this statement
#178: FILE: net/tap-solaris.c:132:
+ if (ioctl(if_fd, I_PUSH, "arp") < 0)
[...]
ERROR: braces {} are necessary for all arms of this statement
#183: FILE: net/tap-solaris.c:136:
+ if (ioctl(ip_fd, I_POP, NULL) < 0)
[...]
ERROR: braces {} are necessary for all arms of this statement
#186: FILE: net/tap-solaris.c:138:
+ if (ioctl(ip_fd, I_PUSH, "arp") < 0)
[...]
ERROR: do not use assignment in if condition
#204: FILE: net/tap-solaris.c:154:
+ if ((ip_muxid = ioctl(ip_fd, I_LINK, if_fd)) < 0) {
ERROR: do not use assignment in if condition
#210: FILE: net/tap-solaris.c:159:
+ if ((arp_muxid = ioctl(ip_fd, link_type, arp_fd)) < 0)
ERROR: braces {} are necessary for all arms of this statement
#210: FILE: net/tap-solaris.c:159:
+ if ((arp_muxid = ioctl(ip_fd, link_type, arp_fd)) < 0)
[...]
ERROR: suspect code indent for conditional statements (4, 6)
#222: FILE: net/tap-solaris.c:169:
+ if (ioctl(ip_fd, SIOCSLIFMUXID, &ifr) < 0)
{
ERROR: line over 90 characters
#297: FILE: net/tap-win32.c:174:
+static tun_buffer_t* get_buffer_from_output_queue_immediate(tap_win32_overlapped_t* const overlapped)
ERROR: "foo* bar" should be "foo *bar"
#297: FILE: net/tap-win32.c:174:
+static tun_buffer_t* get_buffer_from_output_queue_immediate(tap_win32_overlapped_t* const overlapped)
WARNING: line over 80 characters
#306: FILE: net/tap-win32.c:183:
+ if (overlapped->output_queue_front == NULL && overlapped->output_queue_back == NULL) {
ERROR: braces {} are necessary for all arms of this statement
#416: FILE: net/tap-win32.c:458:
+ if (!overlapped->tap_semaphore)
[...]
WARNING: line over 80 characters
#425: FILE: net/tap-win32.c:470:
+ result = GetOverlappedResult(overlapped->handle, &overlapped->write_overlapped,
WARNING: line over 80 characters
#434: FILE: net/tap-win32.c:503:
+ FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM,
ERROR: line over 90 characters
#443: FILE: net/tap-win32.c:534:
+ result = GetOverlappedResult(overlapped->handle, &overlapped->read_overlapped,
ERROR: line over 90 characters
#450: FILE: net/tap-win32.c:540:
+ FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM,
WARNING: line over 80 characters
#463: FILE: net/tap-win32.c:550:
+ FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM,
total: 22 errors, 4 warnings, 457 lines checked
Patch 1/9 has style problems, please review. If any of these errors
are false positives report them to the maintainer, see
CHECKPATCH in MAINTAINERS.
2/9 Checking commit cb5a6632624a (net: Add braces for statements/fix braces' position)
ERROR: suspect code indent for conditional statements (7, 11)
#251: FILE: net/tap-solaris.c:80:
+ while (*ptr && !qemu_isdigit((int)*ptr)) {
+ ptr++;
ERROR: suspect code indent for conditional statements (4, 7)
#259: FILE: net/tap-solaris.c:87:
+ if (ip_fd) {
close(ip_fd);
ERROR: do not use assignment in if condition
#270: FILE: net/tap-solaris.c:108:
+ if ((ppa = ioctl(tap_fd, I_STR, &strioc_ppa)) < 0) {
ERROR: do not use assignment in if condition
#328: FILE: net/tap-solaris.c:170:
+ if ((arp_muxid = ioctl(ip_fd, link_type, arp_fd)) < 0) {
ERROR: suspect code indent for conditional statements (4, 6)
#340: FILE: net/tap-solaris.c:181:
+ if (ioctl(ip_fd, SIOCSLIFMUXID, &ifr) < 0) {
ioctl(ip_fd, I_PUNLINK , arp_muxid);
total: 5 errors, 0 warnings, 381 lines checked
Patch 2/9 has style problems, please review. If any of these errors
are false positives report them to the maintainer, see
CHECKPATCH in MAINTAINERS.
3/9 Checking commit 9dd5b80ec06d (net: Transfer // comments to /**/)
4/9 Checking commit a9b2502fcb92 (net: Transfer "foo* " to "foo *")
WARNING: line over 80 characters
#56: FILE: net/tap-win32.c:126:
+static tun_buffer_t *get_buffer_from_free_list(tap_win32_overlapped_t *const overlapped)
ERROR: line over 90 characters
#68: FILE: net/tap-win32.c:139:
+static void put_buffer_on_free_list(tap_win32_overlapped_t *const overlapped, tun_buffer_t *const buffer)
ERROR: line over 90 characters
#77: FILE: net/tap-win32.c:148:
+static tun_buffer_t *get_buffer_from_output_queue(tap_win32_overlapped_t *const overlapped, const int block)
ERROR: line over 90 characters
#89: FILE: net/tap-win32.c:180:
+static tun_buffer_t *get_buffer_from_output_queue_immediate(tap_win32_overlapped_t *const overlapped)
ERROR: line over 90 characters
#95: FILE: net/tap-win32.c:185:
+static void put_buffer_on_output_queue(tap_win32_overlapped_t *const overlapped, tun_buffer_t *const buffer)
ERROR: line over 90 characters
#104: FILE: net/tap-win32.c:412:
+static void tap_win32_overlapped_init(tap_win32_overlapped_t *const overlapped, const HANDLE handle)
total: 5 errors, 1 warnings, 115 lines checked
Patch 4/9 has style problems, please review. If any of these errors
are false positives report them to the maintainer, see
CHECKPATCH in MAINTAINERS.
5/9 Checking commit c96ec8e7f974 (net: Fix lines over 90 characters)
WARNING: Block comments use a leading /* on a separate line
#34: FILE: net/socket.c:358:
+ /* fd passed: multicast: "learn" dgram_dst address from bound address
ERROR: line over 90 characters
#74: FILE: net/tap-win32.c:151:
+static tun_buffer_t *get_buffer_from_output_queue(tap_win32_overlapped_t *const overlapped,
WARNING: line over 80 characters
#139: FILE: net/tap-win32.c:560:
+ fprintf(stderr, "Tap-Win32: Error GetOverlappedResult %d - %s\n",
total: 1 errors, 2 warnings, 123 lines checked
Patch 5/9 has style problems, please review. If any of these errors
are false positives report them to the maintainer, see
CHECKPATCH in MAINTAINERS.
6/9 Checking commit 55fc567376cd (net: Transfer tabs to spcaes)
7/9 Checking commit e1c36e115c99 (net: Remove assignment in if condition)
8/9 Checking commit 3a9a235f5e6f (net: Remove initialization of static ints)
9/9 Checking commit a1e8031d967e (net: Fix the indent problems)
=== OUTPUT END ===
Test command exited with code: 1
The full log is available at
http://patchew.org/logs/20201222082340.67405-1-zhanghan64@huawei.com/testing.checkpatch/?type=message.
---
Email generated automatically by Patchew [https://patchew.org/].
Please send your feedback to patchew-devel@redhat.com
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH 0/9] Fix some style problems in net
2020-12-22 17:00 ` [PATCH 0/9] Fix some style problems in net no-reply
@ 2021-01-14 2:34 ` zhanghan (J)
2021-02-01 6:18 ` zhanghan (J)
0 siblings, 1 reply; 15+ messages in thread
From: zhanghan (J) @ 2021-01-14 2:34 UTC (permalink / raw)
To: jasowang
Cc: hang.zhanghailiang, hunongda, qemu-trivial, qemu-devel,
alex.chen, zhanghan64
ping?
This patch set is submmitted a month ago, and have received no replies.
Did I miss any replies?
The link follows:
http://patchwork.ozlabs.org/project/qemu-devel/cover/20201222082340.67405-1-zhanghan64@huawei.com/
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH 6/9] net: Transfer tabs to spcaes
2020-12-22 8:23 ` [PATCH 6/9] net: Transfer tabs to spcaes Zhang Han
@ 2021-01-14 11:34 ` Philippe Mathieu-Daudé
0 siblings, 0 replies; 15+ messages in thread
From: Philippe Mathieu-Daudé @ 2021-01-14 11:34 UTC (permalink / raw)
To: Zhang Han, jasowang
Cc: alex.chen, hunongda, qemu-trivial, hang.zhanghailiang, qemu-devel
On 12/22/20 9:23 AM, Zhang Han wrote:
> Code indent use spaces instead of tabs.
>
> Signed-off-by: Zhang Han <zhanghan64@huawei.com>
> ---
> net/tap-linux.h | 10 +++++-----
> 1 file changed, 5 insertions(+), 5 deletions(-)
FWIW typo "spaces" in subject (no need to repost).
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH 7/9] net: Remove assignment in if condition
2020-12-22 8:23 ` [PATCH 7/9] net: Remove assignment in if condition Zhang Han
@ 2021-01-14 11:35 ` Philippe Mathieu-Daudé
0 siblings, 0 replies; 15+ messages in thread
From: Philippe Mathieu-Daudé @ 2021-01-14 11:35 UTC (permalink / raw)
To: Zhang Han, jasowang
Cc: alex.chen, hunongda, qemu-trivial, hang.zhanghailiang, qemu-devel
On 12/22/20 9:23 AM, Zhang Han wrote:
> Put the assignment before the if condition
>
> Signed-off-by: Zhang Han <zhanghan64@huawei.com>
> ---
> net/tap-bsd.c | 3 ++-
> net/tap-solaris.c | 9 ++++++---
> 2 files changed, 8 insertions(+), 4 deletions(-)
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH 0/9] Fix some style problems in net
2021-01-14 2:34 ` zhanghan (J)
@ 2021-02-01 6:18 ` zhanghan (J)
0 siblings, 0 replies; 15+ messages in thread
From: zhanghan (J) @ 2021-02-01 6:18 UTC (permalink / raw)
To: jasowang
Cc: alex.chen, hunongda, qemu-trivial, hang.zhanghailiang, qemu-devel
ping?This patch set about code style problem in net receives no replies.
Did I miss any response?
The link follows:
http://patchwork.ozlabs.org/project/qemu-devel/cover/20201222082340.67405-1-zhanghan64@huawei.com/
^ permalink raw reply [flat|nested] 15+ messages in thread
end of thread, other threads:[~2021-02-01 6:19 UTC | newest]
Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-12-22 8:23 [PATCH 0/9] Fix some style problems in net Zhang Han
2020-12-22 8:23 ` [PATCH 1/9] net: Add spaces around operator/delete redundant spaces Zhang Han
2020-12-22 8:23 ` [PATCH 2/9] net: Add braces for statements/fix braces' position Zhang Han
2020-12-22 8:23 ` [PATCH 3/9] net: Transfer // comments to /**/ Zhang Han
2020-12-22 8:23 ` [PATCH 4/9] net: Transfer "foo* " to "foo *" Zhang Han
2020-12-22 8:23 ` [PATCH 5/9] net: Fix lines over 90 characters Zhang Han
2020-12-22 8:23 ` [PATCH 6/9] net: Transfer tabs to spcaes Zhang Han
2021-01-14 11:34 ` Philippe Mathieu-Daudé
2020-12-22 8:23 ` [PATCH 7/9] net: Remove assignment in if condition Zhang Han
2021-01-14 11:35 ` Philippe Mathieu-Daudé
2020-12-22 8:23 ` [PATCH 8/9] net: Remove initialization of static ints Zhang Han
2020-12-22 8:23 ` [PATCH 9/9] net: Fix the indent problems Zhang Han
2020-12-22 17:00 ` [PATCH 0/9] Fix some style problems in net no-reply
2021-01-14 2:34 ` zhanghan (J)
2021-02-01 6:18 ` zhanghan (J)
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.