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
diff --git a/hw/bt-hci.c b/hw/bt-hci.c
index 96a5b11..7e93e26 100644
--- a/hw/bt-hci.c
+++ b/hw/bt-hci.c
@@ -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):
diff --git a/hw/bt-hid.c b/hw/bt-hid.c
index 815caaf..3317ecc 100644
--- a/hw/bt-hid.c
+++ b/hw/bt-hid.c
@@ -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);
 }
 
diff --git a/hw/bt-l2cap.c b/hw/bt-l2cap.c
index 0abcac0..b22b761 100644
--- a/hw/bt-l2cap.c
+++ b/hw/bt-l2cap.c
@@ -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;
 }
diff --git a/hw/bt-sdp.c b/hw/bt-sdp.c
index 9dee7c2..992de0e 100644
--- a/hw/bt-sdp.c
+++ b/hw/bt-sdp.c
@@ -948,7 +948,7 @@
         &sdp_service_sdp_s,
         &sdp_service_hid_s,
         &sdp_service_pnp_s,
-        0,
+        NULL,
     };
 
     sdp->channel = params;
diff --git a/hw/ppce500_mpc8544ds.c b/hw/ppce500_mpc8544ds.c
index 8fa0383..3d73f8a 100644
--- a/hw/ppce500_mpc8544ds.c
+++ b/hw/ppce500_mpc8544ds.c
@@ -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,
diff --git a/hw/usb-bt.c b/hw/usb-bt.c
index 55f979e..53ad9a8 100644
--- a/hw/usb-bt.c
+++ b/hw/usb-bt.c
@@ -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);
 }
 
diff --git a/hw/vmware_vga.c b/hw/vmware_vga.c
index d1cba28..5c271e6 100644
--- a/hw/vmware_vga.c
+++ b/hw/vmware_vga.c
@@ -230,7 +230,6 @@
 #ifdef VERBOSE
 # define GUEST_OS_BASE		0x5001
 static 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
diff --git a/hw/wm8750.c b/hw/wm8750.c
index 93fa6d7..e5324ec 100644
--- a/hw/wm8750.c
+++ b/hw/wm8750.c
@@ -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)