Fix warnings that would be caused by gcc flag -Wwrite-strings

git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@5206 c046a42c-6fe2-441c-8c8c-71466251a162
diff --git a/block-vmdk.c b/block-vmdk.c
index e85bd42..8d67c2f 100644
--- a/block-vmdk.c
+++ b/block-vmdk.c
@@ -119,7 +119,7 @@
     BDRVVmdkState *s = bs->opaque;
     char desc[DESC_SIZE];
     uint32_t cid;
-    char *p_name, *cid_str;
+    const char *p_name, *cid_str;
     size_t cid_str_size;
 
     /* the descriptor offset = 0x200 */
@@ -193,7 +193,7 @@
     uint32_t gde_entries, gd_size;
     int64_t gd_offset, rgd_offset, capacity, gt_size;
     char p_desc[DESC_SIZE], s_desc[DESC_SIZE], hdr[HEADER_SIZE];
-    char *desc_template =
+    static const char desc_template[] =
     "# Disk DescriptorFile\n"
     "version=1\n"
     "CID=%x\n"
@@ -202,7 +202,7 @@
     "parentFileNameHint=\"%s\"\n"
     "\n"
     "# Extent description\n"
-    "RW %lu SPARSE \"%s\"\n"
+    "RW %u SPARSE \"%s\"\n"
     "\n"
     "# The Disk Data Base \n"
     "#DDB\n"
@@ -702,7 +702,7 @@
     int fd, i;
     VMDK4Header header;
     uint32_t tmp, magic, grains, gd_size, gt_size, gt_count;
-    char *desc_template =
+    static const char desc_template[] =
         "# Disk DescriptorFile\n"
         "version=1\n"
         "CID=%x\n"
@@ -791,8 +791,9 @@
         real_filename = temp_str + 1;
     if ((temp_str = strrchr(real_filename, ':')) != NULL)
         real_filename = temp_str + 1;
-    snprintf(desc, sizeof(desc), desc_template, time(NULL), (unsigned long)total_size,
-             real_filename, (flags & BLOCK_FLAG_COMPAT6 ? 6 : 4), total_size / (63 * 16));
+    snprintf(desc, sizeof(desc), desc_template, (unsigned int)time(NULL),
+             (unsigned long)total_size, real_filename,
+             (flags & BLOCK_FLAG_COMPAT6 ? 6 : 4), total_size / (63 * 16));
 
     /* write the descriptor */
     lseek(fd, le64_to_cpu(header.desc_offset) << 9, SEEK_SET);
diff --git a/block.c b/block.c
index 52c8f37..08fa299 100644
--- a/block.c
+++ b/block.c
@@ -190,7 +190,7 @@
 void get_tmp_filename(char *filename, int size)
 {
     int fd;
-    char *tmpdir;
+    const char *tmpdir;
     /* XXX: race condition possible */
     tmpdir = getenv("TMPDIR");
     if (!tmpdir)
diff --git a/exec.c b/exec.c
index 5e30689..18f46cd 100644
--- a/exec.c
+++ b/exec.c
@@ -180,7 +180,7 @@
 #endif
 
 /* log support */
-char *logfilename = "/tmp/qemu.log";
+const char *logfilename = "/tmp/qemu.log";
 FILE *logfile;
 int loglevel;
 static int log_append = 0;
diff --git a/gdbstub.c b/gdbstub.c
index 98dd889..117caf9 100644
--- a/gdbstub.c
+++ b/gdbstub.c
@@ -205,7 +205,7 @@
 }
 
 /* return -1 if error, 0 if OK */
-static int put_packet(GDBState *s, char *buf)
+static int put_packet(GDBState *s, const char *buf)
 {
     int len, csum, i;
     uint8_t *p;
@@ -1259,7 +1259,7 @@
     %x  - target_ulong argument printed in hex.
     %lx - 64-bit argument printed in hex.
     %s  - string pointer (target_ulong) and length (int) pair.  */
-void gdb_do_syscall(gdb_syscall_complete_cb cb, char *fmt, ...)
+void gdb_do_syscall(gdb_syscall_complete_cb cb, const char *fmt, ...)
 {
     va_list va;
     char buf[256];
diff --git a/gdbstub.h b/gdbstub.h
index e1c9efb..ba65f93 100644
--- a/gdbstub.h
+++ b/gdbstub.h
@@ -6,7 +6,7 @@
 typedef void (*gdb_syscall_complete_cb)(CPUState *env,
                                         target_ulong ret, target_ulong err);
 
-void gdb_do_syscall(gdb_syscall_complete_cb cb, char *fmt, ...);
+void gdb_do_syscall(gdb_syscall_complete_cb cb, const char *fmt, ...);
 int use_gdb_syscalls(void);
 #ifdef CONFIG_USER_ONLY
 int gdb_handlesig (CPUState *, int);
diff --git a/hw/e1000.c b/hw/e1000.c
index d52f1f0..a8dcd1a 100644
--- a/hw/e1000.c
+++ b/hw/e1000.c
@@ -949,7 +949,7 @@
     E1000State *d;
     uint8_t *pci_conf;
     uint16_t checksum = 0;
-    char *info_str = "e1000";
+    static const char info_str[] = "e1000";
     int i;
 
     d = (E1000State *)pci_register_device(bus, "e1000",
diff --git a/hw/sh.h b/hw/sh.h
index 808ea50..50a1ae9 100644
--- a/hw/sh.h
+++ b/hw/sh.h
@@ -43,6 +43,6 @@
 		     struct intc_source *bri_source);
 
 /* tc58128.c */
-int tc58128_init(struct SH7750State *s, char *zone1, char *zone2);
+int tc58128_init(struct SH7750State *s, const char *zone1, const char *zone2);
 
 #endif
diff --git a/hw/tc58128.c b/hw/tc58128.c
index 2cd176b..37f5419 100644
--- a/hw/tc58128.c
+++ b/hw/tc58128.c
@@ -26,7 +26,7 @@
 
 #define FLASH_SIZE (16*1024*1024)
 
-void init_dev(tc58128_dev * dev, char *filename)
+static void init_dev(tc58128_dev * dev, const char *filename)
 {
     int ret, blocks;
 
@@ -175,7 +175,7 @@
     tc58128_cb			/* Callback */
 };
 
-int tc58128_init(struct SH7750State *s, char *zone1, char *zone2)
+int tc58128_init(struct SH7750State *s, const char *zone1, const char *zone2)
 {
     init_dev(&tc58128_devs[0], zone1);
     init_dev(&tc58128_devs[1], zone2);
diff --git a/hw/usb-net.c b/hw/usb-net.c
index 63edfd5..a4714c5 100644
--- a/hw/usb-net.c
+++ b/hw/usb-net.c
@@ -1016,7 +1016,7 @@
 {
 }
 
-static char *usb_net_stringtable[] = {
+static const char * const usb_net_stringtable[] = {
     [STRING_MANUFACTURER]	= "QEMU",
     [STRING_PRODUCT]		= "RNDIS/QEMU USB Network Device",
     [STRING_ETHADDR]		= "400102030405",
diff --git a/hw/usb-ohci.c b/hw/usb-ohci.c
index afd5506..55cb77b 100644
--- a/hw/usb-ohci.c
+++ b/hw/usb-ohci.c
@@ -565,7 +565,7 @@
 {
     int dir;
     size_t len = 0;
-    char *str = NULL;
+    const char *str = NULL;
     int pid;
     int ret;
     int i;
@@ -800,7 +800,7 @@
 {
     int dir;
     size_t len = 0;
-    char *str = NULL;
+    const char *str = NULL;
     int pid;
     int ret;
     int i;
diff --git a/linux-user/arm/nwfpe/fpopcode.h b/linux-user/arm/nwfpe/fpopcode.h
index 6c51067..0b501dc 100644
--- a/linux-user/arm/nwfpe/fpopcode.h
+++ b/linux-user/arm/nwfpe/fpopcode.h
@@ -366,19 +366,19 @@
 /* Get the rounding mode from the opcode. */
 #define getRoundingMode(opcode)		((opcode & MASK_ROUNDING_MODE) >> 5)
 
-static inline const floatx80 getExtendedConstant(const unsigned int nIndex)
+static inline floatx80 getExtendedConstant(const unsigned int nIndex)
 {
    extern const floatx80 floatx80Constant[];
    return floatx80Constant[nIndex];
 }
 
-static inline const float64 getDoubleConstant(const unsigned int nIndex)
+static inline float64 getDoubleConstant(const unsigned int nIndex)
 {
    extern const float64 float64Constant[];
    return float64Constant[nIndex];
 }
 
-static inline const float32 getSingleConstant(const unsigned int nIndex)
+static inline float32 getSingleConstant(const unsigned int nIndex)
 {
    extern const float32 float32Constant[];
    return float32Constant[nIndex];
diff --git a/linux-user/strace.c b/linux-user/strace.c
index 76aa3f6..cc0f4d1 100644
--- a/linux-user/strace.c
+++ b/linux-user/strace.c
@@ -13,12 +13,12 @@
 
 struct syscallname {
     int nr;
-    char *name;
-    char *format;
-    void (*call)(struct syscallname *,
+    const char *name;
+    const char *format;
+    void (*call)(const struct syscallname *,
                  abi_long, abi_long, abi_long,
                  abi_long, abi_long, abi_long);
-    void (*result)(struct syscallname *, abi_long);
+    void (*result)(const struct syscallname *, abi_long);
 };
 
 /*
@@ -131,7 +131,7 @@
 static long newselect_arg5 = 0;
 
 static void
-print_newselect(struct syscallname *name,
+print_newselect(const struct syscallname *name,
                 abi_long arg1, abi_long arg2, abi_long arg3,
                 abi_long arg4, abi_long arg5, abi_long arg6)
 {
@@ -155,7 +155,7 @@
 #endif
 
 static void
-print_semctl(struct syscallname *name,
+print_semctl(const struct syscallname *name,
              abi_long arg1, abi_long arg2, abi_long arg3,
              abi_long arg4, abi_long arg5, abi_long arg6)
 {
@@ -165,7 +165,7 @@
 }
 
 static void
-print_execve(struct syscallname *name,
+print_execve(const struct syscallname *name,
              abi_long arg1, abi_long arg2, abi_long arg3,
              abi_long arg4, abi_long arg5, abi_long arg6)
 {
@@ -198,14 +198,15 @@
 
 #ifdef TARGET_NR_ipc
 static void
-print_ipc(struct syscallname *name,
+print_ipc(const struct syscallname *name,
           abi_long arg1, abi_long arg2, abi_long arg3,
           abi_long arg4, abi_long arg5, abi_long arg6)
 {
     switch(arg1) {
     case IPCOP_semctl:
-        name->name = "semctl";
-        print_semctl(name,arg2,arg3,arg4,arg5,arg6,0);
+        gemu_log("semctl(" TARGET_ABI_FMT_ld "," TARGET_ABI_FMT_ld ",", arg1, arg2);
+        print_ipc_cmd(arg3);
+        gemu_log(",0x" TARGET_ABI_FMT_lx ")", arg4);
         break;
     default:
         gemu_log("%s(" TARGET_ABI_FMT_ld "," TARGET_ABI_FMT_ld "," TARGET_ABI_FMT_ld "," TARGET_ABI_FMT_ld ")",
@@ -219,7 +220,7 @@
  */
 
 static void
-print_syscall_ret_addr(struct syscallname *name, abi_long ret)
+print_syscall_ret_addr(const struct syscallname *name, abi_long ret)
 {
 if( ret == -1 ) {
         gemu_log(" = -1 errno=%d (%s)\n", errno, target_strerror(errno));
@@ -238,7 +239,7 @@
 
 #ifdef TARGET_NR__newselect
 static void
-print_syscall_ret_newselect(struct syscallname *name, abi_long ret)
+print_syscall_ret_newselect(const struct syscallname *name, abi_long ret)
 {
     gemu_log(" = 0x" TARGET_ABI_FMT_lx " (", ret);
     print_fdset(newselect_arg1,newselect_arg2);
@@ -256,7 +257,7 @@
  * An array of all of the syscalls we know about
  */
 
-static struct syscallname scnames[] = {
+static const struct syscallname scnames[] = {
 #include "strace.list"
 };
 
@@ -271,7 +272,7 @@
               abi_long arg4, abi_long arg5, abi_long arg6)
 {
     int i;
-    char *format="%s(" TARGET_ABI_FMT_ld "," TARGET_ABI_FMT_ld "," TARGET_ABI_FMT_ld "," TARGET_ABI_FMT_ld "," TARGET_ABI_FMT_ld "," TARGET_ABI_FMT_ld ")";
+    const char *format="%s(" TARGET_ABI_FMT_ld "," TARGET_ABI_FMT_ld "," TARGET_ABI_FMT_ld "," TARGET_ABI_FMT_ld "," TARGET_ABI_FMT_ld "," TARGET_ABI_FMT_ld ")";
 
     gemu_log("%d ", getpid() );
 
diff --git a/m68k-dis.c b/m68k-dis.c
index 10b8d5b..5a4ece5 100644
--- a/m68k-dis.c
+++ b/m68k-dis.c
@@ -546,13 +546,13 @@
 
 /* Local function prototypes.  */
 
-const char * const fpcr_names[] =
+static const char * const fpcr_names[] =
 {
   "", "%fpiar", "%fpsr", "%fpiar/%fpsr", "%fpcr",
   "%fpiar/%fpcr", "%fpsr/%fpcr", "%fpiar/%fpsr/%fpcr"
 };
 
-static char *const reg_names[] =
+static const char *const reg_names[] =
 {
   "%d0", "%d1", "%d2", "%d3", "%d4", "%d5", "%d6", "%d7",
   "%a0", "%a1", "%a2", "%a3", "%a4", "%a5", "%fp", "%sp",
@@ -561,7 +561,7 @@
 
 /* Name of register halves for MAC/EMAC.
    Separate from reg_names since 'spu', 'fpl' look weird.  */
-static char *const reg_half_names[] =
+static const char *const reg_half_names[] =
 {
   "%d0", "%d1", "%d2", "%d3", "%d4", "%d5", "%d6", "%d7",
   "%a0", "%a1", "%a2", "%a3", "%a4", "%a5", "%a6", "%a7",
@@ -991,7 +991,7 @@
 	       disassemble_info *info)
 {
   int word;
-  static char *const scales[] = { "", ":2", ":4", ":8" };
+  static const char *const scales[] = { "", ":2", ":4", ":8" };
   bfd_vma base_disp;
   bfd_vma outer_disp;
   char buf[40];
@@ -1106,7 +1106,7 @@
     {
     case 'c':		/* Cache identifier.  */
       {
-        static char *const cacheFieldName[] = { "nc", "dc", "ic", "bc" };
+        static const char *const cacheFieldName[] = { "nc", "dc", "ic", "bc" };
         val = fetch_arg (buffer, place, 2, info);
         (*info->fprintf_func) (info->stream, cacheFieldName[val]);
         break;
@@ -1157,7 +1157,7 @@
 	/* FIXME: There's a problem here, different m68k processors call the
 	   same address different names. This table can't get it right
 	   because it doesn't know which processor it's disassembling for.  */
-	static const struct { char *name; int value; } names[]
+	static const struct { const char *name; int value; } names[]
 	  = {{"%sfc", 0x000}, {"%dfc", 0x001}, {"%cacr", 0x002},
 	     {"%tc",  0x003}, {"%itt0",0x004}, {"%itt1", 0x005},
              {"%dtt0",0x006}, {"%dtt1",0x007}, {"%buscr",0x008},
@@ -1201,7 +1201,7 @@
     case 'M':
       if (place == 'h')
 	{
-	  static char *const scalefactor_name[] = { "<<", ">>" };
+	  static const char *const scalefactor_name[] = { "<<", ">>" };
 	  val = fetch_arg (buffer, place, 1, info);
 	  (*info->fprintf_func) (info->stream, scalefactor_name[val]);
 	}
@@ -1633,7 +1633,7 @@
     case '3':
       {
 	int val = fetch_arg (buffer, place, 5, info);
-	char *name = 0;
+        const char *name = 0;
 
 	switch (val)
 	  {
diff --git a/sh4-dis.c b/sh4-dis.c
index a1d56c5..82bb75d 100644
--- a/sh4-dis.c
+++ b/sh4-dis.c
@@ -325,7 +325,7 @@
 
 typedef struct
 {
-  char *name;
+  const char *name;
   sh_arg_type arg[4];
   sh_nibble_type nibbles[9];
   unsigned int arch;
@@ -1386,13 +1386,13 @@
      int field_b;
      struct disassemble_info *info;
 {
-  static char *sx_tab[] = { "x0", "x1", "a0", "a1" };
-  static char *sy_tab[] = { "y0", "y1", "m0", "m1" };
+  static const char *sx_tab[] = { "x0", "x1", "a0", "a1" };
+  static const char *sy_tab[] = { "y0", "y1", "m0", "m1" };
   fprintf_ftype fprintf_fn = info->fprintf_func;
   void *stream = info->stream;
   unsigned int nib1, nib2, nib3;
   unsigned int altnib1, nib4;
-  char *dc = NULL;
+  const char *dc = NULL;
   const sh_opcode_info *op;
 
   if ((field_b & 0xe800) == 0)
@@ -1405,10 +1405,10 @@
     }
   if ((field_b & 0xc000) == 0x4000 && (field_b & 0x3000) != 0x1000)
     {
-      static char *du_tab[] = { "x0", "y0", "a0", "a1" };
-      static char *se_tab[] = { "x0", "x1", "y0", "a1" };
-      static char *sf_tab[] = { "y0", "y1", "x0", "a1" };
-      static char *sg_tab[] = { "m0", "m1", "a0", "a1" };
+      static const char *du_tab[] = { "x0", "y0", "a0", "a1" };
+      static const char *se_tab[] = { "x0", "x1", "y0", "a1" };
+      static const char *sf_tab[] = { "y0", "y1", "x0", "a1" };
+      static const char *sg_tab[] = { "m0", "m1", "a0", "a1" };
 
       if (field_b & 0x2000)
 	{
diff --git a/slirp/ip_icmp.c b/slirp/ip_icmp.c
index 53566c1..2514f9f 100644
--- a/slirp/ip_icmp.c
+++ b/slirp/ip_icmp.c
@@ -207,12 +207,8 @@
 
 #define ICMP_MAXDATALEN (IP_MSS-28)
 void
-icmp_error(msrc, type, code, minsize, message)
-     struct mbuf *msrc;
-     u_char type;
-     u_char code;
-     int minsize;
-     char *message;
+icmp_error(struct mbuf *msrc, u_char type, u_char code, int minsize,
+           const char *message)
 {
   unsigned hlen, shlen, s_ip_len;
   register struct ip *ip;
diff --git a/slirp/ip_icmp.h b/slirp/ip_icmp.h
index 8c9b5a1..5cd9f7f 100644
--- a/slirp/ip_icmp.h
+++ b/slirp/ip_icmp.h
@@ -158,7 +158,8 @@
 	(type) == ICMP_MASKREQ || (type) == ICMP_MASKREPLY)
 
 void icmp_input _P((struct mbuf *, int));
-void icmp_error _P((struct mbuf *, u_char, u_char, int, char *));
+void icmp_error(struct mbuf *msrc, u_char type, u_char code, int minsize,
+                const char *message);
 void icmp_reflect _P((struct mbuf *));
 
 #endif
diff --git a/slirp/misc.c b/slirp/misc.c
index 032a1f7..3d921df 100644
--- a/slirp/misc.c
+++ b/slirp/misc.c
@@ -307,7 +307,7 @@
 	socklen_t addrlen = sizeof(addr);
 	int opt;
         int master = -1;
-	char *argv[256];
+	const char *argv[256];
 #if 0
 	char buff[256];
 #endif
@@ -411,7 +411,7 @@
 		   } while (c);
 
 		argv[i] = 0;
-		execvp(argv[0], argv);
+		execvp(argv[0], (char **)argv);
 
 		/* Ooops, failed, let's tell the user why */
 		  {
diff --git a/target-alpha/helper.c b/target-alpha/helper.c
index fd39f5f..7384ba2 100644
--- a/target-alpha/helper.c
+++ b/target-alpha/helper.c
@@ -411,7 +411,7 @@
                      int (*cpu_fprintf)(FILE *f, const char *fmt, ...),
                      int flags)
 {
-    static unsigned char *linux_reg_names[] = {
+    static const unsigned char *linux_reg_names[] = {
         "v0 ", "t0 ", "t1 ", "t2 ", "t3 ", "t4 ", "t5 ", "t6 ",
         "t7 ", "s0 ", "s1 ", "s2 ", "s3 ", "s4 ", "s5 ", "fp ",
         "a0 ", "a1 ", "a2 ", "a3 ", "a4 ", "a5 ", "t8 ", "t9 ",
diff --git a/target-cris/translate.c b/target-cris/translate.c
index 7666cba..4680dd7 100644
--- a/target-cris/translate.c
+++ b/target-cris/translate.c
@@ -123,7 +123,7 @@
 	int singlestep_enabled;
 } DisasContext;
 
-static void gen_BUG(DisasContext *dc, char *file, int line)
+static void gen_BUG(DisasContext *dc, const char *file, int line)
 {
 	printf ("BUG: pc=%x %s %d\n", dc->pc, file, line);
 	fprintf (logfile, "BUG: pc=%x %s %d\n", dc->pc, file, line);
diff --git a/vl.c b/vl.c
index 0619f1c..dd4ffcc 100644
--- a/vl.c
+++ b/vl.c
@@ -1898,7 +1898,7 @@
     return ret;
 }
 
-static char *mux_help[] = {
+static const char * const mux_help[] = {
     "% h    print this help\n\r",
     "% x    exit emulator\n\r",
     "% s    save disk data back to file (if -snapshot)\n\r",
@@ -1948,7 +1948,7 @@
             break;
         case 'x':
             {
-                 char *term =  "QEMU: Terminated\n\r";
+                 const char *term =  "QEMU: Terminated\n\r";
                  chr->chr_write(chr,(uint8_t *)term,strlen(term));
                  exit(0);
                  break;
@@ -3957,6 +3957,7 @@
     char *str = strdup(input_str);
     char *host_str = str;
     char *src_str;
+    const char *src_str2;
     char *ptr;
 
     /*
@@ -3975,10 +3976,11 @@
     if (parse_host_port(haddr, host_str) < 0)
         goto fail;
 
+    src_str2 = src_str;
     if (!src_str || *src_str == '\0')
-        src_str = ":0";
+        src_str2 = ":0";
 
-    if (parse_host_port(saddr, src_str) < 0)
+    if (parse_host_port(saddr, src_str2) < 0)
         goto fail;
 
     free(str);
@@ -5164,7 +5166,7 @@
 }
 
 static int check_params(char *buf, int buf_size,
-                        char **params, const char *str)
+                        const char * const *params, const char *str)
 {
     const char *p;
     int i;
@@ -5451,9 +5453,10 @@
     int cache;
     int bdrv_flags;
     char *str = arg->opt;
-    char *params[] = { "bus", "unit", "if", "index", "cyls", "heads",
-                       "secs", "trans", "media", "snapshot", "file",
-                       "cache", "format", NULL };
+    static const char * const params[] = { "bus", "unit", "if", "index",
+                                           "cyls", "heads", "secs", "trans",
+                                           "media", "snapshot", "file",
+                                           "cache", "format", NULL };
 
     if (check_params(buf, sizeof(buf), params, str) < 0) {
          fprintf(stderr, "qemu: unknown parameter '%s' in '%s'\n",