Commit 660f11be541813be5f09fbaf44d8e7c6d5a5bbfe

Authored by Blue Swirl
1 parent 2e29bd04

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

Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
audio/ossaudio.c
... ... @@ -481,7 +481,7 @@ static int oss_init_out (HWVoiceOut *hw, struct audsettings *as)
481 481 oss->mmapped = 0;
482 482 if (conf.try_mmap) {
483 483 oss->pcm_buf = mmap (
484   - 0,
  484 + NULL,
485 485 hw->samples << hw->info.shift,
486 486 PROT_READ | PROT_WRITE,
487 487 MAP_SHARED,
... ...
audio/sdlaudio.c
... ... @@ -201,7 +201,7 @@ static int sdl_open (SDL_AudioSpec *req, SDL_AudioSpec *obt)
201 201 }
202 202  
203 203 #ifndef _WIN32
204   - pthread_sigmask (SIG_SETMASK, &old, 0);
  204 + pthread_sigmask (SIG_SETMASK, &old, NULL);
205 205 #endif
206 206 return status;
207 207 }
... ...
curses.c
... ... @@ -158,7 +158,7 @@ static void curses_cursor_position(DisplayState *ds, int x, int y)
158 158  
159 159 #include "curses_keys.h"
160 160  
161   -static kbd_layout_t *kbd_layout = 0;
  161 +static kbd_layout_t *kbd_layout = NULL;
162 162 static int keycode2keysym[CURSES_KEYS];
163 163  
164 164 static void curses_refresh(DisplayState *ds)
... ...
curses_keys.h
... ... @@ -479,5 +479,5 @@ static const name2keysym_t name2keysym[] = {
479 479 { "F20", 0x11c },
480 480 { "Escape", 27 },
481 481  
482   - { 0, 0 },
  482 + { NULL, 0 },
483 483 };
... ...
elf_ops.h
... ... @@ -82,7 +82,7 @@ static const char *glue(lookup_symbol, SZ)(struct syminfo *s, target_ulong orig_
82 82 key.st_value = orig_addr;
83 83  
84 84 sym = bsearch(&key, syms, s->disas_num_syms, sizeof(*syms), glue(symfind, SZ));
85   - if (sym != 0) {
  85 + if (sym != NULL) {
86 86 return s->disas_strtab + sym->st_name;
87 87 }
88 88  
... ...
... ... @@ -316,7 +316,7 @@ static inline PageDesc *page_find_alloc(target_ulong index)
316 316 #if defined(CONFIG_USER_ONLY)
317 317 size_t len = sizeof(PageDesc) * L2_SIZE;
318 318 /* Don't use qemu_malloc because it may recurse. */
319   - p = mmap(0, len, PROT_READ | PROT_WRITE,
  319 + p = mmap(NULL, len, PROT_READ | PROT_WRITE,
320 320 MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
321 321 *lp = p;
322 322 if (h2g_valid(p)) {
... ... @@ -341,8 +341,9 @@ static inline PageDesc *page_find(target_ulong index)
341 341 return NULL;
342 342  
343 343 p = *lp;
344   - if (!p)
345   - return 0;
  344 + if (!p) {
  345 + return NULL;
  346 + }
346 347 return p + (index & (L2_SIZE - 1));
347 348 }
348 349  
... ...
feature_to_c.sh
... ... @@ -72,5 +72,5 @@ for input; do
72 72 echo " { \"$basename\", $arrayname }," >> $output
73 73 done
74 74  
75   -echo " { 0, 0 }" >> $output
  75 +echo " { (char *)0, (char *)0 }" >> $output
76 76 echo "};" >> $output
... ...
hw/ide.c
... ... @@ -4411,7 +4411,7 @@ PCMCIACardState *dscm1xxxx_init(BlockDriverState *bdrv)
4411 4411 md->card.cis = dscm1xxxx_cis;
4412 4412 md->card.cis_len = sizeof(dscm1xxxx_cis);
4413 4413  
4414   - ide_init2(md->ide, bdrv, 0, qemu_allocate_irqs(md_set_irq, md, 1)[0]);
  4414 + ide_init2(md->ide, bdrv, NULL, qemu_allocate_irqs(md_set_irq, md, 1)[0]);
4415 4415 md->ide->is_cf = 1;
4416 4416 md->ide->mdata_size = METADATA_SIZE;
4417 4417 md->ide->mdata_storage = (uint8_t *) qemu_mallocz(METADATA_SIZE);
... ...
hw/ppc_newworld.c
... ... @@ -195,7 +195,7 @@ static void ppc_core99_init (ram_addr_t ram_size,
195 195 kernel_size = load_elf(kernel_filename, kernel_base, NULL, &lowaddr, NULL);
196 196 if (kernel_size > 0 && lowaddr != KERNEL_LOAD_ADDR) {
197 197 kernel_size = load_elf(kernel_filename, (2 * kernel_base) - lowaddr,
198   - NULL, 0, NULL);
  198 + NULL, NULL, NULL);
199 199 }
200 200 if (kernel_size < 0)
201 201 kernel_size = load_aout(kernel_filename, kernel_base,
... ...
hw/ppc_oldworld.c
... ... @@ -227,7 +227,7 @@ static void ppc_heathrow_init (ram_addr_t ram_size,
227 227 kernel_size = load_elf(kernel_filename, kernel_base, NULL, &lowaddr, NULL);
228 228 if (kernel_size > 0 && lowaddr != KERNEL_LOAD_ADDR) {
229 229 kernel_size = load_elf(kernel_filename, (2 * kernel_base) - lowaddr,
230   - NULL, 0, NULL);
  230 + NULL, NULL, NULL);
231 231 }
232 232 if (kernel_size < 0)
233 233 kernel_size = load_aout(kernel_filename, kernel_base,
... ...
hw/rtl8139.c
... ... @@ -2090,12 +2090,12 @@ static int rtl8139_cplus_transmit_one(RTL8139State *s)
2090 2090 #define ETH_MTU 1500
2091 2091  
2092 2092 /* ip packet header */
2093   - ip_header *ip = 0;
  2093 + ip_header *ip = NULL;
2094 2094 int hlen = 0;
2095 2095 uint8_t ip_protocol = 0;
2096 2096 uint16_t ip_data_len = 0;
2097 2097  
2098   - uint8_t *eth_payload_data = 0;
  2098 + uint8_t *eth_payload_data = NULL;
2099 2099 size_t eth_payload_len = 0;
2100 2100  
2101 2101 int proto = be16_to_cpu(*(uint16_t *)(saved_buffer + 12));
... ...
hw/sysbus.c
... ... @@ -32,7 +32,7 @@ struct BusInfo system_bus_info = {
32 32 void sysbus_connect_irq(SysBusDevice *dev, int n, qemu_irq irq)
33 33 {
34 34 assert(n >= 0 && n < dev->num_irq);
35   - dev->irqs[n] = 0;
  35 + dev->irqs[n] = NULL;
36 36 if (dev->irqp[n]) {
37 37 *dev->irqp[n] = irq;
38 38 }
... ...
keymaps.c
... ... @@ -75,7 +75,7 @@ static kbd_layout_t *parse_keyboard_layout(const name2keysym_t *table,
75 75 if (!(filename && (f = fopen(filename, "r")))) {
76 76 fprintf(stderr,
77 77 "Could not read keymap file: '%s'\n", language);
78   - return 0;
  78 + return NULL;
79 79 }
80 80 qemu_free(filename);
81 81 for(;;) {
... ... @@ -144,7 +144,7 @@ static kbd_layout_t *parse_keyboard_layout(const name2keysym_t *table,
144 144  
145 145 void *init_keyboard_layout(const name2keysym_t *table, const char *language)
146 146 {
147   - return parse_keyboard_layout(table, language, 0);
  147 + return parse_keyboard_layout(table, language, NULL);
148 148 }
149 149  
150 150  
... ...
monitor.c
... ... @@ -2272,7 +2272,7 @@ static int get_monitor_def(target_long *pval, const char *name)
2272 2272  
2273 2273 static void next(void)
2274 2274 {
2275   - if (pch != '\0') {
  2275 + if (*pch != '\0') {
2276 2276 pch++;
2277 2277 while (qemu_isspace(*pch))
2278 2278 pch++;
... ...
qemu-io.c
... ... @@ -1414,17 +1414,17 @@ int main(int argc, char **argv)
1414 1414 int growable = 0;
1415 1415 const char *sopt = "hVc:Crsnmg";
1416 1416 struct option lopt[] = {
1417   - { "help", 0, 0, 'h' },
1418   - { "version", 0, 0, 'V' },
1419   - { "offset", 1, 0, 'o' },
1420   - { "cmd", 1, 0, 'c' },
1421   - { "create", 0, 0, 'C' },
1422   - { "read-only", 0, 0, 'r' },
1423   - { "snapshot", 0, 0, 's' },
1424   - { "nocache", 0, 0, 'n' },
1425   - { "misalign", 0, 0, 'm' },
1426   - { "growable", 0, 0, 'g' },
1427   - { NULL, 0, 0, 0 }
  1417 + { "help", 0, NULL, 'h' },
  1418 + { "version", 0, NULL, 'V' },
  1419 + { "offset", 1, NULL, 'o' },
  1420 + { "cmd", 1, NULL, 'c' },
  1421 + { "create", 0, NULL, 'C' },
  1422 + { "read-only", 0, NULL, 'r' },
  1423 + { "snapshot", 0, NULL, 's' },
  1424 + { "nocache", 0, NULL, 'n' },
  1425 + { "misalign", 0, NULL, 'm' },
  1426 + { "growable", 0, NULL, 'g' },
  1427 + { NULL, 0, NULL, 0 }
1428 1428 };
1429 1429 int c;
1430 1430 int opt_index = 0;
... ...
qemu-nbd.c
... ... @@ -191,22 +191,22 @@ int main(int argc, char **argv)
191 191 char sockpath[128];
192 192 const char *sopt = "hVb:o:p:rsnP:c:dvk:e:t";
193 193 struct option lopt[] = {
194   - { "help", 0, 0, 'h' },
195   - { "version", 0, 0, 'V' },
196   - { "bind", 1, 0, 'b' },
197   - { "port", 1, 0, 'p' },
198   - { "socket", 1, 0, 'k' },
199   - { "offset", 1, 0, 'o' },
200   - { "read-only", 0, 0, 'r' },
201   - { "partition", 1, 0, 'P' },
202   - { "connect", 1, 0, 'c' },
203   - { "disconnect", 0, 0, 'd' },
204   - { "snapshot", 0, 0, 's' },
205   - { "nocache", 0, 0, 'n' },
206   - { "shared", 1, 0, 'e' },
207   - { "persistent", 0, 0, 't' },
208   - { "verbose", 0, 0, 'v' },
209   - { NULL, 0, 0, 0 }
  194 + { "help", 0, NULL, 'h' },
  195 + { "version", 0, NULL, 'V' },
  196 + { "bind", 1, NULL, 'b' },
  197 + { "port", 1, NULL, 'p' },
  198 + { "socket", 1, NULL, 'k' },
  199 + { "offset", 1, NULL, 'o' },
  200 + { "read-only", 0, NULL, 'r' },
  201 + { "partition", 1, NULL, 'P' },
  202 + { "connect", 1, NULL, 'c' },
  203 + { "disconnect", 0, NULL, 'd' },
  204 + { "snapshot", 0, NULL, 's' },
  205 + { "nocache", 0, NULL, 'n' },
  206 + { "shared", 1, NULL, 'e' },
  207 + { "persistent", 0, NULL, 't' },
  208 + { "verbose", 0, NULL, 'v' },
  209 + { NULL, 0, NULL, 0 }
210 210 };
211 211 int ch;
212 212 int opt_ind = 0;
... ...
... ... @@ -53,7 +53,7 @@ static SDL_Cursor *sdl_cursor_hidden;
53 53 static int absolute_enabled = 0;
54 54 static int guest_cursor = 0;
55 55 static int guest_x, guest_y;
56   -static SDL_Cursor *guest_sprite = 0;
  56 +static SDL_Cursor *guest_sprite = NULL;
57 57 static uint8_t allocator;
58 58 static SDL_PixelFormat host_format;
59 59 static int scaling_active = 0;
... ...
sdl_keysym.h
... ... @@ -273,5 +273,5 @@ static const name2keysym_t name2keysym[]={
273 273 {"Pause", SDLK_PAUSE},
274 274 {"Escape", SDLK_ESCAPE},
275 275  
276   -{0,0},
  276 +{NULL, 0},
277 277 };
... ...
sparc-dis.c
... ... @@ -2115,7 +2115,7 @@ static const arg asi_table_v8[] =
2115 2115 { 0x40, "#ASI_M_VIKING_TMP1" },
2116 2116 { 0x41, "#ASI_M_VIKING_TMP2" },
2117 2117 { 0x4c, "#ASI_M_ACTION" },
2118   - { 0, 0 }
  2118 + { 0, NULL }
2119 2119 };
2120 2120  
2121 2121 static const arg asi_table_v9[] =
... ... @@ -2155,7 +2155,7 @@ static const arg asi_table_v9[] =
2155 2155 /* These are UltraSPARC extensions. */
2156 2156 /* FIXME: There are dozens of them. Not sure we want them all.
2157 2157 Most are for kernel building but some are for vis type stuff. */
2158   - { 0, 0 }
  2158 + { 0, NULL }
2159 2159 };
2160 2160  
2161 2161 /* Return the name for ASI value VALUE or NULL if not found. */
... ... @@ -2183,7 +2183,7 @@ static const arg membar_table[] =
2183 2183 { 0x04, "#LoadStore" },
2184 2184 { 0x02, "#StoreLoad" },
2185 2185 { 0x01, "#LoadLoad" },
2186   - { 0, 0 }
  2186 + { 0, NULL }
2187 2187 };
2188 2188  
2189 2189 /* Return the name for membar value VALUE or NULL if not found. */
... ... @@ -2204,7 +2204,7 @@ static const arg prefetch_table[] =
2204 2204 { 3, "#one_write" },
2205 2205 { 4, "#page" },
2206 2206 { 16, "#invalidate" },
2207   - { 0, 0 }
  2207 + { 0, NULL }
2208 2208 };
2209 2209  
2210 2210 /* Return the name for prefetch value VALUE or NULL if not found. */
... ... @@ -2226,7 +2226,7 @@ static const arg sparclet_cpreg_table[] =
2226 2226 { 4, "%ccsr2" },
2227 2227 { 5, "%cccrr" },
2228 2228 { 6, "%ccrstr" },
2229   - { 0, 0 }
  2229 + { 0, NULL }
2230 2230 };
2231 2231  
2232 2232 /* 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)
2770 2770 imm_added_to_rs1 = 1;
2771 2771  
2772 2772 if (X_RS1 (insn) != X_RD (insn)
2773   - && strchr (opcode->args, 'r') != 0)
  2773 + && strchr (opcode->args, 'r') != NULL)
2774 2774 /* Can't do simple format if source and dest are different. */
2775 2775 continue;
2776 2776 if (X_RS2 (insn) != X_RD (insn)
2777   - && strchr (opcode->args, 'O') != 0)
  2777 + && strchr (opcode->args, 'O') != NULL)
2778 2778 /* Can't do simple format if source and dest are different. */
2779 2779 continue;
2780 2780  
... ...
usb-linux.c
... ... @@ -1057,7 +1057,7 @@ static int get_tag_value(char *buf, int buf_size,
1057 1057 */
1058 1058 static int usb_host_scan_dev(void *opaque, USBScanFunc *func)
1059 1059 {
1060   - FILE *f = 0;
  1060 + FILE *f = NULL;
1061 1061 char line[1024];
1062 1062 char buf[1024];
1063 1063 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
1178 1178 */
1179 1179 static int usb_host_scan_sys(void *opaque, USBScanFunc *func)
1180 1180 {
1181   - DIR *dir = 0;
  1181 + DIR *dir = NULL;
1182 1182 char line[1024];
1183 1183 int bus_num, addr, speed, class_id, product_id, vendor_id;
1184 1184 int ret = 0;
... ... @@ -1257,8 +1257,8 @@ static int usb_host_scan_sys(void *opaque, USBScanFunc *func)
1257 1257 static int usb_host_scan(void *opaque, USBScanFunc *func)
1258 1258 {
1259 1259 Monitor *mon = cur_mon;
1260   - FILE *f = 0;
1261   - DIR *dir = 0;
  1260 + FILE *f = NULL;
  1261 + DIR *dir = NULL;
1262 1262 int ret = 0;
1263 1263 const char *fs_type[] = {"unknown", "proc", "dev", "sys"};
1264 1264 char devpath[PATH_MAX];
... ...