[6736] Sparse fixes: NULL use, header order, ANSI prototypes, static
Revision: 6736
http://svn.sv.gnu.org/viewvc/?view=rev&root=qemu&revision=6736 Author: blueswir1 Date: 2009-03-07 15:32:56 +0000 (Sat, 07 Mar 2009)
Log Message:
-----------
Sparse fixes: NULL use, header order, ANSI prototypes, static
Fix Sparse warnings:
* use NULL instead of plain 0
* rearrange header include order to avoid redefining types accidentally
* ANSIfy SLIRP
* avoid "restrict" keyword
* add static
Modified Paths:
--------------
trunk/block-dmg.c
trunk/block-vmdk.c
trunk/block-vvfat.c
trunk/bt-host.c
trunk/bt-vhci.c
trunk/console.c
trunk/curses.c
trunk/exec.c
trunk/hw/bt-hci.c
trunk/hw/bt-hid.c
trunk/hw/bt-l2cap.c
trunk/hw/bt-sdp.c
trunk/hw/ppce500_mpc8544ds.c
trunk/hw/usb-bt.c
trunk/hw/vmware_vga.c
trunk/hw/wm8750.c
trunk/monitor.c
trunk/net.c
trunk/osdep.c
trunk/savevm.c
trunk/sdl.c
trunk/slirp/if.c
trunk/slirp/ip_icmp.c
trunk/slirp/ip_input.c
trunk/slirp/ip_output.c
trunk/slirp/libslirp.h
trunk/slirp/mbuf.c
trunk/slirp/misc.c
trunk/slirp/sbuf.c
trunk/slirp/slirp.c
trunk/slirp/socket.c
trunk/slirp/tcp_input.c
trunk/slirp/tcp_output.c
trunk/slirp/tcp_subr.c
trunk/vl.cModified: trunk/block-dmg.c
===================================================================
block-dmg.c +1 -1
@@ -85,7 +85,7 @@return -errno; bs->read_only =1 ; s->n_chunks =0 ; - s->offsets = s->lengths = s->sectors = s->sectorcounts =0 ; + s->offsets = s->lengths = s->sectors = s->sectorcounts =NULL ;/* read offset of info blocks */ if (lseek (s->fd,-0x1d8 ,SEEK_END )<0 ) {
Modified: trunk/block-vmdk.c
===================================================================
block-vmdk.c +5 -5
@@ -134,7 +134,7 @@ cid_str_size =sizeof ("CID" ); } -if ((p_name =strstr (desc,cid_str)) !=0 ) { +if ((p_name =strstr (desc,cid_str)) !=NULL ) { p_name += cid_str_size;sscanf (p_name,"%x" ,&cid); }
@@ -154,7 +154,7 @@ tmp_str =strstr (desc,"parentCID" );pstrcpy (tmp_desc,sizeof (tmp_desc), tmp_str); -if ((p_name =strstr (desc,"CID" )) !=0 ) { +if ((p_name =strstr (desc,"CID" )) !=NULL ) { p_name +=sizeof ("CID" );snprintf (p_name,sizeof (desc) - (p_name - desc),"%x\n" , cid);pstrcat (desc,sizeof (desc), tmp_desc);
@@ -239,7 +239,7 @@if (read (p_fd, p_desc,DESC_SIZE ) !=DESC_SIZE ) goto fail; -if ((p_name =strstr (p_desc,"CID" )) !=0 ) { +if ((p_name =strstr (p_desc,"CID" )) !=NULL ) { p_name +=sizeof ("CID" );sscanf (p_name,"%x" ,&p_cid); }
@@ -330,12 +330,12 @@if (bdrv_pread (s->hd,0x200 , desc,DESC_SIZE ) !=DESC_SIZE )return -1 ; -if ((p_name =strstr (desc,"parentFileNameHint" )) !=0 ) { +if ((p_name =strstr (desc,"parentFileNameHint" )) !=NULL ) {char *end_name;struct stat file_buf; p_name +=sizeof ("parentFileNameHint" ) +1 ; -if ((end_name =strchr (p_name,'\"' )) ==0 ) +if ((end_name =strchr (p_name,'\"' )) ==NULL )return -1 ;if ((end_name - p_name) >sizeof (s->hd->backing_file) -1 )return -1 ;
Modified: trunk/block-vvfat.c
===================================================================
block-vvfat.c +7 -7
@@ -78,7 +78,7 @@static inline void array_init (array_t * array,unsigned int item_size) { - array->pointer=0 ; + array->pointer =NULL ; array->size=0 ; array->next=0 ; array->item_size=item_size;
@@ -129,7 +129,7 @@int increment=count*array->item_size; array->pointer=qemu_realloc (array->pointer,array->size+increment);if (!array->pointer) -return 0 ; +return NULL ; array->size+=increment; } memmove(array->pointer+(index+count)*array->item_size,
@@ -604,8 +604,8 @@ unsigned int directory_start, const char* filename, int is_dot) { int i,j,long_index=s->directory.next; -direntry_t * entry=0 ; -direntry_t * entry_long=0 ; +direntry_t * entry =NULL ; +direntry_t * entry_long =NULL ;if (is_dot) { entry=array_get_next (&(s->directory));
@@ -696,7 +696,7 @@int first_cluster = mapping->begin;int parent_index = mapping->info.dir.parent_mapping_index;mapping_t * parent_mapping = (mapping_t *) - (parent_index >=0 ?array_get (&(s->mapping), parent_index) :0 ); + (parent_index >=0 ?array_get (&(s->mapping), parent_index) :NULL );int first_cluster_of_parent = parent_mapping ? parent_mapping->begin :-1 ;DIR * dir=opendir (dirname);
@@ -1125,10 +1125,10 @@int index=find_mapping_for_cluster_aux (s,cluster_num,0 ,s->mapping.next);mapping_t * mapping;if (index>=s->mapping.next) -return 0 ; +return NULL ; mapping=array_get (&(s->mapping),index);if (mapping->begin>cluster_num) -return 0 ; +return NULL ;assert (mapping->begin<=cluster_num && mapping->end>cluster_num);return mapping; }
Modified: trunk/bt-host.c
===================================================================
bt-host.c +2 -2
@@ -171,7 +171,7 @@if (fd <0 ) {fprintf (stderr,"qemu: Can't open `%s': %s (%i)\n" , id,strerror (errno), errno); -return 0 ; +return NULL ; }# ifdef CONFIG_BLUEZ
@@ -192,7 +192,7 @@ s->hci.acl_send = bt_host_acl; s->hci.bdaddr_set = bt_host_bdaddr_set; -qemu_set_fd_handler2 (s->fd, bt_host_read_poll, bt_host_read,0 , s); +qemu_set_fd_handler2 (s->fd, bt_host_read_poll, bt_host_read,NULL , s);return &s->hci; }
Modified: trunk/bt-vhci.c
===================================================================
bt-vhci.c +1 -1
@@ -165,5 +165,5 @@ s->info->evt_recv = vhci_out_hci_packet_event; s->info->acl_recv = vhci_out_hci_packet_acl; -qemu_set_fd_handler (s->fd, vhci_read,0 , s); +qemu_set_fd_handler (s->fd, vhci_read,NULL , s); }
Modified: trunk/console.c
===================================================================
console.c +2 -2
@@ -1327,7 +1327,7 @@unsigned height;static int color_inited; - s =new_console (ds, (p ==0 ) ?TEXT_CONSOLE :TEXT_CONSOLE_FIXED_SIZE ); + s =new_console (ds, (p ==NULL ) ?TEXT_CONSOLE :TEXT_CONSOLE_FIXED_SIZE );if (!s) {free (chr);return ;
@@ -1353,7 +1353,7 @@ s->y =0 ; width =ds_get_width (s->ds); height =ds_get_height (s->ds); -if (p !=0 ) { +if (p !=NULL ) { width =strtoul (p, (char **)&p,10 );if (*p =='C' ) { p++;
Modified: trunk/curses.c
===================================================================
curses.c +4 -5
@@ -21,11 +21,6 @@* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ - -#include "qemu-common.h" -#include "console.h" -#include "sysemu.h" -#include <curses.h> #ifndef _WIN32
@@ -38,6 +33,10 @@#define resize_term resizeterm#endif +#include "qemu-common.h" +#include "console.h" +#include "sysemu.h" +#define FONT_HEIGHT 16#define FONT_WIDTH 8
Modified: trunk/exec.c
===================================================================
exec.c +1 -1
@@ -179,7 +179,7 @@CPUWriteMemoryFunc *io_mem_write[IO_MEM_NB_ENTRIES ][4 ];CPUReadMemoryFunc *io_mem_read[IO_MEM_NB_ENTRIES ][4 ];void *io_mem_opaque[IO_MEM_NB_ENTRIES ]; -char io_mem_used[IO_MEM_NB_ENTRIES ]; +static char io_mem_used[IO_MEM_NB_ENTRIES ];static int io_mem_watch;#endif
Modified: trunk/hw/bt-hci.c
===================================================================
hw/bt-hci.c +5 -5
@@ -446,7 +446,7 @@ mask_byte = (evt -1 ) >>3 ; mask =1 << ((evt -1 ) &3 );if (mask & bt_event_reserved_mask[mask_byte] & ~hci->event_mask[mask_byte]) -return 0 ; +return NULL ; packet = hci->evt_packet (hci->opaque); packet[0 ] = evt;
@@ -664,7 +664,7 @@static void bt_hci_lmp_link_teardown (struct bt_hci_s *hci,uint16_t handle) { handle &= ~HCI_HANDLE_OFFSET ; - hci->lm.handle[handle].link =0 ; + hci->lm.handle[handle].link =NULL ;if (bt_hci_role_master (hci, handle)) {qemu_del_timer (hci->lm.handle[handle].acl_mode_timer);
@@ -1138,7 +1138,7 @@ hci->device.page_scan =0 ;if (hci->device.lmp_name)qemu_free ((void *) hci->device.lmp_name); - hci->device.lmp_name =0 ; + hci->device.lmp_name =NULL ; hci->device.class[0 ] =0x00 ; hci->device.class[1 ] =0x00 ; hci->device.class[2 ] =0x00 ;
@@ -1617,7 +1617,7 @@bt_hci_event_status (hci,HCI_SUCCESS );bt_hci_connection_accept (hci, hci->conn_req_host); - hci->conn_req_host =0 ; + hci->conn_req_host =NULL ;break ;case cmd_opcode_pack (OGF_LINK_CTL ,OCF_REJECT_CONN_REQ ):
@@ -1634,7 +1634,7 @@bt_hci_connection_reject (hci, hci->conn_req_host,PARAM (reject_conn_req, reason));bt_hci_connection_reject_event (hci, &hci->conn_req_host->bd_addr); - hci->conn_req_host =0 ; + hci->conn_req_host =NULL ;break ;case cmd_opcode_pack (OGF_LINK_CTL ,OCF_AUTH_REQUESTED ):
Modified: trunk/hw/bt-hid.c
===================================================================
hw/bt-hid.c +5 -4
@@ -324,7 +324,8 @@break ; } s->proto = parameter; - s->usbdev->handle_control (s->usbdev,SET_PROTOCOL , s->proto,0 ,0 ,0 ); + s->usbdev->handle_control (s->usbdev,SET_PROTOCOL , s->proto,0 ,0 , +NULL ); ret =BT_HS_SUCCESSFUL ;break ;
@@ -347,7 +348,7 @@/* We don't need to know about the Idle Rate here really, * so just pass it on to the device. */ ret = s->usbdev->handle_control (s->usbdev, -SET_IDLE , data[1 ],0 ,0 ,0 ) ? +SET_IDLE , data[1 ],0 ,0 ,NULL ) ?BT_HS_SUCCESSFUL :BT_HS_ERR_INVALID_PARAMETER ;/* XXX: Does this generate a handshake? */ break ;
@@ -462,7 +463,7 @@ {struct bt_hid_device_s *hid = opaque; - hid->control =0 ; + hid->control =NULL ;bt_hid_connected_update (hid); }
@@ -470,7 +471,7 @@ {struct bt_hid_device_s *hid = opaque; - hid->interrupt =0 ; + hid->interrupt =NULL ;bt_hid_connected_update (hid); }
Modified: trunk/hw/bt-l2cap.c
===================================================================
hw/bt-l2cap.c +4 -4
@@ -401,7 +401,7 @@static struct l2cap_chan_s *l2cap_channel_open (struct l2cap_instance_s *l2cap,int psm,int source_cid) { -struct l2cap_chan_s *ch =0 ; +struct l2cap_chan_s *ch =NULL ;struct bt_l2cap_psm_s *psm_info;int result, status;int cid =l2cap_cid_new (l2cap);
@@ -452,7 +452,7 @@static void l2cap_channel_close (struct l2cap_instance_s *l2cap,int cid,int source_cid) { -struct l2cap_chan_s *ch =0 ; +struct l2cap_chan_s *ch =NULL ;/* According to Volume 3, section 6.1.1, pg 1048 of BT Core V2.0, a * connection in CLOSED state still responds with a L2CAP_DisconnectRsp
@@ -472,7 +472,7 @@return ; } - l2cap->cid[cid] =0 ; + l2cap->cid[cid] =NULL ; ch->params.close (ch->params.opaque);qemu_free (ch);
@@ -484,7 +484,7 @@static void l2cap_channel_config_null (struct l2cap_instance_s *l2cap,struct l2cap_chan_s *ch) { -l2cap_configuration_request (l2cap, ch->remote_cid,0 ,0 ,0 ); +l2cap_configuration_request (l2cap, ch->remote_cid,0 ,NULL ,0 ); ch->config_req_id = l2cap->last_id; ch->config &= ~L2CAP_CFG_INIT ; }
Modified: trunk/hw/bt-sdp.c
===================================================================
hw/bt-sdp.c +1 -1
@@ -948,7 +948,7 @@ &sdp_service_sdp_s, &sdp_service_hid_s, &sdp_service_pnp_s, -0 , +NULL , }; sdp->channel = params;
Modified: trunk/hw/ppce500_mpc8544ds.c
===================================================================
hw/ppce500_mpc8544ds.c +2 -0
@@ -47,6 +47,7 @@#define MPC8544_PCI_IO 0xE1000000#define MPC8544_PCI_IOLEN 0x10000 +#ifdef HAVE_FDT static int mpc8544_copy_soc_cell (void *fdt,const char *node,const char *prop) {uint32_t cell;
@@ -68,6 +69,7 @@ out:return ret; } +#endif static void *mpc8544_load_device_tree(void *addr, uint32_t ramsize,
Modified: trunk/hw/usb-bt.c
===================================================================
hw/usb-bt.c +3 -3
@@ -612,9 +612,9 @@ {struct USBBtState *s = (struct USBBtState *) dev->opaque; - s->hci->opaque =0 ; - s->hci->evt_recv =0 ; - s->hci->acl_recv =0 ; + s->hci->opaque =NULL ; + s->hci->evt_recv =NULL ; + s->hci->acl_recv =NULL ;qemu_free (s); }
Modified: trunk/hw/vmware_vga.c
===================================================================
hw/vmware_vga.c +10 -1
@@ -230,7 +230,6 @@#ifdef VERBOSE # define GUEST_OS_BASE 0x5001static const char *vmsvga_guest_id[] = { - [0x00 ...0x15 ] ="an unknown OS" , [0x00 ] ="Dos" , [0x01 ] ="Windows 3.1" , [0x02] = "Windows 95",
@@ -240,8 +239,18 @@ [0x06] = "Windows 2000", [0x07] = "Linux", [0x08] = "OS/2", + [0x09] = "an unknown OS", [0x0a] = "BSD", [0x0b] = "Whistler", + [0x0c] = "an unknown OS", + [0x0d] = "an unknown OS", + [0x0e] = "an unknown OS", + [0x0f] = "an unknown OS", + [0x10] = "an unknown OS", + [0x11] = "an unknown OS", + [0x12] = "an unknown OS", + [0x13] = "an unknown OS", + [0x14] = "an unknown OS", [0x15] = "Windows 2003", };#endif
Modified: trunk/hw/wm8750.c
===================================================================
hw/wm8750.c +2 -2
@@ -184,12 +184,12 @@for (i =0 ; i <IN_PORT_N ; i ++)if (s->adc_voice[i]) {AUD_close_in (&s->card, s->adc_voice[i]); - s->adc_voice[i] =0 ; + s->adc_voice[i] =NULL ; }for (i =0 ; i <OUT_PORT_N ; i ++)if (s->dac_voice[i]) {AUD_close_out (&s->card, s->dac_voice[i]); - s->dac_voice[i] =0 ; + s->dac_voice[i] =NULL ; }if (!s->enable)
Modified: trunk/monitor.c
===================================================================
monitor.c +1 -1
@@ -21,6 +21,7 @@* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ +#include <dirent.h> #include "hw/hw.h" #include "hw/usb.h" #include "hw/pcmcia.h"
@@ -37,7 +38,6 @@#include "audio/audio.h" #include "disas.h" #include "balloon.h" -#include <dirent.h> #include "qemu-timer.h" #include "migration.h" #include "kvm.h"
Modified: trunk/net.c
===================================================================
net.c +16 -16
@@ -21,14 +21,6 @@* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ -#include "qemu-common.h" -#include "net.h" -#include "monitor.h" -#include "sysemu.h" -#include "qemu-timer.h" -#include "qemu-char.h" -#include "audio/audio.h" -#include <unistd.h> #include <fcntl.h> #include <signal.h>
@@ -98,12 +90,6 @@#endif #endif -#include "qemu_socket.h" - -#if defined(CONFIG_SLIRP ) -#include "libslirp.h" -#endif -#if defined(__OpenBSD__)#include <util.h> #endif
@@ -120,6 +106,20 @@#define memalign (align, size) malloc(size)#endif +#include "qemu-common.h" +#include "net.h" +#include "monitor.h" +#include "sysemu.h" +#include "qemu-timer.h" +#include "qemu-char.h" +#include "audio/audio.h" +#include "qemu_socket.h" + +#if defined(CONFIG_SLIRP ) +#include "libslirp.h" +#endif + +static VLANState *first_vlan;/***********************************************************/
@@ -585,7 +585,7 @@char filename[1024 ];/* erase all the files in the directory */ -if ((d =opendir (dir_name)) !=0 ) { +if ((d =opendir (dir_name)) !=NULL ) {for (;;) { de =readdir (d);if (!de)
@@ -673,7 +673,7 @@struct VMChannel {CharDriverState *hd;int port; -} *vmchannels; +};static int vmchannel_can_read (void *opaque) {
Modified: trunk/osdep.c
===================================================================
osdep.c +2 -3
@@ -33,9 +33,6 @@#include <sys/statvfs.h> #endif -#include "qemu-common.h" -#include "sysemu.h" -#ifdef _WIN32#define WIN32_LEAN_AND_MEAN #include <windows.h>
@@ -45,6 +42,8 @@#include <malloc.h> #endif +#include "qemu-common.h" +#include "sysemu.h" #include "qemu_socket.h" #if defined(_WIN32)
Modified: trunk/savevm.c
===================================================================
savevm.c +12 -12
@@ -21,18 +21,6 @@* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ -#include "qemu-common.h" -#include "hw/hw.h" -#include "net.h" -#include "monitor.h" -#include "sysemu.h" -#include "qemu-timer.h" -#include "qemu-char.h" -#include "block.h" -#include "audio/audio.h" -#include "migration.h" -#include "qemu_socket.h" -#include <unistd.h> #include <fcntl.h> #include <signal.h>
@@ -87,6 +75,18 @@#define memalign (align, size) malloc(size)#endif +#include "qemu-common.h" +#include "hw/hw.h" +#include "net.h" +#include "monitor.h" +#include "sysemu.h" +#include "qemu-timer.h" +#include "qemu-char.h" +#include "block.h" +#include "audio/audio.h" +#include "migration.h" +#include "qemu_socket.h" +/* point to the block driver where the snapshots are managed */ static BlockDriverState *bs_snapshots;
Modified: trunk/sdl.c
===================================================================
sdl.c +5 -5
@@ -21,11 +21,6 @@* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ -#include "qemu-common.h" -#include "console.h" -#include "sysemu.h" -#include "x_keymap.h" -#include <SDL.h> #include <SDL/SDL_syswm.h>
@@ -33,6 +28,11 @@#include <signal.h> #endif +#include "qemu-common.h" +#include "console.h" +#include "sysemu.h" +#include "x_keymap.h" +static DisplayChangeListener *dcl;static SDL_Surface *real_screen;static SDL_Surface *guest_screen =NULL ;
Modified: trunk/slirp/if.c
===================================================================
slirp/if.c +2 -4
@@ -32,7 +32,7 @@ }void -if_init () +if_init (void ) { if_fastq.ifq_next = if_fastq.ifq_prev = &if_fastq; if_batchq.ifq_next = if_batchq.ifq_prev = &if_batchq;
@@ -133,9 +133,7 @@* it'll temporarily get downgraded to the batchq) */ void -if_output (so, ifm) -struct socket *so; -struct mbuf *ifm; +if_output (struct socket *so,struct mbuf *ifm) {struct mbuf *ifq;int on_fastq =1 ;
Modified: trunk/slirp/ip_icmp.c
===================================================================
slirp/ip_icmp.c +2 -5
@@ -68,9 +68,7 @@* Process a received ICMP message. */ void -icmp_input (m, hlen) -struct mbuf *m; -int hlen; +icmp_input (struct mbuf *m,int hlen) { registerstruct icmp *icp; register struct ip *ip=mtod(m, struct ip *);
@@ -319,8 +317,7 @@* Reflect the ip packet back to the source */ void -icmp_reflect (m) -struct mbuf *m; +icmp_reflect (struct mbuf *m) { register struct ip *ip = mtod(m, struct ip *);int hlen = ip->ip_hl <<2 ;
Modified: trunk/slirp/ip_input.c
===================================================================
slirp/ip_input.c +10 -13
@@ -60,7 +60,7 @@* All protocols not implemented in kernel go to raw IP protocol handler. */ void -ip_init () +ip_init (void ) { ipq.ip_link.next = ipq.ip_link.prev = &ipq.ip_link; ip_id = tt.tv_sec &0xffff ;
@@ -73,8 +73,7 @@* try to reassemble. Process options. Pass to next level. */ void -ip_input (m) -struct mbuf *m; +ip_input (struct mbuf *m) { registerstruct ip *ip;int hlen;
@@ -222,7 +221,7 @@if (ip->ip_tos &1 || ip->ip_off) {STAT (ipstat.ips_fragments++); ip =ip_reass (ip, fp); -if (ip ==0 ) +if (ip ==NULL )return ;STAT (ipstat.ips_reassembled++); m =dtom (ip);
@@ -289,7 +288,7 @@/* * If first fragment to arrive, create a reassembly queue. */ -if (fp ==0 ) { +if (fp ==NULL ) {struct mbuf *t;if ((t =m_get ()) ==NULL ) goto dropfrag; fp = mtod(t, struct ipq *);
@@ -357,11 +356,11 @@for (q = fp->frag_link.next; q != (struct ipasfrag *)&fp->frag_link; q = q->ipf_next) {if (q->ipf_off != next) -return (0 ); +return NULL ; next += q->ipf_len; }if (((struct ipasfrag *)(q->ipf_prev))->ipf_tos &1 ) -return (0 ); +return NULL ;/* * Reassembly is complete; concatenate fragments.
@@ -414,7 +413,7 @@ dropfrag:STAT (ipstat.ips_fragdropped++);m_freem (m); -return (0 ); +return NULL ; }/*
@@ -466,7 +465,7 @@* queue, discard it. */ void -ip_slowtimo () +ip_slowtimo (void ) {struct qlink *l;
@@ -474,7 +473,7 @@ l = ipq.ip_link.next; -if (l ==0 ) +if (l ==NULL )return ;while (l != &ipq.ip_link) {
@@ -702,9 +701,7 @@* (XXX) should be deleted; last arg currently ignored. */ void -ip_stripoptions (m, mopt) - registerstruct mbuf *m; -struct mbuf *mopt; +ip_stripoptions (registerstruct mbuf *m,struct mbuf *mopt) { registerint i; struct ip *ip = mtod(m, struct ip *);
Modified: trunk/slirp/ip_output.c
===================================================================
slirp/ip_output.c +3 -5
@@ -53,9 +53,7 @@* The mbuf opt, if present, will not be freed. */ int -ip_output (so, m0) -struct socket *so; -struct mbuf *m0; +ip_output (struct socket *so,struct mbuf *m0) { registerstruct ip *ip; registerstruct mbuf *m = m0;
@@ -135,7 +133,7 @@for (off = hlen + len; off < (u_int16_t )ip->ip_len; off += len) { registerstruct ip *mhip; m =m_get (); -if (m ==0 ) { +if (m ==NULL ) { error =-1 ;STAT (ipstat.ips_odropped++); goto sendorfree;
@@ -185,7 +183,7 @@ sendorfree:for (m = m0; m; m = m0) { m0 = m->m_nextpkt; - m->m_nextpkt =0 ; + m->m_nextpkt =NULL ;if (error ==0 )if_output (so, m);else
Modified: trunk/slirp/libslirp.h
===================================================================
slirp/libslirp.h +1 -1
@@ -5,7 +5,7 @@extern "C" {#endif -void slirp_init (int restrict,char *special_ip); +void slirp_init (int restricted,char *special_ip);void slirp_select_fill (int *pnfds,fd_set *readfds,fd_set *writefds,fd_set *xfds);
Modified: trunk/slirp/mbuf.c
===================================================================
slirp/mbuf.c +10 -19
@@ -29,7 +29,7 @@#define SLIRP_MSIZE (IF_MTU + IF_MAXLINKHDR + sizeof(struct m_hdr ) + 6)void -m_init () +m_init (void ) { m_freelist.m_next = m_freelist.m_prev = &m_freelist; m_usedlist.m_next = m_usedlist.m_prev = &m_usedlist;
@@ -44,7 +44,7 @@* which tells m_free to actually free() it */ struct mbuf * -m_get () +m_get (void ) { registerstruct mbuf *m;int flags =0 ;
@@ -72,16 +72,15 @@ m->m_size =SLIRP_MSIZE -sizeof (struct m_hdr ); m->m_data = m->m_dat; m->m_len =0 ; - m->m_nextpkt =0 ; - m->m_prevpkt =0 ; + m->m_nextpkt =NULL ; + m->m_prevpkt =NULL ; end_error:DEBUG_ARG ("m = %lx" , (long )m);return m; }void -m_free (m) -struct mbuf *m; +m_free (struct mbuf *m) {DEBUG_CALL ("m_free" );
@@ -115,8 +114,7 @@* an M_EXT data segment */ void -m_cat (m, n) - registerstruct mbuf *m, *n; +m_cat (struct mbuf *m,struct mbuf *n) {/* * If there's no room, realloc
@@ -133,9 +131,7 @@/* make m size bytes large */ void -m_inc (m, size) -struct mbuf *m; -int size; +m_inc (struct mbuf *m,int size) {int datasize;
@@ -170,9 +166,7 @@void -m_adj (m, len) -struct mbuf *m; -int len; +m_adj (struct mbuf *m,int len) {if (m ==NULL )return ;
@@ -192,9 +186,7 @@* Copy len bytes from m, starting off bytes into n */ int -m_copy (n, m, off, len) -struct mbuf *n, *m; -int off, len; +m_copy (struct mbuf *n,struct mbuf *m,int off,int len) {if (len >M_FREEROOM (n))return -1 ;
@@ -211,8 +203,7 @@* Fortunately, it's not used often */ struct mbuf * -dtom (dat ) - void *dat; +dtom (void *dat) {struct mbuf *m;
Modified: trunk/slirp/misc.c
===================================================================
slirp/misc.c +10 -20
@@ -70,7 +70,7 @@* Get our IP address and put it in our_addr */ void -getouraddr () +getouraddr (void ) {char buff[256 ];struct hostent *he =NULL ;
@@ -89,8 +89,7 @@ };inline void -insque (a, b) -void *a, *b; +insque (void *a,void *b) { registerstruct quehead *element = (struct quehead *) a; registerstruct quehead *head = (struct quehead *) b;
@@ -102,8 +101,7 @@ }inline void -remque (a) -void *a; +remque (void *a) { registerstruct quehead *element = (struct quehead *) a; ((struct quehead *)(element->qh_link))->qh_rlink = element->qh_rlink;
@@ -116,12 +114,7 @@int -add_exec (ex_ptr, do_pty, exec, addr, port) -struct ex_list **ex_ptr; -int do_pty; -char *exec; -int addr; -int port; +add_exec (struct ex_list **ex_ptr,int do_pty,char *exec,int addr,int port) {struct ex_list *tmp_ptr;
@@ -363,7 +356,7 @@ argv[i++] =strdup (curarg); }while (c); - argv[i] =0 ; + argv[i] =NULL ;execvp (argv[0 ], (char **)argv);/* Ooops, failed, let's tell the user why */
@@ -402,9 +395,9 @@fd_nonblock (so->s);/* Append the telnet options now */ -if (so->so_m !=0 && do_pty ==1 ) { +if (so->so_m !=NULL && do_pty ==1 ) {sbappend (so, so->so_m); - so->so_m =0 ; + so->so_m =NULL ; }return 1 ;
@@ -764,8 +757,7 @@#endif void -u_sleep (usec) -int usec; +u_sleep (int usec) {struct timeval t;fd_set fdset;
@@ -783,8 +775,7 @@*/ void -fd_nonblock (fd) -int fd; +fd_nonblock (int fd) {#ifdef FIONBIO int opt =1 ;
@@ -800,8 +791,7 @@ }void -fd_block (fd) -int fd; +fd_block (int fd) {#ifdef FIONBIO int opt =0 ;
Modified: trunk/slirp/sbuf.c
===================================================================
slirp/sbuf.c +5 -16
@@ -18,16 +18,13 @@*/ void -sbfree (sb) -struct sbuf *sb; +sbfree (struct sbuf *sb) {free (sb->sb_data); }void -sbdrop (sb, num) -struct sbuf *sb; -int num; +sbdrop (struct sbuf *sb,int num) {/* * We can only drop how much we have
@@ -43,9 +40,7 @@ }void -sbreserve (sb, size) -struct sbuf *sb; -int size; +sbreserve (struct sbuf *sb,int size) {if (sb->sb_data) {/* Already alloced, realloc if necessary */
@@ -74,9 +69,7 @@* (the socket is non-blocking, so we won't hang) */ void -sbappend (so, m) -struct socket *so; -struct mbuf *m; +sbappend (struct socket *so,struct mbuf *m) {int ret =0 ;
@@ -173,11 +166,7 @@* done in sbdrop when the data is acked */ void -sbcopy (sb, off, len, to) -struct sbuf *sb; -int off; -int len; -char *to; +sbcopy (struct sbuf *sb,int off,int len,char *to) {char *from;
Modified: trunk/slirp/slirp.c
===================================================================
slirp/slirp.c +4 -4
@@ -50,7 +50,7 @@const char *slirp_special_ip =CTL_SPECIAL ;int slirp_restrict; -int do_slowtimo; +static int do_slowtimo;int link_up;struct timeval tt;FILE *lfd;
@@ -171,7 +171,7 @@static void slirp_state_save (QEMUFile *f,void *opaque);static int slirp_state_load (QEMUFile *f,void *opaque,int version_id); -void slirp_init (int restrict,char *special_ip) +void slirp_init (int restricted,char *special_ip) {// debug_init("/tmp/slirp.log", DEBUG_DEFAULT);
@@ -184,7 +184,7 @@#endif link_up =1 ; - slirp_restrict = restrict; + slirp_restrict = restricted;if_init ();ip_init ();
@@ -228,7 +228,7 @@#else static void updtime (void ) { -gettimeofday (&tt,0 ); +gettimeofday (&tt,NULL ); curtime = (u_int )tt.tv_sec * (u_int )1000 ; curtime += (u_int )tt.tv_usec / (u_int )1000 ;
Modified: trunk/slirp/socket.c
===================================================================
slirp/socket.c +16 -36
142 lines not on this page · raw message
Modified: trunk/slirp/tcp_input.c
===================================================================
slirp/tcp_input.c +11 -16
@@ -121,10 +121,10 @@int flags;/* -* Call with ti==0 after become established to +* Call with ti==NULL after become established to * force pre-ESTABLISHED data up to user socket. */ -if (ti ==0 ) +if (ti ==NULL ) goto present;/*
@@ -230,19 +230,16 @@* protocol specification dated September, 1981 very closely. */ void -tcp_input (m, iphlen, inso) - registerstruct mbuf *m; -int iphlen; -struct socket *inso; +tcp_input (struct mbuf *m,int iphlen,struct socket *inso) {struct ip save_ip, *ip; registerstruct tcpiphdr *ti;caddr_t optp =NULL ;int optlen =0 ;int len, tlen, off; - registerstruct tcpcb *tp =0 ; + registerstruct tcpcb *tp =NULL ; registerint tiflags; -struct socket *so =0 ; +struct socket *so =NULL ;int todrop, acked, ourfinisacked, needoutput =0 ;/* int dropsocket = 0; */ int iss =0 ;
@@ -264,7 +261,7 @@/* Re-set a few variables */ tp =sototcpcb (so); m = so->so_m; - so->so_m =0 ; + so->so_m =NULL ; ti = so->so_ti; tiwin = ti->ti_win; tiflags = ti->ti_flags;
@@ -298,8 +295,8 @@* Checksum extended TCP header and data. */ tlen = ((struct ip *)ti)->ip_len; -tcpiphdr2qlink (ti)->next =tcpiphdr2qlink (ti)->prev =0 ; -memset (&ti->ti_i.ih_mbuf,0 ,sizeof (struct mbuf_ptr )); +tcpiphdr2qlink (ti)->next =tcpiphdr2qlink (ti)->prev =NULL ; +memset (&ti->ti_i.ih_mbuf,0 ,sizeof (struct mbuf_ptr )); ti->ti_x1 =0 ; ti->ti_len =htons ((u_int16_t )tlen); len =sizeof (struct ip ) + tlen;
@@ -399,7 +396,7 @@* the only flag set, then create a session, mark it * as if it was LISTENING, and continue... */ -if (so ==0 ) { +if (so ==NULL ) {if ((tiflags & (TH_SYN |TH_FIN |TH_RST |TH_URG |TH_ACK )) !=TH_SYN ) goto dropwithreset;
@@ -439,7 +436,7 @@ tp =sototcpcb (so);/* XXX Should never fail */ -if (tp ==0 ) +if (tp ==NULL ) goto dropwithreset;if (tp->t_state ==TCPS_CLOSED ) goto drop;
@@ -1697,9 +1694,7 @@*/ int -tcp_mss (tp, offer) - registerstruct tcpcb *tp; -u_int offer; +tcp_mss (struct tcpcb *tp,u_int offer) {struct socket *so = tp->t_socket;int mss;
Modified: trunk/slirp/tcp_output.c
===================================================================
slirp/tcp_output.c +2 -4
@@ -64,8 +64,7 @@* Tcp output routine: figure out what should be sent and send it. */ int -tcp_output (tp) - registerstruct tcpcb *tp; +tcp_output (struct tcpcb *tp) { registerstruct socket *so = tp->t_socket; registerlong len, win;
@@ -582,8 +581,7 @@ }void -tcp_setpersist (tp) - registerstruct tcpcb *tp; +tcp_setpersist (struct tcpcb *tp) {int t = ((tp->t_srtt >>2 ) + tp->t_rttvar) >>1 ;
Modified: trunk/slirp/tcp_subr.c
===================================================================
slirp/tcp_subr.c +18 -33
152 lines not on this page · raw message
Modified: trunk/vl.c
===================================================================
vl.c +29 -29
80 lines not on this page · raw message
Quoted 8 lines · Blue Swirl
Revision: 6736
http://svn.sv.gnu.org/viewvc/?view=rev&root=qemu&revision=6736 Author: blueswir1 Date: 2009-03-07 15:32:56 +0000 (Sat, 07 Mar 2009)Log Message:
-----------
Sparse fixes: NULL use, header order, ANSI prototypes, static
Quoted 7 lines
Fix Sparse warnings:
* use NULL instead of plain 0
* rearrange header include order to avoid redefining types accidentally
* ANSIfy SLIRP
* avoid "restrict" keyword
* add static
This broke the Windows build. The reason is that you moved all system headers to be included before any QEMU headers. While I agree with this in principle, Windows headers are sloppy and don't include their dependencies. Right now, we rely on qemu-common.h being included in the top in order to get #include <windows.h> every where.
To complicate matters further, we define some special versioning magic to get windows IPv6 support working. I don't want to add that full blob to every .c file so it makes sense to use a qemu include file (like qemu-common.h). That defeats that purpose of your refactoring though so I wanted to see what you thought about it.
Regards,
Anthony Liguori
Quoted 26 lines · Anthony Liguori
Quoted 2 lines · Blue Swirl
Revision: 6736
http://svn.sv.gnu.org/viewvc/?view=rev&root=qemu&revision=6736
Quoted 6 lines
Author: blueswir1 Date: 2009-03-07 15:32:56 +0000 (Sat, 07 Mar 2009)Log Message:
-----------
Sparse fixes: NULL use, header order, ANSI prototypes, staticQuoted 8 lines
Fix Sparse warnings:
* use NULL instead of plain 0
* rearrange header include order to avoid redefining types accidentally
* ANSIfy SLIRP
* avoid "restrict" keyword
* add staticThis broke the Windows build. The reason is that you moved all system
headers to be included before any QEMU headers. While I agree with this in principle, Windows headers are sloppy and don't include their dependencies. Right now, we rely onqemu-common.hbeing included in the top in order to get #include <windows.h> every where.
Quoted 5 lines
To complicate matters further, we define some special versioning magic to
get windows IPv6 support working. I don't want to add that full blob to every .c file so it makes sense to use a qemu include file (likeqemu-common.h). That defeats that purpose of your refactoring though so I wanted to see what you thought about it.
Taking vl.c as an example, do you mean that even these headers:
#include <unistd.h>
#include <fcntl.h>
#include <signal.h>
#include <time.h>
#include <errno.h>
#include <sys/time.h>
#include <zlib.h>
before config-host.h line are now broken because of missing windows.h include? Or is it just some header below that?
Quoted 33 lines · Blue Swirl
Quoted 26 lines · Anthony Liguori
Quoted 2 lines · Blue Swirl
Revision: 6736
http://svn.sv.gnu.org/viewvc/?view=rev&root=qemu&revision=6736
Quoted 6 lines
Author: blueswir1
Date: 2009-03-07 15:32:56 +0000 (Sat, 07 Mar 2009) Log Message:
-----------
Sparse fixes: NULL use, header order, ANSI prototypes, staticQuoted 8 lines
Fix Sparse warnings:
* use NULL instead of plain 0
* rearrange header include order to avoid redefining types accidentally
* ANSIfy SLIRP
* avoid "restrict" keyword
* add staticThis broke the Windows build. The reason is that you moved all system headers to be included before any QEMU headers. While I agree with this in principle, Windows headers are sloppy and don't include their dependencies. Right now, we rely on
qemu-common.hbeing included in the top in order to get #include <windows.h> every where.Quoted 5 lines
To complicate matters further, we define some special versioning magic to get windows IPv6 support working. I don't want to add that full blob to every .c file so it makes sense to use a qemu include file (like
qemu-common.h). That defeats that purpose of your refactoring though so I wanted to see what you thought about it.
Quoted 10 lines
Taking
vl.cas an example, do you mean that even these headers:
#include <unistd.h>
#include <fcntl.h>
#include <signal.h>
#include <time.h>
#include <errno.h>
#include <sys/time.h>
#include <zlib.h>
beforeconfig-host.hline are now broken because of missingwindows.hinclude? Or is it just some header below that?
Only mmsystem.h as far as I can see... which is also needlessly included in many files (savecm.c, net.c).
F.
Quoted 11 lines · Blue Swirl
Taking
vl.cas an example, do you mean that even these headers:
#include <unistd.h>
#include <fcntl.h>
#include <signal.h>
#include <time.h>
#include <errno.h>
#include <sys/time.h>
#include <zlib.h>
beforeconfig-host.hline are now broken because of missingwindows.hinclude? Or is it just some header below that?
Just windows headers. For example, from net.c:
Quoted 80 lines
#include <
unistd.h>
#include <fcntl.h>
#include <signal.h>
#include <time.h>
#include <errno.h>
#include <sys/time.h>
#include <zlib.h>/* Needed early for
HOST_BSDetc. */
#include "config-host.h"#ifndef
_WIN32
#include <sys/times.h>
#include <sys/wait.h>
#include <termios.h>
#include <sys/mman.h>
#include <sys/ioctl.h>
#include <sys/resource.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <net/if.h>
#ifdef__NetBSD__
#include <net/if_tap.h>
#endif
#ifdef__linux__
#include <linux/if_tun.h>
#endif
#include <arpa/inet.h>
#include <dirent.h>
#include <netdb.h>
#include <sys/select.h>
#ifdefHOST_BSD
#include <sys/stat.h>
#ifdefined(__FreeBSD__)||defined(__DragonFly__)#include <libutil.h>
#else
#include <util.h>
#endif
#elif defined (__GLIBC__) && defined (__FreeBSD_kernel__) #include <freebsd/stdlib.h>
#else
#ifdef__linux__
#include <pty.h>
#include <malloc.h>
#include <linux/rtc.h>/* For the benefit of older linux systems which don't supply it,
we use a local copy ofhpet.h. */
/* #include <linux/hpet.h> */
#include "hpet.h"#include <
linux/ppdev.h>
#include <linux/parport.h>
#endif
#ifdef__sun__
#include <sys/stat.h>
#include <sys/ethernet.h>
#include <sys/sockio.h>
#include <netinet/arp.h>
#include <netinet/in.h>
#include <netinet/in_systm.h>
#include <netinet/ip.h>
#include <netinet/ip_icmp.h> // must come afterip.h#include <netinet/udp.h>
#include <netinet/tcp.h>
#include <net/if.h>
#include <syslog.h>
#include <stropts.h>
#endif
#endif
#endif#if
defined(__OpenBSD__)
#include <util.h>
#endif#if
defined(CONFIG_VDE)
#include <libvdeplug.h>
#endif
Quoted 7 lines
#ifdef
_WIN32
#include <malloc.h>
#include <sys/timeb.h>
#include <mmsystem.h>
#definegetopt_long_onlygetopt_long
#definememalign(align, size)malloc(size)
#endif
mmsystem.h needs windows.h to be included first. We need to get that include from qemu-common.h. I see three options:
1) include qemu-common.h at the top of every file as we were previously
2) split out a qemu-win32.h or something like that that just contained the windows headers included as we need them
3) explicitly include <windows.h> and use -D CFLAGS to set things up as we need it.
I guess #3 looks the best to me.
Regards,
Anthony Liguori
Quoted 110 lines · Anthony Liguori
Quoted 12 lines · Blue Swirl
Taking
vl.cas an example, do you mean that even these headers:
#include <unistd.h>
#include <fcntl.h>
#include <signal.h>
#include <time.h>
#include <errno.h>
#include <sys/time.h>
#include <zlib.h>
beforeconfig-host.hline are now broken because of missingwindows.hinclude? Or is it just some header below that?Just windows headers. For example, from
net.c:Quoted 80 lines
#include <
unistd.h>
#include <fcntl.h>
#include <signal.h>
#include <time.h>
#include <errno.h>
#include <sys/time.h>
#include <zlib.h>/* Needed early for
HOST_BSDetc. */
#include "config-host.h"#ifndef
_WIN32
#include <sys/times.h>
#include <sys/wait.h>
#include <termios.h>
#include <sys/mman.h>
#include <sys/ioctl.h>
#include <sys/resource.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <net/if.h>
#ifdef__NetBSD__
#include <net/if_tap.h>
#endif
#ifdef__linux__
#include <linux/if_tun.h>
#endif
#include <arpa/inet.h>
#include <dirent.h>
#include <netdb.h>
#include <sys/select.h>
#ifdefHOST_BSD
#include <sys/stat.h>
#ifdefined(__FreeBSD__)||defined(__DragonFly__)#include <libutil.h>
#else
#include <util.h>
#endif
#elif defined (__GLIBC__) && defined (__FreeBSD_kernel__) #include <freebsd/stdlib.h>
#else
#ifdef__linux__
#include <pty.h>
#include <malloc.h>
#include <linux/rtc.h>/* For the benefit of older linux systems which don't supply it,
we use a local copy ofhpet.h. */
/* #include <linux/hpet.h> */
#include "hpet.h"#include <
linux/ppdev.h>
#include <linux/parport.h>
#endif
#ifdef__sun__
#include <sys/stat.h>
#include <sys/ethernet.h>
#include <sys/sockio.h>
#include <netinet/arp.h>
#include <netinet/in.h>
#include <netinet/in_systm.h>
#include <netinet/ip.h>
#include <netinet/ip_icmp.h> // must come afterip.h#include <netinet/udp.h>
#include <netinet/tcp.h>
#include <net/if.h>
#include <syslog.h>
#include <stropts.h>
#endif
#endif
#endif#if
defined(__OpenBSD__)
#include <util.h>
#endif#if
defined(CONFIG_VDE)
#include <libvdeplug.h>
#endifQuoted 8 lines
#ifdef
_WIN32
#include <malloc.h>
#include <sys/timeb.h>
#include <mmsystem.h>
#definegetopt_long_onlygetopt_long
#definememalign(align, size)malloc(size)
#endif
mmsystem.hneedswindows.hto be included first. We need to get that
include fromqemu-common.h. I see three options:
Quoted 7 lines
1) include
qemu-common.hat the top of every file as we were previously
2) split out aqemu-win32.hor something like that that just contained the
windows headers included as we need them
3) explicitly include <windows.h> and use -D CFLAGS to set things up as we
need it.I guess #3 looks the best to me.
I'd go for 2) but make it qemu-host.h which hides all Win/Linux/BSD specific stuff, maybe with -D tuning.
Quoted 11 lines · Blue Swirl
Quoted 9 lines · Anthony Liguori
mmsystem.hneedswindows.hto be included first. We need to get that
include fromqemu-common.h. I see three options:1) include
qemu-common.hat the top of every file as we were previously
2) split out aqemu-win32.hor something like that that just contained the
windows headers included as we need them
3) explicitly include <windows.h> and use -D CFLAGS to set things up as we
need it.
Quoted 6 lines
Quoted 2 lines
I guess #3 looks the best to me.
I'd go for 2) but make it
qemu-host.hwhich hides all Win/Linux/BSD specific stuff, maybe with -D tuning.
I'm about to commit #3. I think doing the #defines in a header file is wrong and broken. I see a large numbers of places in the tree right now that do it and it results in extra warnings. Using -D simplifies things and reduces warnings. Then adding #include <windows.h> where needed becomes pretty clean.
Regards,
Anthony Liguori