Fix net.c coding style (with regard to tabs)
PATCH 1/1 Fix net.c coding style (with regard to tabs)
This patch will replace existing tab in net.c with spaces in accordance with qemu CODING_STYLE.
Note: This first patch is more of a test to see if it will be accepted and if it is worth spending my time on fixing the same issue in other files.
--- net.c | 118 ++++++++++++++++++++++++++++++++-------------------------------- 1 files changed, 59 insertions(+), 59 deletions(-)
net.c +59 -59
@@ -290,7 +290,7 @@ static int parse_unix_path(struct sockaddr_un *uaddr, const char *str) len =MIN (108 ,strlen (str)); p =strchr (str,',' );if (p) - len =MIN (len, p - str); + len =MIN (len, p - str);memset (uaddr,0 ,sizeof (*uaddr));
@@ -1220,7 +1220,7 @@ static int tap_alloc(char *dev, size_t dev_size) }if (ioctl (if_fd,SIOCGLIFFLAGS , &ifr) <0 ) -syslog (LOG_ERR ,"Can't get flags\n" ); +syslog (LOG_ERR ,"Can't get flags\n" );snprintf (actual_name,32 ,"tap%d" , ppa);pstrcpy (ifr.lifr_name,sizeof (ifr.lifr_name), actual_name);
@@ -1391,8 +1391,8 @@ static int net_tap_init(VLANState *vlan, const char *model,if (!setup_script || !strcmp (setup_script,"no" )) setup_script ="" ;if (setup_script[0 ] !='\0' ) { -if (launch_script (setup_script, ifname, fd)) -return -1 ; +if (launch_script (setup_script, ifname, fd)) +return -1 ; } s =net_tap_fd_init (vlan, model, name, fd); snprintf(s->vc->info_str, sizeof(s->vc->info_str),
@@ -1598,10 +1598,10 @@ static int net_socket_mcast_create(struct sockaddr_in *mcastaddr)int fd;int val, ret;if (!IN_MULTICAST (ntohl (mcastaddr->sin_addr.s_addr))) { -fprintf (stderr,"qemu: error: specified mcastaddr \"%s\" (0x%08x) does not contain a multicast address\n" , -inet_ntoa (mcastaddr->sin_addr), +fprintf (stderr,"qemu: error: specified mcastaddr \"%s\" (0x%08x) does not contain a multicast address\n" , +inet_ntoa (mcastaddr->sin_addr), (int )ntohl (mcastaddr->sin_addr.s_addr)); -return -1 ; +return -1 ; } fd =socket (PF_INET ,SOCK_DGRAM ,0 );
@@ -1614,8 +1614,8 @@ static int net_socket_mcast_create(struct sockaddr_in *mcastaddr) ret=setsockopt (fd,SOL_SOCKET ,SO_REUSEADDR , (const char *)&val,sizeof (val));if (ret <0 ) { -perror ("setsockopt(SOL_SOCKET, SO_REUSEADDR)" ); - goto fail; +perror ("setsockopt(SOL_SOCKET, SO_REUSEADDR)" ); + goto fail; } ret =bind (fd, (struct sockaddr *)mcastaddr,sizeof (*mcastaddr));
@@ -1631,8 +1631,8 @@ static int net_socket_mcast_create(struct sockaddr_in *mcastaddr) ret =setsockopt (fd,IPPROTO_IP ,IP_ADD_MEMBERSHIP , (const char *)&imr,sizeof (struct ip_mreq ));if (ret <0 ) { -perror ("setsockopt(IP_ADD_MEMBERSHIP)" ); - goto fail; +perror ("setsockopt(IP_ADD_MEMBERSHIP)" ); + goto fail; }/* Force mcast msgs to loopback (eg. several QEMUs in same host */
@@ -1640,8 +1640,8 @@ static int net_socket_mcast_create(struct sockaddr_in *mcastaddr) ret=setsockopt (fd,IPPROTO_IP ,IP_MULTICAST_LOOP , (const char *)&val,sizeof (val));if (ret <0 ) { -perror ("setsockopt(SOL_IP, IP_MULTICAST_LOOP)" ); - goto fail; +perror ("setsockopt(SOL_IP, IP_MULTICAST_LOOP)" ); + goto fail; }socket_set_nonblock (fd);
@@ -1676,29 +1676,29 @@ static NetSocketState *net_socket_fd_init_dgram(VLANState *vlan,*/ if (is_connected) { -if (getsockname (fd, (struct sockaddr *) &saddr, &saddr_len) ==0 ) { -/* must be bound */ -if (saddr.sin_addr.s_addr==0 ) { -fprintf (stderr,"qemu: error: init_dgram: fd=%d unbound, cannot setup multicast dst addr\n" , - fd); -return NULL ; - } -/* clone dgram socket */ - newfd =net_socket_mcast_create (&saddr); -if (newfd <0 ) { -/* error already reported by net_socket_mcast_create() */ -close (fd); -return NULL ; - } -/* clone newfd to fd, close newfd */ -dup2 (newfd, fd); -close (newfd); - - }else { -fprintf (stderr,"qemu: error: init_dgram: fd=%d failed getsockname(): %s\n" , - fd,strerror (errno)); -return NULL ; - } +if (getsockname (fd, (struct sockaddr *) &saddr, &saddr_len) ==0 ) { +/* must be bound */ +if (saddr.sin_addr.s_addr==0 ) { +fprintf (stderr,"qemu: error: init_dgram: fd=%d unbound, cannot setup multicast dst addr\n" , + fd); +return NULL ; + } +/* clone dgram socket */ + newfd =net_socket_mcast_create (&saddr); +if (newfd <0 ) { +/* error already reported by net_socket_mcast_create() */ +close (fd); +return NULL ; + } +/* clone newfd to fd, close newfd */ +dup2 (newfd, fd); +close (newfd); + + }else { +fprintf (stderr,"qemu: error: init_dgram: fd=%d failed getsockname(): %s\n" , + fd,strerror (errno)); +return NULL ; + } } s =qemu_mallocz (sizeof (NetSocketState));
@@ -1712,9 +1712,9 @@ static NetSocketState *net_socket_fd_init_dgram(VLANState *vlan,if (is_connected) s->dgram_dst=saddr;snprintf (s->vc->info_str,sizeof (s->vc->info_str), -"socket: fd=%d (%s mcast=%s:%d)" , - fd, is_connected?"cloned" :"" , -inet_ntoa (saddr.sin_addr),ntohs (saddr.sin_port)); +"socket: fd=%d (%s mcast=%s:%d)" , + fd, is_connected?"cloned" :"" , +inet_ntoa (saddr.sin_addr),ntohs (saddr.sin_port));return s; }
@@ -1752,8 +1752,8 @@ static NetSocketState *net_socket_fd_init(VLANState *vlan,if (getsockopt (fd,SOL_SOCKET ,SO_TYPE , (char *)&so_type, (socklen_t *)&optlen)<0 ) { -fprintf (stderr,"qemu: error: getsockopt(SO_TYPE) for fd=%d failed\n" , fd); -return NULL ; +fprintf (stderr,"qemu: error: getsockopt(SO_TYPE) for fd=%d failed\n" , fd); +return NULL ; }switch (so_type) {case SOCK_DGRAM :
@@ -1903,7 +1903,7 @@ static int net_socket_mcast_init(VLANState *vlan, fd =net_socket_mcast_create (&saddr);if (fd <0 ) -return -1 ; +return -1 ; s =net_socket_fd_init (vlan, model, name, fd,0 );if (!s)
@@ -2324,7 +2324,7 @@ int net_client_init(Monitor *mon, const char *device, const char *p) "vlan", "name", "sock", "port", "group", "mode", NULL };char vde_sock[1024 ], vde_group[512 ]; -int vde_port, vde_mode; +int vde_port, vde_mode;if (check_params (buf,sizeof (buf), vde_params, p) <0 ) {config_error (mon,"invalid parameter '%s' in '%s'\n" , buf, p);
@@ -2333,22 +2333,22 @@ int net_client_init(Monitor *mon, const char *device, const char *p) } vlan->nb_host_devs++;if (get_param_value (vde_sock,sizeof (vde_sock),"sock" , p) <=0 ) { - vde_sock[0 ] ='\0' ; - } -if (get_param_value (buf,sizeof (buf),"port" , p) >0 ) { - vde_port =strtol (buf,NULL ,10 ); - }else { - vde_port =0 ; - } -if (get_param_value (vde_group,sizeof (vde_group),"group" , p) <=0 ) { - vde_group[0 ] ='\0' ; - } -if (get_param_value (buf,sizeof (buf),"mode" , p) >0 ) { - vde_mode =strtol (buf,NULL ,8 ); - }else { - vde_mode =0700 ; - } - ret =net_vde_init (vlan, device, name, vde_sock, vde_port, vde_group, vde_mode); + vde_sock[0 ] ='\0' ; + } +if (get_param_value (buf,sizeof (buf),"port" , p) >0 ) { + vde_port =strtol (buf,NULL ,10 ); + }else { + vde_port =0 ; + } +if (get_param_value (vde_group,sizeof (vde_group),"group" , p) <=0 ) { + vde_group[0 ] ='\0' ; + } +if (get_param_value (buf,sizeof (buf),"mode" , p) >0 ) { + vde_mode =strtol (buf,NULL ,8 ); + }else { + vde_mode =0700 ; + } + ret =net_vde_init (vlan, device, name, vde_sock, vde_port, vde_group, vde_mode); } else#endif if (!strcmp (device,"dump" )) {
Signature · 1 line
1.6.0.4
Quoted 8 lines · Jean-Christophe DUBOIS
This patch will replace existing tab in
net.cwith spaces in accordance with qemuCODING_STYLE.Note: This first patch is more of a test to see if it will be accepted and if it is worth spending my time on fixing the same issue in other files.
Signed-off-by Jean-Christophe DUBOIS <[email protected]>
I wouldn't do this. We should just pay attention to do it right in code touched by new patches.
Kevin
Le lundi 22 juin 2009 10:29:10 Kevin Wolf, vous avez écrit :
Quoted 4 lines
Quoted 3 lines · Jean-Christophe DUBOIS
This patch will replace existing tab in
net.cwith spaces in accordance with qemuCODING_STYLE.
Quoted 8 lines
Quoted 5 lines
Note: This first patch is more of a test to see if it will be accepted and if it is worth spending my time on fixing the same issue in other files.
Signed-off-by Jean-Christophe DUBOIS <[email protected]>I wouldn't do this. We should just pay attention to do it right in code touched by new patches.
Some people are speaking about not killing 2 birds with one stone (and I don't speak about the kitten ;-) ) and in general I would think you should fix one problem per patch. I am not sure it is a good idea to ask somebody fixing one line in a file to also fix all the coding style issues of this same file. The real patch would be lost into a slew of unrelated changes. Is it not better to have a coding style only patch that bring the file to par?
Now you can certainly manage this the way you prefer.
JC
Quoted 1 line
Kevin
Quoted 9 lines · Jean-Christophe Dubois
Le lundi 22 juin 2009 10:29:10 Kevin Wolf, vous avez écrit :
Quoted 8 lines
Quoted 7 lines · Jean-Christophe DUBOIS
This patch will replace existing tab in
net.cwith spaces in accordance with qemuCODING_STYLE.Note: This first patch is more of a test to see if it will be accepted and if it is worth spending my time on fixing the same issue in other files.
Quoted 8 lines
Quoted 3 lines
Quoted 1 line
Signed-off-by Jean-Christophe DUBOIS <[email protected]>I wouldn't do this. We should just pay attention to do it right in code touched by new patches.
Some people are speaking about not killing 2 birds with one stone (and I don't speak about the kitten ;-) ) and in general I would think you should fix one problem per patch. I am not sure it is a good idea to ask somebody fixing one line in a file to also fix all the coding style issues of this same file.
Agreed, this is obviously nonsense. I'm just talking about the lines touched by the patch. What I mean is really just "Do it right in new code, leave old code alone". You might argue that this results in files with mixed indentation, but in my experience files using tabs are already mixed in most cases.
Anyway, just my personal opinion and I'm not the one who's to decide if we should have such whitespace cleanup patches.
Kevin