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
+1 -1
View File
@@ -85,7 +85,7 @@ static int dmg_open(BlockDriverState *bs, const char *filename, int flags)
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) {
+5 -5
View File
@@ -134,7 +134,7 @@ static uint32_t vmdk_read_cid(BlockDriverState *bs, int parent)
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 @@ static int vmdk_write_cid(BlockDriverState *bs, uint32_t cid)
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 @@ static int vmdk_snapshot_create(const char *filename, const char *backing_file)
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 @@ static int vmdk_parent_open(BlockDriverState *bs, const char * filename)
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;
+7 -7
View File
@@ -78,7 +78,7 @@ typedef struct array_t {
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 @@ static inline void* array_insert(array_t* array,unsigned int index,unsigned int
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 @@ static inline direntry_t* create_short_and_long_name(BDRVVVFATState* s,
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 @@ static int read_directory(BDRVVVFATState* s, int mapping_index)
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 @@ 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);
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;
}
+2 -2
View File
@@ -171,7 +171,7 @@ struct HCIInfo *bt_host_hci(const char *id)
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 @@ struct HCIInfo *bt_host_hci(const char *id)
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;
}
+1 -1
View File
@@ -165,5 +165,5 @@ void bt_vhci_init(struct HCIInfo *info)
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);
}
+2 -2
View File
@@ -1327,7 +1327,7 @@ static void text_console_do_init(CharDriverState *chr, DisplayState *ds, const c
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 @@ static void text_console_do_init(CharDriverState *chr, DisplayState *ds, const c
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++;
+4 -5
View File
@@ -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
+1 -1
View File
@@ -179,7 +179,7 @@ static void io_mem_init(void);
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
+5 -5
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 = 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_establish(struct bt_hci_s *hci,
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 @@ static void bt_hci_reset(struct bt_hci_s *hci)
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 @@ static void bt_submit_hci(struct HCIInfo *info,
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 @@ static void bt_submit_hci(struct HCIInfo *info,
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):
+5 -4
View File
@@ -324,7 +324,8 @@ static void bt_hid_control_transaction(struct bt_hid_device_s *s,
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 @@ static void bt_hid_control_transaction(struct bt_hid_device_s *s,
/* 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 @@ static void bt_hid_close_control(void *opaque)
{
struct bt_hid_device_s *hid = opaque;
hid->control = 0;
hid->control = NULL;
bt_hid_connected_update(hid);
}
@@ -470,7 +471,7 @@ static void bt_hid_close_interrupt(void *opaque)
{
struct bt_hid_device_s *hid = opaque;
hid->interrupt = 0;
hid->interrupt = NULL;
bt_hid_connected_update(hid);
}
+4 -4
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,
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 struct l2cap_chan_s *l2cap_channel_open(struct l2cap_instance_s *l2cap,
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 @@ static void l2cap_channel_close(struct l2cap_instance_s *l2cap,
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_close(struct l2cap_instance_s *l2cap,
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;
}
+1 -1
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_hid_s,
&sdp_service_pnp_s,
0,
NULL,
};
sdp->channel = params;
+2
View File
@@ -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 @@ static int mpc8544_copy_soc_cell(void *fdt, const char *node, const char *prop)
out:
return ret;
}
#endif
static void *mpc8544_load_device_tree(void *addr,
uint32_t ramsize,
+3 -3
View File
@@ -612,9 +612,9 @@ static void usb_bt_handle_destroy(USBDevice *dev)
{
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);
}
+10 -1
View File
@@ -230,7 +230,6 @@ enum {
#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 @@ static const char *vmsvga_guest_id[] = {
[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
+2 -2
View File
@@ -184,12 +184,12 @@ static void wm8750_set_format(struct wm8750_s *s)
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)
+1 -1
View File
@@ -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"
+16 -16
View File
@@ -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 @@ static void erase_dir(char *dir_name)
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 @@ void do_info_slirp(Monitor *mon)
struct VMChannel {
CharDriverState *hd;
int port;
} *vmchannels;
};
static int vmchannel_can_read(void *opaque)
{
+2 -3
View File
@@ -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)
+12 -12
View File
@@ -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;

Some files were not shown because too many files have changed in this diff Show More