qemu-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-commits] [COMMIT 660f11b] Fix Sparse warnings: "Using plain integ


From: Anthony Liguori
Subject: [Qemu-commits] [COMMIT 660f11b] Fix Sparse warnings: "Using plain integer as NULLpointer"
Date: Mon, 10 Aug 2009 21:48:03 -0000

From: Blue Swirl <address@hidden>

Signed-off-by: Blue Swirl <address@hidden>

diff --git a/audio/ossaudio.c b/audio/ossaudio.c
index 0236c2e..bb727d3 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 5d6fc24..dafef5d 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 8aae818..89680e6 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 4c6f3db..a6e41cf 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 72cd83e..699651c 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 a4a7de7..fa5b619 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 53975eb..dbf9f19 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 2eea438..6cf04a6 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 2a350eb..cfeddab 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 7931f44..06e0141 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 91165db..fcd6d95 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 814d347..269be77 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 23db4a0..6685562 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 9093254..aac8878 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 029ee0b..a68f195 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 7eed642..6cdb834 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 50a4a01..238ef08 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 c213ef8..ee90480 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 a71404f..53c8c90 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 3c724ba..043f6b6 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];




reply via email to

[Prev in Thread] Current Thread [Next in Thread]