From 660f11be541813be5f09fbaf44d8e7c6d5a5bbfe Mon Sep 17 00:00:00 2001 From: Blue Swirl Date: Fri, 31 Jul 2009 21:16:51 +0000 Subject: [PATCH] Fix Sparse warnings: "Using plain integer as NULL pointer" Signed-off-by: Blue Swirl --- audio/ossaudio.c | 2 +- audio/sdlaudio.c | 2 +- curses.c | 2 +- curses_keys.h | 2 +- elf_ops.h | 2 +- exec.c | 7 ++++--- feature_to_c.sh | 2 +- hw/ide.c | 2 +- hw/ppc_newworld.c | 2 +- hw/ppc_oldworld.c | 2 +- hw/rtl8139.c | 4 ++-- hw/sysbus.c | 2 +- keymaps.c | 4 ++-- monitor.c | 2 +- qemu-io.c | 22 +++++++++++----------- qemu-nbd.c | 32 ++++++++++++++++---------------- sdl.c | 2 +- sdl_keysym.h | 2 +- sparc-dis.c | 14 +++++++------- usb-linux.c | 8 ++++---- 20 files changed, 59 insertions(+), 58 deletions(-) diff --git a/audio/ossaudio.c b/audio/ossaudio.c index 0236c2efaf..bb727d3de6 100644 --- a/audio/ossaudio.c +++ b/audio/ossaudio.c @@ -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, diff --git a/audio/sdlaudio.c b/audio/sdlaudio.c index 5d6fc24116..dafef5dab6 100644 --- a/audio/sdlaudio.c +++ b/audio/sdlaudio.c @@ -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; } diff --git a/curses.c b/curses.c index 8aae818f24..89680e6fba 100644 --- a/curses.c +++ b/curses.c @@ -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) diff --git a/curses_keys.h b/curses_keys.h index 4c6f3db0dc..a6e41cf4e4 100644 --- a/curses_keys.h +++ b/curses_keys.h @@ -479,5 +479,5 @@ static const name2keysym_t name2keysym[] = { { "F20", 0x11c }, { "Escape", 27 }, - { 0, 0 }, + { NULL, 0 }, }; diff --git a/elf_ops.h b/elf_ops.h index 72cd83eb74..699651c9e1 100644 --- a/elf_ops.h +++ b/elf_ops.h @@ -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; } diff --git a/exec.c b/exec.c index a4a7de7570..fa5b619cab 100644 --- a/exec.c +++ b/exec.c @@ -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)); } diff --git a/feature_to_c.sh b/feature_to_c.sh index 53975ebca7..dbf9f19c91 100644 --- a/feature_to_c.sh +++ b/feature_to_c.sh @@ -72,5 +72,5 @@ for input; do echo " { \"$basename\", $arrayname }," >> $output done -echo " { 0, 0 }" >> $output +echo " { (char *)0, (char *)0 }" >> $output echo "};" >> $output diff --git a/hw/ide.c b/hw/ide.c index 2eea43835c..6cf04a6b89 100644 --- a/hw/ide.c +++ b/hw/ide.c @@ -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); diff --git a/hw/ppc_newworld.c b/hw/ppc_newworld.c index 2a350eb8c5..cfeddabbdd 100644 --- a/hw/ppc_newworld.c +++ b/hw/ppc_newworld.c @@ -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, diff --git a/hw/ppc_oldworld.c b/hw/ppc_oldworld.c index 7931f44088..06e014195e 100644 --- a/hw/ppc_oldworld.c +++ b/hw/ppc_oldworld.c @@ -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, diff --git a/hw/rtl8139.c b/hw/rtl8139.c index 91165dbff4..fcd6d956db 100644 --- a/hw/rtl8139.c +++ b/hw/rtl8139.c @@ -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)); diff --git a/hw/sysbus.c b/hw/sysbus.c index 814d347037..269be772b7 100644 --- a/hw/sysbus.c +++ b/hw/sysbus.c @@ -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; } diff --git a/keymaps.c b/keymaps.c index 23db4a0bdc..668556298a 100644 --- a/keymaps.c +++ b/keymaps.c @@ -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); } diff --git a/monitor.c b/monitor.c index 909325423a..aac88781cc 100644 --- a/monitor.c +++ b/monitor.c @@ -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++; diff --git a/qemu-io.c b/qemu-io.c index 029ee0b6e0..a68f195c11 100644 --- a/qemu-io.c +++ b/qemu-io.c @@ -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; diff --git a/qemu-nbd.c b/qemu-nbd.c index 7eed6424b4..6cdb83473f 100644 --- a/qemu-nbd.c +++ b/qemu-nbd.c @@ -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; diff --git a/sdl.c b/sdl.c index 50a4a016d3..238ef085cb 100644 --- a/sdl.c +++ b/sdl.c @@ -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; diff --git a/sdl_keysym.h b/sdl_keysym.h index c213ef873b..ee904805da 100644 --- a/sdl_keysym.h +++ b/sdl_keysym.h @@ -273,5 +273,5 @@ static const name2keysym_t name2keysym[]={ {"Pause", SDLK_PAUSE}, {"Escape", SDLK_ESCAPE}, -{0,0}, +{NULL, 0}, }; diff --git a/sparc-dis.c b/sparc-dis.c index a71404fe6e..53c8c9024d 100644 --- a/sparc-dis.c +++ b/sparc-dis.c @@ -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; diff --git a/usb-linux.c b/usb-linux.c index 3c724baf69..043f6b6ba1 100644 --- a/usb-linux.c +++ b/usb-linux.c @@ -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];