提交 660f11be 编写于 作者: B Blue Swirl

Fix Sparse warnings: "Using plain integer as NULL pointer"

Signed-off-by: NBlue Swirl <blauwirbel@gmail.com>
上级 2e29bd04
......@@ -481,7 +481,7 @@ static int oss_init_out (HWVoiceOut *hw, struct audsettings *as)
oss->mmapped = 0;
if (conf.try_mmap) {
oss->pcm_buf = mmap (
0,
NULL,
hw->samples << hw->info.shift,
PROT_READ | PROT_WRITE,
MAP_SHARED,
......
......@@ -201,7 +201,7 @@ static int sdl_open (SDL_AudioSpec *req, SDL_AudioSpec *obt)
}
#ifndef _WIN32
pthread_sigmask (SIG_SETMASK, &old, 0);
pthread_sigmask (SIG_SETMASK, &old, NULL);
#endif
return status;
}
......
......@@ -158,7 +158,7 @@ static void curses_cursor_position(DisplayState *ds, int x, int y)
#include "curses_keys.h"
static kbd_layout_t *kbd_layout = 0;
static kbd_layout_t *kbd_layout = NULL;
static int keycode2keysym[CURSES_KEYS];
static void curses_refresh(DisplayState *ds)
......
......@@ -479,5 +479,5 @@ static const name2keysym_t name2keysym[] = {
{ "F20", 0x11c },
{ "Escape", 27 },
{ 0, 0 },
{ NULL, 0 },
};
......@@ -82,7 +82,7 @@ static const char *glue(lookup_symbol, SZ)(struct syminfo *s, target_ulong orig_
key.st_value = orig_addr;
sym = bsearch(&key, syms, s->disas_num_syms, sizeof(*syms), glue(symfind, SZ));
if (sym != 0) {
if (sym != NULL) {
return s->disas_strtab + sym->st_name;
}
......
......@@ -316,7 +316,7 @@ static inline PageDesc *page_find_alloc(target_ulong index)
#if defined(CONFIG_USER_ONLY)
size_t len = sizeof(PageDesc) * L2_SIZE;
/* Don't use qemu_malloc because it may recurse. */
p = mmap(0, len, PROT_READ | PROT_WRITE,
p = mmap(NULL, len, PROT_READ | PROT_WRITE,
MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
*lp = p;
if (h2g_valid(p)) {
......@@ -341,8 +341,9 @@ static inline PageDesc *page_find(target_ulong index)
return NULL;
p = *lp;
if (!p)
return 0;
if (!p) {
return NULL;
}
return p + (index & (L2_SIZE - 1));
}
......
......@@ -72,5 +72,5 @@ for input; do
echo " { \"$basename\", $arrayname }," >> $output
done
echo " { 0, 0 }" >> $output
echo " { (char *)0, (char *)0 }" >> $output
echo "};" >> $output
......@@ -4411,7 +4411,7 @@ PCMCIACardState *dscm1xxxx_init(BlockDriverState *bdrv)
md->card.cis = dscm1xxxx_cis;
md->card.cis_len = sizeof(dscm1xxxx_cis);
ide_init2(md->ide, bdrv, 0, qemu_allocate_irqs(md_set_irq, md, 1)[0]);
ide_init2(md->ide, bdrv, NULL, qemu_allocate_irqs(md_set_irq, md, 1)[0]);
md->ide->is_cf = 1;
md->ide->mdata_size = METADATA_SIZE;
md->ide->mdata_storage = (uint8_t *) qemu_mallocz(METADATA_SIZE);
......
......@@ -195,7 +195,7 @@ static void ppc_core99_init (ram_addr_t ram_size,
kernel_size = load_elf(kernel_filename, kernel_base, NULL, &lowaddr, NULL);
if (kernel_size > 0 && lowaddr != KERNEL_LOAD_ADDR) {
kernel_size = load_elf(kernel_filename, (2 * kernel_base) - lowaddr,
NULL, 0, NULL);
NULL, NULL, NULL);
}
if (kernel_size < 0)
kernel_size = load_aout(kernel_filename, kernel_base,
......
......@@ -227,7 +227,7 @@ static void ppc_heathrow_init (ram_addr_t ram_size,
kernel_size = load_elf(kernel_filename, kernel_base, NULL, &lowaddr, NULL);
if (kernel_size > 0 && lowaddr != KERNEL_LOAD_ADDR) {
kernel_size = load_elf(kernel_filename, (2 * kernel_base) - lowaddr,
NULL, 0, NULL);
NULL, NULL, NULL);
}
if (kernel_size < 0)
kernel_size = load_aout(kernel_filename, kernel_base,
......
......@@ -2090,12 +2090,12 @@ static int rtl8139_cplus_transmit_one(RTL8139State *s)
#define ETH_MTU 1500
/* ip packet header */
ip_header *ip = 0;
ip_header *ip = NULL;
int hlen = 0;
uint8_t ip_protocol = 0;
uint16_t ip_data_len = 0;
uint8_t *eth_payload_data = 0;
uint8_t *eth_payload_data = NULL;
size_t eth_payload_len = 0;
int proto = be16_to_cpu(*(uint16_t *)(saved_buffer + 12));
......
......@@ -32,7 +32,7 @@ struct BusInfo system_bus_info = {
void sysbus_connect_irq(SysBusDevice *dev, int n, qemu_irq irq)
{
assert(n >= 0 && n < dev->num_irq);
dev->irqs[n] = 0;
dev->irqs[n] = NULL;
if (dev->irqp[n]) {
*dev->irqp[n] = irq;
}
......
......@@ -75,7 +75,7 @@ static kbd_layout_t *parse_keyboard_layout(const name2keysym_t *table,
if (!(filename && (f = fopen(filename, "r")))) {
fprintf(stderr,
"Could not read keymap file: '%s'\n", language);
return 0;
return NULL;
}
qemu_free(filename);
for(;;) {
......@@ -144,7 +144,7 @@ static kbd_layout_t *parse_keyboard_layout(const name2keysym_t *table,
void *init_keyboard_layout(const name2keysym_t *table, const char *language)
{
return parse_keyboard_layout(table, language, 0);
return parse_keyboard_layout(table, language, NULL);
}
......
......@@ -2272,7 +2272,7 @@ static int get_monitor_def(target_long *pval, const char *name)
static void next(void)
{
if (pch != '\0') {
if (*pch != '\0') {
pch++;
while (qemu_isspace(*pch))
pch++;
......
......@@ -1414,17 +1414,17 @@ int main(int argc, char **argv)
int growable = 0;
const char *sopt = "hVc:Crsnmg";
struct option lopt[] = {
{ "help", 0, 0, 'h' },
{ "version", 0, 0, 'V' },
{ "offset", 1, 0, 'o' },
{ "cmd", 1, 0, 'c' },
{ "create", 0, 0, 'C' },
{ "read-only", 0, 0, 'r' },
{ "snapshot", 0, 0, 's' },
{ "nocache", 0, 0, 'n' },
{ "misalign", 0, 0, 'm' },
{ "growable", 0, 0, 'g' },
{ NULL, 0, 0, 0 }
{ "help", 0, NULL, 'h' },
{ "version", 0, NULL, 'V' },
{ "offset", 1, NULL, 'o' },
{ "cmd", 1, NULL, 'c' },
{ "create", 0, NULL, 'C' },
{ "read-only", 0, NULL, 'r' },
{ "snapshot", 0, NULL, 's' },
{ "nocache", 0, NULL, 'n' },
{ "misalign", 0, NULL, 'm' },
{ "growable", 0, NULL, 'g' },
{ NULL, 0, NULL, 0 }
};
int c;
int opt_index = 0;
......
......@@ -191,22 +191,22 @@ int main(int argc, char **argv)
char sockpath[128];
const char *sopt = "hVb:o:p:rsnP:c:dvk:e:t";
struct option lopt[] = {
{ "help", 0, 0, 'h' },
{ "version", 0, 0, 'V' },
{ "bind", 1, 0, 'b' },
{ "port", 1, 0, 'p' },
{ "socket", 1, 0, 'k' },
{ "offset", 1, 0, 'o' },
{ "read-only", 0, 0, 'r' },
{ "partition", 1, 0, 'P' },
{ "connect", 1, 0, 'c' },
{ "disconnect", 0, 0, 'd' },
{ "snapshot", 0, 0, 's' },
{ "nocache", 0, 0, 'n' },
{ "shared", 1, 0, 'e' },
{ "persistent", 0, 0, 't' },
{ "verbose", 0, 0, 'v' },
{ NULL, 0, 0, 0 }
{ "help", 0, NULL, 'h' },
{ "version", 0, NULL, 'V' },
{ "bind", 1, NULL, 'b' },
{ "port", 1, NULL, 'p' },
{ "socket", 1, NULL, 'k' },
{ "offset", 1, NULL, 'o' },
{ "read-only", 0, NULL, 'r' },
{ "partition", 1, NULL, 'P' },
{ "connect", 1, NULL, 'c' },
{ "disconnect", 0, NULL, 'd' },
{ "snapshot", 0, NULL, 's' },
{ "nocache", 0, NULL, 'n' },
{ "shared", 1, NULL, 'e' },
{ "persistent", 0, NULL, 't' },
{ "verbose", 0, NULL, 'v' },
{ NULL, 0, NULL, 0 }
};
int ch;
int opt_ind = 0;
......
......@@ -53,7 +53,7 @@ static SDL_Cursor *sdl_cursor_hidden;
static int absolute_enabled = 0;
static int guest_cursor = 0;
static int guest_x, guest_y;
static SDL_Cursor *guest_sprite = 0;
static SDL_Cursor *guest_sprite = NULL;
static uint8_t allocator;
static SDL_PixelFormat host_format;
static int scaling_active = 0;
......
......@@ -273,5 +273,5 @@ static const name2keysym_t name2keysym[]={
{"Pause", SDLK_PAUSE},
{"Escape", SDLK_ESCAPE},
{0,0},
{NULL, 0},
};
......@@ -2115,7 +2115,7 @@ static const arg asi_table_v8[] =
{ 0x40, "#ASI_M_VIKING_TMP1" },
{ 0x41, "#ASI_M_VIKING_TMP2" },
{ 0x4c, "#ASI_M_ACTION" },
{ 0, 0 }
{ 0, NULL }
};
static const arg asi_table_v9[] =
......@@ -2155,7 +2155,7 @@ static const arg asi_table_v9[] =
/* These are UltraSPARC extensions. */
/* FIXME: There are dozens of them. Not sure we want them all.
Most are for kernel building but some are for vis type stuff. */
{ 0, 0 }
{ 0, NULL }
};
/* Return the name for ASI value VALUE or NULL if not found. */
......@@ -2183,7 +2183,7 @@ static const arg membar_table[] =
{ 0x04, "#LoadStore" },
{ 0x02, "#StoreLoad" },
{ 0x01, "#LoadLoad" },
{ 0, 0 }
{ 0, NULL }
};
/* Return the name for membar value VALUE or NULL if not found. */
......@@ -2204,7 +2204,7 @@ static const arg prefetch_table[] =
{ 3, "#one_write" },
{ 4, "#page" },
{ 16, "#invalidate" },
{ 0, 0 }
{ 0, NULL }
};
/* Return the name for prefetch value VALUE or NULL if not found. */
......@@ -2226,7 +2226,7 @@ static const arg sparclet_cpreg_table[] =
{ 4, "%ccsr2" },
{ 5, "%cccrr" },
{ 6, "%ccrstr" },
{ 0, 0 }
{ 0, NULL }
};
/* Return the name for sparclet cpreg value VALUE or NULL if not found. */
......@@ -2770,11 +2770,11 @@ print_insn_sparc (bfd_vma memaddr, disassemble_info *info)
imm_added_to_rs1 = 1;
if (X_RS1 (insn) != X_RD (insn)
&& strchr (opcode->args, 'r') != 0)
&& strchr (opcode->args, 'r') != NULL)
/* Can't do simple format if source and dest are different. */
continue;
if (X_RS2 (insn) != X_RD (insn)
&& strchr (opcode->args, 'O') != 0)
&& strchr (opcode->args, 'O') != NULL)
/* Can't do simple format if source and dest are different. */
continue;
......
......@@ -1057,7 +1057,7 @@ static int get_tag_value(char *buf, int buf_size,
*/
static int usb_host_scan_dev(void *opaque, USBScanFunc *func)
{
FILE *f = 0;
FILE *f = NULL;
char line[1024];
char buf[1024];
int bus_num, addr, speed, device_count, class_id, product_id, vendor_id;
......@@ -1178,7 +1178,7 @@ static int usb_host_read_file(char *line, size_t line_size, const char *device_f
*/
static int usb_host_scan_sys(void *opaque, USBScanFunc *func)
{
DIR *dir = 0;
DIR *dir = NULL;
char line[1024];
int bus_num, addr, speed, class_id, product_id, vendor_id;
int ret = 0;
......@@ -1257,8 +1257,8 @@ static int usb_host_scan_sys(void *opaque, USBScanFunc *func)
static int usb_host_scan(void *opaque, USBScanFunc *func)
{
Monitor *mon = cur_mon;
FILE *f = 0;
DIR *dir = 0;
FILE *f = NULL;
DIR *dir = NULL;
int ret = 0;
const char *fs_type[] = {"unknown", "proc", "dev", "sys"};
char devpath[PATH_MAX];
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册