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



git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@6736 c046a42c-6fe2-441c-8c8c-71466251a162
This commit is contained in:
blueswir1 2009-03-07 15:32:56 +00:00
parent c276471991
commit 511d2b140f
35 changed files with 214 additions and 286 deletions

View file

@ -85,7 +85,7 @@ static int dmg_open(BlockDriverState *bs, const char *filename, int flags)
return -errno; return -errno;
bs->read_only = 1; bs->read_only = 1;
s->n_chunks = 0; 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 */ /* read offset of info blocks */
if(lseek(s->fd,-0x1d8,SEEK_END)<0) { if(lseek(s->fd,-0x1d8,SEEK_END)<0) {

View file

@ -134,7 +134,7 @@ static uint32_t vmdk_read_cid(BlockDriverState *bs, int parent)
cid_str_size = sizeof("CID"); 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; p_name += cid_str_size;
sscanf(p_name,"%x",&cid); sscanf(p_name,"%x",&cid);
} }
@ -154,7 +154,7 @@ static int vmdk_write_cid(BlockDriverState *bs, uint32_t cid)
tmp_str = strstr(desc,"parentCID"); tmp_str = strstr(desc,"parentCID");
pstrcpy(tmp_desc, sizeof(tmp_desc), tmp_str); 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"); p_name += sizeof("CID");
snprintf(p_name, sizeof(desc) - (p_name - desc), "%x\n", cid); snprintf(p_name, sizeof(desc) - (p_name - desc), "%x\n", cid);
pstrcat(desc, sizeof(desc), tmp_desc); pstrcat(desc, sizeof(desc), tmp_desc);
@ -239,7 +239,7 @@ static int vmdk_snapshot_create(const char *filename, const char *backing_file)
if (read(p_fd, p_desc, DESC_SIZE) != DESC_SIZE) if (read(p_fd, p_desc, DESC_SIZE) != DESC_SIZE)
goto fail; goto fail;
if ((p_name = strstr(p_desc,"CID")) != 0) { if ((p_name = strstr(p_desc,"CID")) != NULL) {
p_name += sizeof("CID"); p_name += sizeof("CID");
sscanf(p_name,"%x",&p_cid); sscanf(p_name,"%x",&p_cid);
} }
@ -330,12 +330,12 @@ static int vmdk_parent_open(BlockDriverState *bs, const char * filename)
if (bdrv_pread(s->hd, 0x200, desc, DESC_SIZE) != DESC_SIZE) if (bdrv_pread(s->hd, 0x200, desc, DESC_SIZE) != DESC_SIZE)
return -1; return -1;
if ((p_name = strstr(desc,"parentFileNameHint")) != 0) { if ((p_name = strstr(desc,"parentFileNameHint")) != NULL) {
char *end_name; char *end_name;
struct stat file_buf; struct stat file_buf;
p_name += sizeof("parentFileNameHint") + 1; p_name += sizeof("parentFileNameHint") + 1;
if ((end_name = strchr(p_name,'\"')) == 0) if ((end_name = strchr(p_name,'\"')) == NULL)
return -1; return -1;
if ((end_name - p_name) > sizeof (s->hd->backing_file) - 1) if ((end_name - p_name) > sizeof (s->hd->backing_file) - 1)
return -1; return -1;

View file

@ -78,7 +78,7 @@ typedef struct array_t {
static inline void array_init(array_t* array,unsigned int item_size) static inline void array_init(array_t* array,unsigned int item_size)
{ {
array->pointer=0; array->pointer = NULL;
array->size=0; array->size=0;
array->next=0; array->next=0;
array->item_size=item_size; array->item_size=item_size;
@ -129,7 +129,7 @@ static inline void* array_insert(array_t* array,unsigned int index,unsigned int
int increment=count*array->item_size; int increment=count*array->item_size;
array->pointer=qemu_realloc(array->pointer,array->size+increment); array->pointer=qemu_realloc(array->pointer,array->size+increment);
if(!array->pointer) if(!array->pointer)
return 0; return NULL;
array->size+=increment; array->size+=increment;
} }
memmove(array->pointer+(index+count)*array->item_size, memmove(array->pointer+(index+count)*array->item_size,
@ -604,8 +604,8 @@ static inline direntry_t* create_short_and_long_name(BDRVVVFATState* s,
unsigned int directory_start, const char* filename, int is_dot) unsigned int directory_start, const char* filename, int is_dot)
{ {
int i,j,long_index=s->directory.next; int i,j,long_index=s->directory.next;
direntry_t* entry=0; direntry_t* entry = NULL;
direntry_t* entry_long=0; direntry_t* entry_long = NULL;
if(is_dot) { if(is_dot) {
entry=array_get_next(&(s->directory)); entry=array_get_next(&(s->directory));
@ -696,7 +696,7 @@ static int read_directory(BDRVVVFATState* s, int mapping_index)
int first_cluster = mapping->begin; int first_cluster = mapping->begin;
int parent_index = mapping->info.dir.parent_mapping_index; int parent_index = mapping->info.dir.parent_mapping_index;
mapping_t* parent_mapping = (mapping_t*) 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; int first_cluster_of_parent = parent_mapping ? parent_mapping->begin : -1;
DIR* dir=opendir(dirname); DIR* dir=opendir(dirname);
@ -1125,10 +1125,10 @@ static inline mapping_t* find_mapping_for_cluster(BDRVVVFATState* s,int cluster_
int index=find_mapping_for_cluster_aux(s,cluster_num,0,s->mapping.next); int index=find_mapping_for_cluster_aux(s,cluster_num,0,s->mapping.next);
mapping_t* mapping; mapping_t* mapping;
if(index>=s->mapping.next) if(index>=s->mapping.next)
return 0; return NULL;
mapping=array_get(&(s->mapping),index); mapping=array_get(&(s->mapping),index);
if(mapping->begin>cluster_num) if(mapping->begin>cluster_num)
return 0; return NULL;
assert(mapping->begin<=cluster_num && mapping->end>cluster_num); assert(mapping->begin<=cluster_num && mapping->end>cluster_num);
return mapping; return mapping;
} }

View file

@ -171,7 +171,7 @@ struct HCIInfo *bt_host_hci(const char *id)
if (fd < 0) { if (fd < 0) {
fprintf(stderr, "qemu: Can't open `%s': %s (%i)\n", fprintf(stderr, "qemu: Can't open `%s': %s (%i)\n",
id, strerror(errno), errno); id, strerror(errno), errno);
return 0; return NULL;
} }
# ifdef CONFIG_BLUEZ # ifdef CONFIG_BLUEZ
@ -192,7 +192,7 @@ struct HCIInfo *bt_host_hci(const char *id)
s->hci.acl_send = bt_host_acl; s->hci.acl_send = bt_host_acl;
s->hci.bdaddr_set = bt_host_bdaddr_set; 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; return &s->hci;
} }

View file

@ -165,5 +165,5 @@ void bt_vhci_init(struct HCIInfo *info)
s->info->evt_recv = vhci_out_hci_packet_event; s->info->evt_recv = vhci_out_hci_packet_event;
s->info->acl_recv = vhci_out_hci_packet_acl; 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);
} }

View file

@ -1327,7 +1327,7 @@ static void text_console_do_init(CharDriverState *chr, DisplayState *ds, const c
unsigned height; unsigned height;
static int color_inited; 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) { if (!s) {
free(chr); free(chr);
return; return;
@ -1353,7 +1353,7 @@ static void text_console_do_init(CharDriverState *chr, DisplayState *ds, const c
s->y = 0; s->y = 0;
width = ds_get_width(s->ds); width = ds_get_width(s->ds);
height = ds_get_height(s->ds); height = ds_get_height(s->ds);
if (p != 0) { if (p != NULL) {
width = strtoul(p, (char **)&p, 10); width = strtoul(p, (char **)&p, 10);
if (*p == 'C') { if (*p == 'C') {
p++; p++;

View file

@ -21,11 +21,6 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE. * THE SOFTWARE.
*/ */
#include "qemu-common.h"
#include "console.h"
#include "sysemu.h"
#include <curses.h> #include <curses.h>
#ifndef _WIN32 #ifndef _WIN32
@ -38,6 +33,10 @@
#define resize_term resizeterm #define resize_term resizeterm
#endif #endif
#include "qemu-common.h"
#include "console.h"
#include "sysemu.h"
#define FONT_HEIGHT 16 #define FONT_HEIGHT 16
#define FONT_WIDTH 8 #define FONT_WIDTH 8

2
exec.c
View file

@ -179,7 +179,7 @@ static void io_mem_init(void);
CPUWriteMemoryFunc *io_mem_write[IO_MEM_NB_ENTRIES][4]; CPUWriteMemoryFunc *io_mem_write[IO_MEM_NB_ENTRIES][4];
CPUReadMemoryFunc *io_mem_read[IO_MEM_NB_ENTRIES][4]; CPUReadMemoryFunc *io_mem_read[IO_MEM_NB_ENTRIES][4];
void *io_mem_opaque[IO_MEM_NB_ENTRIES]; 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; static int io_mem_watch;
#endif #endif

View file

@ -446,7 +446,7 @@ static inline uint8_t *bt_hci_event_start(struct bt_hci_s *hci,
mask_byte = (evt - 1) >> 3; mask_byte = (evt - 1) >> 3;
mask = 1 << ((evt - 1) & 3); mask = 1 << ((evt - 1) & 3);
if (mask & bt_event_reserved_mask[mask_byte] & ~hci->event_mask[mask_byte]) if (mask & bt_event_reserved_mask[mask_byte] & ~hci->event_mask[mask_byte])
return 0; return NULL;
packet = hci->evt_packet(hci->opaque); packet = hci->evt_packet(hci->opaque);
packet[0] = evt; packet[0] = evt;
@ -664,7 +664,7 @@ static void bt_hci_lmp_link_establish(struct bt_hci_s *hci,
static void bt_hci_lmp_link_teardown(struct bt_hci_s *hci, uint16_t handle) static void bt_hci_lmp_link_teardown(struct bt_hci_s *hci, uint16_t handle)
{ {
handle &= ~HCI_HANDLE_OFFSET; handle &= ~HCI_HANDLE_OFFSET;
hci->lm.handle[handle].link = 0; hci->lm.handle[handle].link = NULL;
if (bt_hci_role_master(hci, handle)) { if (bt_hci_role_master(hci, handle)) {
qemu_del_timer(hci->lm.handle[handle].acl_mode_timer); qemu_del_timer(hci->lm.handle[handle].acl_mode_timer);
@ -1138,7 +1138,7 @@ static void bt_hci_reset(struct bt_hci_s *hci)
hci->device.page_scan = 0; hci->device.page_scan = 0;
if (hci->device.lmp_name) if (hci->device.lmp_name)
qemu_free((void *) 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[0] = 0x00;
hci->device.class[1] = 0x00; hci->device.class[1] = 0x00;
hci->device.class[2] = 0x00; hci->device.class[2] = 0x00;
@ -1617,7 +1617,7 @@ static void bt_submit_hci(struct HCIInfo *info,
bt_hci_event_status(hci, HCI_SUCCESS); bt_hci_event_status(hci, HCI_SUCCESS);
bt_hci_connection_accept(hci, hci->conn_req_host); bt_hci_connection_accept(hci, hci->conn_req_host);
hci->conn_req_host = 0; hci->conn_req_host = NULL;
break; break;
case cmd_opcode_pack(OGF_LINK_CTL, OCF_REJECT_CONN_REQ): case cmd_opcode_pack(OGF_LINK_CTL, OCF_REJECT_CONN_REQ):
@ -1634,7 +1634,7 @@ static void bt_submit_hci(struct HCIInfo *info,
bt_hci_connection_reject(hci, hci->conn_req_host, bt_hci_connection_reject(hci, hci->conn_req_host,
PARAM(reject_conn_req, reason)); PARAM(reject_conn_req, reason));
bt_hci_connection_reject_event(hci, &hci->conn_req_host->bd_addr); bt_hci_connection_reject_event(hci, &hci->conn_req_host->bd_addr);
hci->conn_req_host = 0; hci->conn_req_host = NULL;
break; break;
case cmd_opcode_pack(OGF_LINK_CTL, OCF_AUTH_REQUESTED): case cmd_opcode_pack(OGF_LINK_CTL, OCF_AUTH_REQUESTED):

View file

@ -324,7 +324,8 @@ static void bt_hid_control_transaction(struct bt_hid_device_s *s,
break; break;
} }
s->proto = parameter; 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; ret = BT_HS_SUCCESSFUL;
break; break;
@ -347,7 +348,7 @@ static void bt_hid_control_transaction(struct bt_hid_device_s *s,
/* We don't need to know about the Idle Rate here really, /* We don't need to know about the Idle Rate here really,
* so just pass it on to the device. */ * so just pass it on to the device. */
ret = s->usbdev->handle_control(s->usbdev, 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; BT_HS_SUCCESSFUL : BT_HS_ERR_INVALID_PARAMETER;
/* XXX: Does this generate a handshake? */ /* XXX: Does this generate a handshake? */
break; break;
@ -462,7 +463,7 @@ static void bt_hid_close_control(void *opaque)
{ {
struct bt_hid_device_s *hid = opaque; struct bt_hid_device_s *hid = opaque;
hid->control = 0; hid->control = NULL;
bt_hid_connected_update(hid); bt_hid_connected_update(hid);
} }
@ -470,7 +471,7 @@ static void bt_hid_close_interrupt(void *opaque)
{ {
struct bt_hid_device_s *hid = opaque; struct bt_hid_device_s *hid = opaque;
hid->interrupt = 0; hid->interrupt = NULL;
bt_hid_connected_update(hid); bt_hid_connected_update(hid);
} }

View file

@ -401,7 +401,7 @@ static inline struct bt_l2cap_psm_s *l2cap_psm(
static struct l2cap_chan_s *l2cap_channel_open(struct l2cap_instance_s *l2cap, static struct l2cap_chan_s *l2cap_channel_open(struct l2cap_instance_s *l2cap,
int psm, int source_cid) int psm, int source_cid)
{ {
struct l2cap_chan_s *ch = 0; struct l2cap_chan_s *ch = NULL;
struct bt_l2cap_psm_s *psm_info; struct bt_l2cap_psm_s *psm_info;
int result, status; int result, status;
int cid = l2cap_cid_new(l2cap); int cid = l2cap_cid_new(l2cap);
@ -452,7 +452,7 @@ static struct l2cap_chan_s *l2cap_channel_open(struct l2cap_instance_s *l2cap,
static void l2cap_channel_close(struct l2cap_instance_s *l2cap, static void l2cap_channel_close(struct l2cap_instance_s *l2cap,
int cid, int source_cid) 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 /* 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 * connection in CLOSED state still responds with a L2CAP_DisconnectRsp
@ -472,7 +472,7 @@ static void l2cap_channel_close(struct l2cap_instance_s *l2cap,
return; return;
} }
l2cap->cid[cid] = 0; l2cap->cid[cid] = NULL;
ch->params.close(ch->params.opaque); ch->params.close(ch->params.opaque);
qemu_free(ch); qemu_free(ch);
@ -484,7 +484,7 @@ static void l2cap_channel_close(struct l2cap_instance_s *l2cap,
static void l2cap_channel_config_null(struct l2cap_instance_s *l2cap, static void l2cap_channel_config_null(struct l2cap_instance_s *l2cap,
struct l2cap_chan_s *ch) 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_req_id = l2cap->last_id;
ch->config &= ~L2CAP_CFG_INIT; ch->config &= ~L2CAP_CFG_INIT;
} }

View file

@ -948,7 +948,7 @@ static int bt_l2cap_sdp_new_ch(struct bt_l2cap_device_s *dev,
&sdp_service_sdp_s, &sdp_service_sdp_s,
&sdp_service_hid_s, &sdp_service_hid_s,
&sdp_service_pnp_s, &sdp_service_pnp_s,
0, NULL,
}; };
sdp->channel = params; sdp->channel = params;

View file

@ -47,6 +47,7 @@
#define MPC8544_PCI_IO 0xE1000000 #define MPC8544_PCI_IO 0xE1000000
#define MPC8544_PCI_IOLEN 0x10000 #define MPC8544_PCI_IOLEN 0x10000
#ifdef HAVE_FDT
static int mpc8544_copy_soc_cell(void *fdt, const char *node, const char *prop) static int mpc8544_copy_soc_cell(void *fdt, const char *node, const char *prop)
{ {
uint32_t cell; uint32_t cell;
@ -68,6 +69,7 @@ static int mpc8544_copy_soc_cell(void *fdt, const char *node, const char *prop)
out: out:
return ret; return ret;
} }
#endif
static void *mpc8544_load_device_tree(void *addr, static void *mpc8544_load_device_tree(void *addr,
uint32_t ramsize, uint32_t ramsize,

View file

@ -612,9 +612,9 @@ static void usb_bt_handle_destroy(USBDevice *dev)
{ {
struct USBBtState *s = (struct USBBtState *) dev->opaque; struct USBBtState *s = (struct USBBtState *) dev->opaque;
s->hci->opaque = 0; s->hci->opaque = NULL;
s->hci->evt_recv = 0; s->hci->evt_recv = NULL;
s->hci->acl_recv = 0; s->hci->acl_recv = NULL;
qemu_free(s); qemu_free(s);
} }

View file

@ -230,7 +230,6 @@ enum {
#ifdef VERBOSE #ifdef VERBOSE
# define GUEST_OS_BASE 0x5001 # define GUEST_OS_BASE 0x5001
static const char *vmsvga_guest_id[] = { static const char *vmsvga_guest_id[] = {
[0x00 ... 0x15] = "an unknown OS",
[0x00] = "Dos", [0x00] = "Dos",
[0x01] = "Windows 3.1", [0x01] = "Windows 3.1",
[0x02] = "Windows 95", [0x02] = "Windows 95",
@ -240,8 +239,18 @@ static const char *vmsvga_guest_id[] = {
[0x06] = "Windows 2000", [0x06] = "Windows 2000",
[0x07] = "Linux", [0x07] = "Linux",
[0x08] = "OS/2", [0x08] = "OS/2",
[0x09] = "an unknown OS",
[0x0a] = "BSD", [0x0a] = "BSD",
[0x0b] = "Whistler", [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", [0x15] = "Windows 2003",
}; };
#endif #endif

View file

@ -184,12 +184,12 @@ static void wm8750_set_format(struct wm8750_s *s)
for (i = 0; i < IN_PORT_N; i ++) for (i = 0; i < IN_PORT_N; i ++)
if (s->adc_voice[i]) { if (s->adc_voice[i]) {
AUD_close_in(&s->card, 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 ++) for (i = 0; i < OUT_PORT_N; i ++)
if (s->dac_voice[i]) { if (s->dac_voice[i]) {
AUD_close_out(&s->card, 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) if (!s->enable)

View file

@ -21,6 +21,7 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE. * THE SOFTWARE.
*/ */
#include <dirent.h>
#include "hw/hw.h" #include "hw/hw.h"
#include "hw/usb.h" #include "hw/usb.h"
#include "hw/pcmcia.h" #include "hw/pcmcia.h"
@ -37,7 +38,6 @@
#include "audio/audio.h" #include "audio/audio.h"
#include "disas.h" #include "disas.h"
#include "balloon.h" #include "balloon.h"
#include <dirent.h>
#include "qemu-timer.h" #include "qemu-timer.h"
#include "migration.h" #include "migration.h"
#include "kvm.h" #include "kvm.h"

32
net.c
View file

@ -21,14 +21,6 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE. * 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 <unistd.h>
#include <fcntl.h> #include <fcntl.h>
#include <signal.h> #include <signal.h>
@ -98,12 +90,6 @@
#endif #endif
#endif #endif
#include "qemu_socket.h"
#if defined(CONFIG_SLIRP)
#include "libslirp.h"
#endif
#if defined(__OpenBSD__) #if defined(__OpenBSD__)
#include <util.h> #include <util.h>
#endif #endif
@ -120,6 +106,20 @@
#define memalign(align, size) malloc(size) #define memalign(align, size) malloc(size)
#endif #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; static VLANState *first_vlan;
/***********************************************************/ /***********************************************************/
@ -585,7 +585,7 @@ static void erase_dir(char *dir_name)
char filename[1024]; char filename[1024];
/* erase all the files in the directory */ /* erase all the files in the directory */
if ((d = opendir(dir_name)) != 0) { if ((d = opendir(dir_name)) != NULL) {
for(;;) { for(;;) {
de = readdir(d); de = readdir(d);
if (!de) if (!de)
@ -673,7 +673,7 @@ void do_info_slirp(Monitor *mon)
struct VMChannel { struct VMChannel {
CharDriverState *hd; CharDriverState *hd;
int port; int port;
} *vmchannels; };
static int vmchannel_can_read(void *opaque) static int vmchannel_can_read(void *opaque)
{ {

View file

@ -33,9 +33,6 @@
#include <sys/statvfs.h> #include <sys/statvfs.h>
#endif #endif
#include "qemu-common.h"
#include "sysemu.h"
#ifdef _WIN32 #ifdef _WIN32
#define WIN32_LEAN_AND_MEAN #define WIN32_LEAN_AND_MEAN
#include <windows.h> #include <windows.h>
@ -45,6 +42,8 @@
#include <malloc.h> #include <malloc.h>
#endif #endif
#include "qemu-common.h"
#include "sysemu.h"
#include "qemu_socket.h" #include "qemu_socket.h"
#if defined(_WIN32) #if defined(_WIN32)

View file

@ -21,18 +21,6 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE. * 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 <unistd.h>
#include <fcntl.h> #include <fcntl.h>
#include <signal.h> #include <signal.h>
@ -87,6 +75,18 @@
#define memalign(align, size) malloc(size) #define memalign(align, size) malloc(size)
#endif #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 */ /* point to the block driver where the snapshots are managed */
static BlockDriverState *bs_snapshots; static BlockDriverState *bs_snapshots;

10
sdl.c
View file

@ -21,11 +21,6 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE. * THE SOFTWARE.
*/ */
#include "qemu-common.h"
#include "console.h"
#include "sysemu.h"
#include "x_keymap.h"
#include <SDL.h> #include <SDL.h>
#include <SDL/SDL_syswm.h> #include <SDL/SDL_syswm.h>
@ -33,6 +28,11 @@
#include <signal.h> #include <signal.h>
#endif #endif
#include "qemu-common.h"
#include "console.h"
#include "sysemu.h"
#include "x_keymap.h"
static DisplayChangeListener *dcl; static DisplayChangeListener *dcl;
static SDL_Surface *real_screen; static SDL_Surface *real_screen;
static SDL_Surface *guest_screen = NULL; static SDL_Surface *guest_screen = NULL;

View file

@ -32,7 +32,7 @@ ifs_remque(struct mbuf *ifm)
} }
void void
if_init() if_init(void)
{ {
if_fastq.ifq_next = if_fastq.ifq_prev = &if_fastq; if_fastq.ifq_next = if_fastq.ifq_prev = &if_fastq;
if_batchq.ifq_next = if_batchq.ifq_prev = &if_batchq; if_batchq.ifq_next = if_batchq.ifq_prev = &if_batchq;
@ -133,9 +133,7 @@ if_input(ttyp)
* it'll temporarily get downgraded to the batchq) * it'll temporarily get downgraded to the batchq)
*/ */
void void
if_output(so, ifm) if_output(struct socket *so, struct mbuf *ifm)
struct socket *so;
struct mbuf *ifm;
{ {
struct mbuf *ifq; struct mbuf *ifq;
int on_fastq = 1; int on_fastq = 1;

View file

@ -68,9 +68,7 @@ static const int icmp_flush[19] = {
* Process a received ICMP message. * Process a received ICMP message.
*/ */
void void
icmp_input(m, hlen) icmp_input(struct mbuf *m, int hlen)
struct mbuf *m;
int hlen;
{ {
register struct icmp *icp; register struct icmp *icp;
register struct ip *ip=mtod(m, struct ip *); register struct ip *ip=mtod(m, struct ip *);
@ -319,8 +317,7 @@ end_error:
* Reflect the ip packet back to the source * Reflect the ip packet back to the source
*/ */
void void
icmp_reflect(m) icmp_reflect(struct mbuf *m)
struct mbuf *m;
{ {
register struct ip *ip = mtod(m, struct ip *); register struct ip *ip = mtod(m, struct ip *);
int hlen = ip->ip_hl << 2; int hlen = ip->ip_hl << 2;

View file

@ -60,7 +60,7 @@ static void ip_deq(register struct ipasfrag *p);
* All protocols not implemented in kernel go to raw IP protocol handler. * All protocols not implemented in kernel go to raw IP protocol handler.
*/ */
void void
ip_init() ip_init(void)
{ {
ipq.ip_link.next = ipq.ip_link.prev = &ipq.ip_link; ipq.ip_link.next = ipq.ip_link.prev = &ipq.ip_link;
ip_id = tt.tv_sec & 0xffff; ip_id = tt.tv_sec & 0xffff;
@ -73,8 +73,7 @@ ip_init()
* try to reassemble. Process options. Pass to next level. * try to reassemble. Process options. Pass to next level.
*/ */
void void
ip_input(m) ip_input(struct mbuf *m)
struct mbuf *m;
{ {
register struct ip *ip; register struct ip *ip;
int hlen; int hlen;
@ -222,7 +221,7 @@ ip_input(m)
if (ip->ip_tos & 1 || ip->ip_off) { if (ip->ip_tos & 1 || ip->ip_off) {
STAT(ipstat.ips_fragments++); STAT(ipstat.ips_fragments++);
ip = ip_reass(ip, fp); ip = ip_reass(ip, fp);
if (ip == 0) if (ip == NULL)
return; return;
STAT(ipstat.ips_reassembled++); STAT(ipstat.ips_reassembled++);
m = dtom(ip); m = dtom(ip);
@ -289,7 +288,7 @@ ip_reass(register struct ip *ip, register struct ipq *fp)
/* /*
* If first fragment to arrive, create a reassembly queue. * If first fragment to arrive, create a reassembly queue.
*/ */
if (fp == 0) { if (fp == NULL) {
struct mbuf *t; struct mbuf *t;
if ((t = m_get()) == NULL) goto dropfrag; if ((t = m_get()) == NULL) goto dropfrag;
fp = mtod(t, struct ipq *); fp = mtod(t, struct ipq *);
@ -357,11 +356,11 @@ insert:
for (q = fp->frag_link.next; q != (struct ipasfrag*)&fp->frag_link; for (q = fp->frag_link.next; q != (struct ipasfrag*)&fp->frag_link;
q = q->ipf_next) { q = q->ipf_next) {
if (q->ipf_off != next) if (q->ipf_off != next)
return (0); return NULL;
next += q->ipf_len; next += q->ipf_len;
} }
if (((struct ipasfrag *)(q->ipf_prev))->ipf_tos & 1) if (((struct ipasfrag *)(q->ipf_prev))->ipf_tos & 1)
return (0); return NULL;
/* /*
* Reassembly is complete; concatenate fragments. * Reassembly is complete; concatenate fragments.
@ -414,7 +413,7 @@ insert:
dropfrag: dropfrag:
STAT(ipstat.ips_fragdropped++); STAT(ipstat.ips_fragdropped++);
m_freem(m); m_freem(m);
return (0); return NULL;
} }
/* /*
@ -466,7 +465,7 @@ ip_deq(register struct ipasfrag *p)
* queue, discard it. * queue, discard it.
*/ */
void void
ip_slowtimo() ip_slowtimo(void)
{ {
struct qlink *l; struct qlink *l;
@ -474,7 +473,7 @@ ip_slowtimo()
l = ipq.ip_link.next; l = ipq.ip_link.next;
if (l == 0) if (l == NULL)
return; return;
while (l != &ipq.ip_link) { while (l != &ipq.ip_link) {
@ -702,9 +701,7 @@ bad:
* (XXX) should be deleted; last arg currently ignored. * (XXX) should be deleted; last arg currently ignored.
*/ */
void void
ip_stripoptions(m, mopt) ip_stripoptions(register struct mbuf *m, struct mbuf *mopt)
register struct mbuf *m;
struct mbuf *mopt;
{ {
register int i; register int i;
struct ip *ip = mtod(m, struct ip *); struct ip *ip = mtod(m, struct ip *);

View file

@ -53,9 +53,7 @@ u_int16_t ip_id;
* The mbuf opt, if present, will not be freed. * The mbuf opt, if present, will not be freed.
*/ */
int int
ip_output(so, m0) ip_output(struct socket *so, struct mbuf *m0)
struct socket *so;
struct mbuf *m0;
{ {
register struct ip *ip; register struct ip *ip;
register struct mbuf *m = m0; register struct mbuf *m = m0;
@ -135,7 +133,7 @@ ip_output(so, m0)
for (off = hlen + len; off < (u_int16_t)ip->ip_len; off += len) { for (off = hlen + len; off < (u_int16_t)ip->ip_len; off += len) {
register struct ip *mhip; register struct ip *mhip;
m = m_get(); m = m_get();
if (m == 0) { if (m == NULL) {
error = -1; error = -1;
STAT(ipstat.ips_odropped++); STAT(ipstat.ips_odropped++);
goto sendorfree; goto sendorfree;
@ -185,7 +183,7 @@ ip_output(so, m0)
sendorfree: sendorfree:
for (m = m0; m; m = m0) { for (m = m0; m; m = m0) {
m0 = m->m_nextpkt; m0 = m->m_nextpkt;
m->m_nextpkt = 0; m->m_nextpkt = NULL;
if (error == 0) if (error == 0)
if_output(so, m); if_output(so, m);
else else

View file

@ -5,7 +5,7 @@
extern "C" { extern "C" {
#endif #endif
void slirp_init(int restrict, char *special_ip); void slirp_init(int restricted, char *special_ip);
void slirp_select_fill(int *pnfds, void slirp_select_fill(int *pnfds,
fd_set *readfds, fd_set *writefds, fd_set *xfds); fd_set *readfds, fd_set *writefds, fd_set *xfds);

View file

@ -29,7 +29,7 @@ int mbuf_max = 0;
#define SLIRP_MSIZE (IF_MTU + IF_MAXLINKHDR + sizeof(struct m_hdr ) + 6) #define SLIRP_MSIZE (IF_MTU + IF_MAXLINKHDR + sizeof(struct m_hdr ) + 6)
void void
m_init() m_init(void)
{ {
m_freelist.m_next = m_freelist.m_prev = &m_freelist; m_freelist.m_next = m_freelist.m_prev = &m_freelist;
m_usedlist.m_next = m_usedlist.m_prev = &m_usedlist; m_usedlist.m_next = m_usedlist.m_prev = &m_usedlist;
@ -44,7 +44,7 @@ m_init()
* which tells m_free to actually free() it * which tells m_free to actually free() it
*/ */
struct mbuf * struct mbuf *
m_get() m_get(void)
{ {
register struct mbuf *m; register struct mbuf *m;
int flags = 0; int flags = 0;
@ -72,16 +72,15 @@ m_get()
m->m_size = SLIRP_MSIZE - sizeof(struct m_hdr); m->m_size = SLIRP_MSIZE - sizeof(struct m_hdr);
m->m_data = m->m_dat; m->m_data = m->m_dat;
m->m_len = 0; m->m_len = 0;
m->m_nextpkt = 0; m->m_nextpkt = NULL;
m->m_prevpkt = 0; m->m_prevpkt = NULL;
end_error: end_error:
DEBUG_ARG("m = %lx", (long )m); DEBUG_ARG("m = %lx", (long )m);
return m; return m;
} }
void void
m_free(m) m_free(struct mbuf *m)
struct mbuf *m;
{ {
DEBUG_CALL("m_free"); DEBUG_CALL("m_free");
@ -115,8 +114,7 @@ m_free(m)
* an M_EXT data segment * an M_EXT data segment
*/ */
void void
m_cat(m, n) m_cat(struct mbuf *m, struct mbuf *n)
register struct mbuf *m, *n;
{ {
/* /*
* If there's no room, realloc * If there's no room, realloc
@ -133,9 +131,7 @@ m_cat(m, n)
/* make m size bytes large */ /* make m size bytes large */
void void
m_inc(m, size) m_inc(struct mbuf *m, int size)
struct mbuf *m;
int size;
{ {
int datasize; int datasize;
@ -170,9 +166,7 @@ m_inc(m, size)
void void
m_adj(m, len) m_adj(struct mbuf *m, int len)
struct mbuf *m;
int len;
{ {
if (m == NULL) if (m == NULL)
return; return;
@ -192,9 +186,7 @@ m_adj(m, len)
* Copy len bytes from m, starting off bytes into n * Copy len bytes from m, starting off bytes into n
*/ */
int int
m_copy(n, m, off, len) m_copy(struct mbuf *n, struct mbuf *m, int off, int len)
struct mbuf *n, *m;
int off, len;
{ {
if (len > M_FREEROOM(n)) if (len > M_FREEROOM(n))
return -1; return -1;
@ -211,8 +203,7 @@ m_copy(n, m, off, len)
* Fortunately, it's not used often * Fortunately, it's not used often
*/ */
struct mbuf * struct mbuf *
dtom(dat) dtom(void *dat)
void *dat;
{ {
struct mbuf *m; struct mbuf *m;

View file

@ -70,7 +70,7 @@ redir_x(inaddr, start_port, display, screen)
* Get our IP address and put it in our_addr * Get our IP address and put it in our_addr
*/ */
void void
getouraddr() getouraddr(void)
{ {
char buff[256]; char buff[256];
struct hostent *he = NULL; struct hostent *he = NULL;
@ -89,8 +89,7 @@ struct quehead {
}; };
inline void inline void
insque(a, b) insque(void *a, void *b)
void *a, *b;
{ {
register struct quehead *element = (struct quehead *) a; register struct quehead *element = (struct quehead *) a;
register struct quehead *head = (struct quehead *) b; register struct quehead *head = (struct quehead *) b;
@ -102,8 +101,7 @@ insque(a, b)
} }
inline void inline void
remque(a) remque(void *a)
void *a;
{ {
register struct quehead *element = (struct quehead *) a; register struct quehead *element = (struct quehead *) a;
((struct quehead *)(element->qh_link))->qh_rlink = element->qh_rlink; ((struct quehead *)(element->qh_link))->qh_rlink = element->qh_rlink;
@ -116,12 +114,7 @@ remque(a)
int int
add_exec(ex_ptr, do_pty, exec, addr, port) add_exec(struct ex_list **ex_ptr, int do_pty, char *exec, int addr, int port)
struct ex_list **ex_ptr;
int do_pty;
char *exec;
int addr;
int port;
{ {
struct ex_list *tmp_ptr; struct ex_list *tmp_ptr;
@ -363,7 +356,7 @@ fork_exec(struct socket *so, const char *ex, int do_pty)
argv[i++] = strdup(curarg); argv[i++] = strdup(curarg);
} while (c); } while (c);
argv[i] = 0; argv[i] = NULL;
execvp(argv[0], (char **)argv); execvp(argv[0], (char **)argv);
/* Ooops, failed, let's tell the user why */ /* Ooops, failed, let's tell the user why */
@ -402,9 +395,9 @@ fork_exec(struct socket *so, const char *ex, int do_pty)
fd_nonblock(so->s); fd_nonblock(so->s);
/* Append the telnet options now */ /* 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); sbappend(so, so->so_m);
so->so_m = 0; so->so_m = NULL;
} }
return 1; return 1;
@ -764,8 +757,7 @@ sprintf_len(va_alist) va_dcl
#endif #endif
void void
u_sleep(usec) u_sleep(int usec)
int usec;
{ {
struct timeval t; struct timeval t;
fd_set fdset; fd_set fdset;
@ -783,8 +775,7 @@ u_sleep(usec)
*/ */
void void
fd_nonblock(fd) fd_nonblock(int fd)
int fd;
{ {
#ifdef FIONBIO #ifdef FIONBIO
int opt = 1; int opt = 1;
@ -800,8 +791,7 @@ fd_nonblock(fd)
} }
void void
fd_block(fd) fd_block(int fd)
int fd;
{ {
#ifdef FIONBIO #ifdef FIONBIO
int opt = 0; int opt = 0;

View file

@ -18,16 +18,13 @@ static void sbappendsb(struct sbuf *sb, struct mbuf *m);
*/ */
void void
sbfree(sb) sbfree(struct sbuf *sb)
struct sbuf *sb;
{ {
free(sb->sb_data); free(sb->sb_data);
} }
void void
sbdrop(sb, num) sbdrop(struct sbuf *sb, int num)
struct sbuf *sb;
int num;
{ {
/* /*
* We can only drop how much we have * We can only drop how much we have
@ -43,9 +40,7 @@ sbdrop(sb, num)
} }
void void
sbreserve(sb, size) sbreserve(struct sbuf *sb, int size)
struct sbuf *sb;
int size;
{ {
if (sb->sb_data) { if (sb->sb_data) {
/* Already alloced, realloc if necessary */ /* Already alloced, realloc if necessary */
@ -74,9 +69,7 @@ sbreserve(sb, size)
* (the socket is non-blocking, so we won't hang) * (the socket is non-blocking, so we won't hang)
*/ */
void void
sbappend(so, m) sbappend(struct socket *so, struct mbuf *m)
struct socket *so;
struct mbuf *m;
{ {
int ret = 0; int ret = 0;
@ -173,11 +166,7 @@ sbappendsb(struct sbuf *sb, struct mbuf *m)
* done in sbdrop when the data is acked * done in sbdrop when the data is acked
*/ */
void void
sbcopy(sb, off, len, to) sbcopy(struct sbuf *sb, int off, int len, char *to)
struct sbuf *sb;
int off;
int len;
char *to;
{ {
char *from; char *from;

View file

@ -50,7 +50,7 @@ static const uint8_t zero_ethaddr[6] = { 0, 0, 0, 0, 0, 0 };
const char *slirp_special_ip = CTL_SPECIAL; const char *slirp_special_ip = CTL_SPECIAL;
int slirp_restrict; int slirp_restrict;
int do_slowtimo; static int do_slowtimo;
int link_up; int link_up;
struct timeval tt; struct timeval tt;
FILE *lfd; FILE *lfd;
@ -171,7 +171,7 @@ static void slirp_cleanup(void)
static void slirp_state_save(QEMUFile *f, void *opaque); static void slirp_state_save(QEMUFile *f, void *opaque);
static int slirp_state_load(QEMUFile *f, void *opaque, int version_id); 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); // debug_init("/tmp/slirp.log", DEBUG_DEFAULT);
@ -184,7 +184,7 @@ void slirp_init(int restrict, char *special_ip)
#endif #endif
link_up = 1; link_up = 1;
slirp_restrict = restrict; slirp_restrict = restricted;
if_init(); if_init();
ip_init(); ip_init();
@ -228,7 +228,7 @@ static void updtime(void)
#else #else
static void updtime(void) static void updtime(void)
{ {
gettimeofday(&tt, 0); gettimeofday(&tt, NULL);
curtime = (u_int)tt.tv_sec * (u_int)1000; curtime = (u_int)tt.tv_sec * (u_int)1000;
curtime += (u_int)tt.tv_usec / (u_int)1000; curtime += (u_int)tt.tv_usec / (u_int)1000;

View file

@ -25,12 +25,8 @@ so_init()
#endif #endif
struct socket * struct socket *
solookup(head, laddr, lport, faddr, fport) solookup(struct socket *head, struct in_addr laddr, u_int lport,
struct socket *head; struct in_addr faddr, u_int fport)
struct in_addr laddr;
u_int lport;
struct in_addr faddr;
u_int fport;
{ {
struct socket *so; struct socket *so;
@ -54,7 +50,7 @@ solookup(head, laddr, lport, faddr, fport)
* insque() it into the correct linked-list * insque() it into the correct linked-list
*/ */
struct socket * struct socket *
socreate() socreate(void)
{ {
struct socket *so; struct socket *so;
@ -71,8 +67,7 @@ socreate()
* remque and free a socket, clobber cache * remque and free a socket, clobber cache
*/ */
void void
sofree(so) sofree(struct socket *so)
struct socket *so;
{ {
if (so->so_emu==EMU_RSH && so->extra) { if (so->so_emu==EMU_RSH && so->extra) {
sofree(so->extra); sofree(so->extra);
@ -158,8 +153,7 @@ size_t sopreprbuf(struct socket *so, struct iovec *iov, int *np)
* a read() of 0 (or less) means it's disconnected * a read() of 0 (or less) means it's disconnected
*/ */
int int
soread(so) soread(struct socket *so)
struct socket *so;
{ {
int n, nn; int n, nn;
struct sbuf *sb = &so->so_snd; struct sbuf *sb = &so->so_snd;
@ -269,8 +263,7 @@ err:
* in the send buffer is sent as urgent data * in the send buffer is sent as urgent data
*/ */
void void
sorecvoob(so) sorecvoob(struct socket *so)
struct socket *so;
{ {
struct tcpcb *tp = sototcpcb(so); struct tcpcb *tp = sototcpcb(so);
@ -297,8 +290,7 @@ sorecvoob(so)
* There's a lot duplicated code here, but... * There's a lot duplicated code here, but...
*/ */
int int
sosendoob(so) sosendoob(struct socket *so)
struct socket *so;
{ {
struct sbuf *sb = &so->so_rcv; struct sbuf *sb = &so->so_rcv;
char buff[2048]; /* XXX Shouldn't be sending more oob data than this */ char buff[2048]; /* XXX Shouldn't be sending more oob data than this */
@ -356,8 +348,7 @@ sosendoob(so)
* updating all sbuf field as necessary * updating all sbuf field as necessary
*/ */
int int
sowrite(so) sowrite(struct socket *so)
struct socket *so;
{ {
int n,nn; int n,nn;
struct sbuf *sb = &so->so_rcv; struct sbuf *sb = &so->so_rcv;
@ -451,8 +442,7 @@ sowrite(so)
* recvfrom() a UDP socket * recvfrom() a UDP socket
*/ */
void void
sorecvfrom(so) sorecvfrom(struct socket *so)
struct socket *so;
{ {
struct sockaddr_in addr; struct sockaddr_in addr;
socklen_t addrlen = sizeof(struct sockaddr_in); socklen_t addrlen = sizeof(struct sockaddr_in);
@ -479,7 +469,7 @@ sorecvfrom(so)
icmp_error(so->so_m, ICMP_UNREACH,code, 0,strerror(errno)); icmp_error(so->so_m, ICMP_UNREACH,code, 0,strerror(errno));
} else { } else {
icmp_reflect(so->so_m); icmp_reflect(so->so_m);
so->so_m = 0; /* Don't m_free() it again! */ so->so_m = NULL; /* Don't m_free() it again! */
} }
/* No need for this socket anymore, udp_detach it */ /* No need for this socket anymore, udp_detach it */
udp_detach(so); udp_detach(so);
@ -551,9 +541,7 @@ sorecvfrom(so)
* sendto() a socket * sendto() a socket
*/ */
int int
sosendto(so, m) sosendto(struct socket *so, struct mbuf *m)
struct socket *so;
struct mbuf *m;
{ {
int ret; int ret;
struct sockaddr_in addr; struct sockaddr_in addr;
@ -600,11 +588,7 @@ sosendto(so, m)
* XXX This should really be tcp_listen * XXX This should really be tcp_listen
*/ */
struct socket * struct socket *
solisten(port, laddr, lport, flags) solisten(u_int port, u_int32_t laddr, u_int lport, int flags)
u_int port;
u_int32_t laddr;
u_int lport;
int flags;
{ {
struct sockaddr_in addr; struct sockaddr_in addr;
struct socket *so; struct socket *so;
@ -706,8 +690,7 @@ sowwakeup(so)
* times each when only 1 was needed * times each when only 1 was needed
*/ */
void void
soisfconnecting(so) soisfconnecting(struct socket *so)
register struct socket *so;
{ {
so->so_state &= ~(SS_NOFDREF|SS_ISFCONNECTED|SS_FCANTRCVMORE| so->so_state &= ~(SS_NOFDREF|SS_ISFCONNECTED|SS_FCANTRCVMORE|
SS_FCANTSENDMORE|SS_FWDRAIN); SS_FCANTSENDMORE|SS_FWDRAIN);
@ -715,8 +698,7 @@ soisfconnecting(so)
} }
void void
soisfconnected(so) soisfconnected(struct socket *so)
register struct socket *so;
{ {
so->so_state &= ~(SS_ISFCONNECTING|SS_FWDRAIN|SS_NOFDREF); so->so_state &= ~(SS_ISFCONNECTING|SS_FWDRAIN|SS_NOFDREF);
so->so_state |= SS_ISFCONNECTED; /* Clobber other states */ so->so_state |= SS_ISFCONNECTED; /* Clobber other states */
@ -758,8 +740,7 @@ sofcantsendmore(struct socket *so)
} }
void void
soisfdisconnected(so) soisfdisconnected(struct socket *so)
struct socket *so;
{ {
/* so->so_state &= ~(SS_ISFCONNECTING|SS_ISFCONNECTED); */ /* so->so_state &= ~(SS_ISFCONNECTING|SS_ISFCONNECTED); */
/* close(so->s); */ /* close(so->s); */
@ -774,8 +755,7 @@ soisfdisconnected(so)
* Set CANTSENDMORE once all data has been write()n * Set CANTSENDMORE once all data has been write()n
*/ */
void void
sofwdrain(so) sofwdrain(struct socket *so)
struct socket *so;
{ {
if (so->so_rcv.sb_cc) if (so->so_rcv.sb_cc)
so->so_state |= SS_FWDRAIN; so->so_state |= SS_FWDRAIN;

View file

@ -121,10 +121,10 @@ tcp_reass(register struct tcpcb *tp, register struct tcpiphdr *ti,
int flags; 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. * force pre-ESTABLISHED data up to user socket.
*/ */
if (ti == 0) if (ti == NULL)
goto present; goto present;
/* /*
@ -230,19 +230,16 @@ present:
* protocol specification dated September, 1981 very closely. * protocol specification dated September, 1981 very closely.
*/ */
void void
tcp_input(m, iphlen, inso) tcp_input(struct mbuf *m, int iphlen, struct socket *inso)
register struct mbuf *m;
int iphlen;
struct socket *inso;
{ {
struct ip save_ip, *ip; struct ip save_ip, *ip;
register struct tcpiphdr *ti; register struct tcpiphdr *ti;
caddr_t optp = NULL; caddr_t optp = NULL;
int optlen = 0; int optlen = 0;
int len, tlen, off; int len, tlen, off;
register struct tcpcb *tp = 0; register struct tcpcb *tp = NULL;
register int tiflags; register int tiflags;
struct socket *so = 0; struct socket *so = NULL;
int todrop, acked, ourfinisacked, needoutput = 0; int todrop, acked, ourfinisacked, needoutput = 0;
/* int dropsocket = 0; */ /* int dropsocket = 0; */
int iss = 0; int iss = 0;
@ -264,7 +261,7 @@ tcp_input(m, iphlen, inso)
/* Re-set a few variables */ /* Re-set a few variables */
tp = sototcpcb(so); tp = sototcpcb(so);
m = so->so_m; m = so->so_m;
so->so_m = 0; so->so_m = NULL;
ti = so->so_ti; ti = so->so_ti;
tiwin = ti->ti_win; tiwin = ti->ti_win;
tiflags = ti->ti_flags; tiflags = ti->ti_flags;
@ -298,8 +295,8 @@ tcp_input(m, iphlen, inso)
* Checksum extended TCP header and data. * Checksum extended TCP header and data.
*/ */
tlen = ((struct ip *)ti)->ip_len; tlen = ((struct ip *)ti)->ip_len;
tcpiphdr2qlink(ti)->next = tcpiphdr2qlink(ti)->prev = 0; tcpiphdr2qlink(ti)->next = tcpiphdr2qlink(ti)->prev = NULL;
memset(&ti->ti_i.ih_mbuf, 0 , sizeof(struct mbuf_ptr)); memset(&ti->ti_i.ih_mbuf, 0 , sizeof(struct mbuf_ptr));
ti->ti_x1 = 0; ti->ti_x1 = 0;
ti->ti_len = htons((u_int16_t)tlen); ti->ti_len = htons((u_int16_t)tlen);
len = sizeof(struct ip ) + tlen; len = sizeof(struct ip ) + tlen;
@ -399,7 +396,7 @@ findso:
* the only flag set, then create a session, mark it * the only flag set, then create a session, mark it
* as if it was LISTENING, and continue... * 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) if ((tiflags & (TH_SYN|TH_FIN|TH_RST|TH_URG|TH_ACK)) != TH_SYN)
goto dropwithreset; goto dropwithreset;
@ -439,7 +436,7 @@ findso:
tp = sototcpcb(so); tp = sototcpcb(so);
/* XXX Should never fail */ /* XXX Should never fail */
if (tp == 0) if (tp == NULL)
goto dropwithreset; goto dropwithreset;
if (tp->t_state == TCPS_CLOSED) if (tp->t_state == TCPS_CLOSED)
goto drop; goto drop;
@ -1697,9 +1694,7 @@ tcp_xmit_timer(register struct tcpcb *tp, int rtt)
*/ */
int int
tcp_mss(tp, offer) tcp_mss(struct tcpcb *tp, u_int offer)
register struct tcpcb *tp;
u_int offer;
{ {
struct socket *so = tp->t_socket; struct socket *so = tp->t_socket;
int mss; int mss;

View file

@ -64,8 +64,7 @@ static const u_char tcp_outflags[TCP_NSTATES] = {
* Tcp output routine: figure out what should be sent and send it. * Tcp output routine: figure out what should be sent and send it.
*/ */
int int
tcp_output(tp) tcp_output(struct tcpcb *tp)
register struct tcpcb *tp;
{ {
register struct socket *so = tp->t_socket; register struct socket *so = tp->t_socket;
register long len, win; register long len, win;
@ -582,8 +581,7 @@ out:
} }
void void
tcp_setpersist(tp) tcp_setpersist(struct tcpcb *tp)
register struct tcpcb *tp;
{ {
int t = ((tp->t_srtt >> 2) + tp->t_rttvar) >> 1; int t = ((tp->t_srtt >> 2) + tp->t_rttvar) >> 1;

View file

@ -49,7 +49,7 @@
* Tcp initialization * Tcp initialization
*/ */
void void
tcp_init() tcp_init(void)
{ {
tcp_iss = 1; /* wrong */ tcp_iss = 1; /* wrong */
tcb.so_next = tcb.so_prev = &tcb; tcb.so_next = tcb.so_prev = &tcb;
@ -63,8 +63,7 @@ tcp_init()
*/ */
/* struct tcpiphdr * */ /* struct tcpiphdr * */
void void
tcp_template(tp) tcp_template(struct tcpcb *tp)
struct tcpcb *tp;
{ {
struct socket *so = tp->t_socket; struct socket *so = tp->t_socket;
register struct tcpiphdr *n = &tp->t_template; register struct tcpiphdr *n = &tp->t_template;
@ -102,12 +101,8 @@ tcp_template(tp)
* segment are as specified by the parameters. * segment are as specified by the parameters.
*/ */
void void
tcp_respond(tp, ti, m, ack, seq, flags) tcp_respond(struct tcpcb *tp, struct tcpiphdr *ti, struct mbuf *m,
struct tcpcb *tp; tcp_seq ack, tcp_seq seq, int flags)
register struct tcpiphdr *ti;
register struct mbuf *m;
tcp_seq ack, seq;
int flags;
{ {
register int tlen; register int tlen;
int win = 0; int win = 0;
@ -122,7 +117,7 @@ tcp_respond(tp, ti, m, ack, seq, flags)
if (tp) if (tp)
win = sbspace(&tp->t_socket->so_rcv); win = sbspace(&tp->t_socket->so_rcv);
if (m == 0) { if (m == NULL) {
if ((m = m_get()) == NULL) if ((m = m_get()) == NULL)
return; return;
#ifdef TCP_COMPAT_42 #ifdef TCP_COMPAT_42
@ -152,7 +147,7 @@ tcp_respond(tp, ti, m, ack, seq, flags)
tlen += sizeof (struct tcpiphdr); tlen += sizeof (struct tcpiphdr);
m->m_len = tlen; m->m_len = tlen;
ti->ti_mbuf = 0; ti->ti_mbuf = NULL;
ti->ti_x1 = 0; ti->ti_x1 = 0;
ti->ti_seq = htonl(seq); ti->ti_seq = htonl(seq);
ti->ti_ack = htonl(ack); ti->ti_ack = htonl(ack);
@ -182,8 +177,7 @@ tcp_respond(tp, ti, m, ack, seq, flags)
* protocol control block. * protocol control block.
*/ */
struct tcpcb * struct tcpcb *
tcp_newtcpcb(so) tcp_newtcpcb(struct socket *so)
struct socket *so;
{ {
register struct tcpcb *tp; register struct tcpcb *tp;
@ -257,8 +251,7 @@ struct tcpcb *tcp_drop(struct tcpcb *tp, int err)
* wake up any sleepers * wake up any sleepers
*/ */
struct tcpcb * struct tcpcb *
tcp_close(tp) tcp_close(struct tcpcb *tp)
register struct tcpcb *tp;
{ {
register struct tcpiphdr *t; register struct tcpiphdr *t;
struct socket *so = tp->t_socket; struct socket *so = tp->t_socket;
@ -281,7 +274,7 @@ tcp_close(tp)
*/ */
/* free(tp, M_PCB); */ /* free(tp, M_PCB); */
free(tp); free(tp);
so->so_tcpcb = 0; so->so_tcpcb = NULL;
soisfdisconnected(so); soisfdisconnected(so);
/* clobber input socket cache if we're closing the cached connection */ /* clobber input socket cache if we're closing the cached connection */
if (so == tcp_last_so) if (so == tcp_last_so)
@ -333,8 +326,7 @@ tcp_quench(i, errno)
* We can let the user exit from the close as soon as the FIN is acked. * We can let the user exit from the close as soon as the FIN is acked.
*/ */
void void
tcp_sockclosed(tp) tcp_sockclosed(struct tcpcb *tp)
struct tcpcb *tp;
{ {
DEBUG_CALL("tcp_sockclosed"); DEBUG_CALL("tcp_sockclosed");
@ -375,8 +367,7 @@ tcp_sockclosed(tp)
* nonblocking. Connect returns after the SYN is sent, and does * nonblocking. Connect returns after the SYN is sent, and does
* not wait for ACK+SYN. * not wait for ACK+SYN.
*/ */
int tcp_fconnect(so) int tcp_fconnect(struct socket *so)
struct socket *so;
{ {
int ret=0; int ret=0;
@ -438,8 +429,7 @@ int tcp_fconnect(so)
* here and SYN the local-host. * here and SYN the local-host.
*/ */
void void
tcp_connect(inso) tcp_connect(struct socket *inso)
struct socket *inso;
{ {
struct socket *so; struct socket *so;
struct sockaddr_in addr; struct sockaddr_in addr;
@ -525,8 +515,7 @@ tcp_connect(inso)
* Attach a TCPCB to a socket. * Attach a TCPCB to a socket.
*/ */
int int
tcp_attach(so) tcp_attach(struct socket *so)
struct socket *so;
{ {
if ((so->so_tcpcb = tcp_newtcpcb(so)) == NULL) if ((so->so_tcpcb = tcp_newtcpcb(so)) == NULL)
return -1; return -1;
@ -558,14 +547,13 @@ static const struct tos_t tcptos[] = {
#ifdef CONFIG_QEMU #ifdef CONFIG_QEMU
static static
#endif #endif
struct emu_t *tcpemu = 0; struct emu_t *tcpemu = NULL;
/* /*
* Return TOS according to the above table * Return TOS according to the above table
*/ */
u_int8_t u_int8_t
tcp_tos(so) tcp_tos(struct socket *so)
struct socket *so;
{ {
int i = 0; int i = 0;
struct emu_t *emup; struct emu_t *emup;
@ -620,9 +608,7 @@ int do_echo = -1;
* NOTE: if you return 0 you MUST m_free() the mbuf! * NOTE: if you return 0 you MUST m_free() the mbuf!
*/ */
int int
tcp_emu(so, m) tcp_emu(struct socket *so, struct mbuf *m)
struct socket *so;
struct mbuf *m;
{ {
u_int n1, n2, n3, n4, n5, n6; u_int n1, n2, n3, n4, n5, n6;
char buff[257]; char buff[257];
@ -976,7 +962,7 @@ do_prompt:
} }
#endif #endif
case EMU_FTP: /* ftp */ case EMU_FTP: /* ftp */
*(m->m_data+m->m_len) = 0; /* NULL terminate for strstr */ *(m->m_data+m->m_len) = 0; /* NUL terminate for strstr */
if ((bptr = (char *)strstr(m->m_data, "ORT")) != NULL) { if ((bptr = (char *)strstr(m->m_data, "ORT")) != NULL) {
/* /*
* Need to emulate the PORT command * Need to emulate the PORT command
@ -1244,8 +1230,7 @@ do_prompt:
* return 2 if this is a command-line connection * return 2 if this is a command-line connection
*/ */
int int
tcp_ctl(so) tcp_ctl(struct socket *so)
struct socket *so;
{ {
struct sbuf *sb = &so->so_snd; struct sbuf *sb = &so->so_snd;
int command; int command;

58
vl.c
View file

@ -21,29 +21,6 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE. * THE SOFTWARE.
*/ */
#include "hw/hw.h"
#include "hw/boards.h"
#include "hw/usb.h"
#include "hw/pcmcia.h"
#include "hw/pc.h"
#include "hw/audiodev.h"
#include "hw/isa.h"
#include "hw/baum.h"
#include "hw/bt.h"
#include "net.h"
#include "monitor.h"
#include "console.h"
#include "sysemu.h"
#include "gdbstub.h"
#include "qemu-timer.h"
#include "qemu-char.h"
#include "cache-utils.h"
#include "block.h"
#include "audio/audio.h"
#include "migration.h"
#include "kvm.h"
#include "balloon.h"
#include <unistd.h> #include <unistd.h>
#include <fcntl.h> #include <fcntl.h>
#include <signal.h> #include <signal.h>
@ -114,12 +91,6 @@
#endif #endif
#endif #endif
#include "qemu_socket.h"
#if defined(CONFIG_SLIRP)
#include "libslirp.h"
#endif
#if defined(__OpenBSD__) #if defined(__OpenBSD__)
#include <util.h> #include <util.h>
#endif #endif
@ -154,10 +125,39 @@ int main(int argc, char **argv)
#define main qemu_main #define main qemu_main
#endif /* CONFIG_COCOA */ #endif /* CONFIG_COCOA */
#include "hw/hw.h"
#include "hw/boards.h"
#include "hw/usb.h"
#include "hw/pcmcia.h"
#include "hw/pc.h"
#include "hw/audiodev.h"
#include "hw/isa.h"
#include "hw/baum.h"
#include "hw/bt.h"
#include "net.h"
#include "monitor.h"
#include "console.h"
#include "sysemu.h"
#include "gdbstub.h"
#include "qemu-timer.h"
#include "qemu-char.h"
#include "cache-utils.h"
#include "block.h"
#include "audio/audio.h"
#include "migration.h"
#include "kvm.h"
#include "balloon.h"
#include "disas.h" #include "disas.h"
#include "exec-all.h" #include "exec-all.h"
#include "qemu_socket.h"
#if defined(CONFIG_SLIRP)
#include "libslirp.h"
#endif
//#define DEBUG_UNUSED_IOPORT //#define DEBUG_UNUSED_IOPORT
//#define DEBUG_IOPORT //#define DEBUG_IOPORT
//#define DEBUG_NET //#define DEBUG_NET