Skip to content

Commit

Permalink
Fix warnings that would be caused by gcc flag -Wwrite-strings
Browse files Browse the repository at this point in the history
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@5206 c046a42c-6fe2-441c-8c8c-71466251a162
  • Loading branch information
blueswir1 committed Sep 14, 2008
1 parent 5d0c575 commit 7ccfb2e
Show file tree
Hide file tree
Showing 20 changed files with 72 additions and 70 deletions.
13 changes: 7 additions & 6 deletions block-vmdk.c
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ static uint32_t vmdk_read_cid(BlockDriverState *bs, int parent)
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 */
Expand Down Expand Up @@ -193,7 +193,7 @@ static int vmdk_snapshot_create(const char *filename, const char *backing_file)
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"
Expand All @@ -202,7 +202,7 @@ static int vmdk_snapshot_create(const char *filename, const char *backing_file)
"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"
Expand Down Expand Up @@ -702,7 +702,7 @@ static int vmdk_create(const char *filename, int64_t total_size,
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"
Expand Down Expand Up @@ -791,8 +791,9 @@ static int vmdk_create(const char *filename, int64_t total_size,
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);
Expand Down
2 changes: 1 addition & 1 deletion block.c
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ void get_tmp_filename(char *filename, int size)
void get_tmp_filename(char *filename, int size)
{
int fd;
char *tmpdir;
const char *tmpdir;
/* XXX: race condition possible */
tmpdir = getenv("TMPDIR");
if (!tmpdir)
Expand Down
2 changes: 1 addition & 1 deletion exec.c
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ static int io_mem_watch;
#endif

/* log support */
char *logfilename = "/tmp/qemu.log";
const char *logfilename = "/tmp/qemu.log";
FILE *logfile;
int loglevel;
static int log_append = 0;
Expand Down
4 changes: 2 additions & 2 deletions gdbstub.c
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ static void hextomem(uint8_t *mem, const char *buf, int len)
}

/* 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;
Expand Down Expand Up @@ -1259,7 +1259,7 @@ static void gdb_vm_stopped(void *opaque, int reason)
%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];
Expand Down
2 changes: 1 addition & 1 deletion gdbstub.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion hw/e1000.c
Original file line number Diff line number Diff line change
Expand Up @@ -949,7 +949,7 @@ pci_e1000_init(PCIBus *bus, NICInfo *nd, int devfn)
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",
Expand Down
2 changes: 1 addition & 1 deletion hw/sh.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,6 @@ void sh_serial_init (target_phys_addr_t base, int feat,
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
4 changes: 2 additions & 2 deletions hw/tc58128.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ static tc58128_dev tc58128_devs[2];

#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;

Expand Down Expand Up @@ -175,7 +175,7 @@ static sh7750_io_device tc58128 = {
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);
Expand Down
2 changes: 1 addition & 1 deletion hw/usb-net.c
Original file line number Diff line number Diff line change
Expand Up @@ -1016,7 +1016,7 @@ static void usb_net_handle_reset(USBDevice *dev)
{
}

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",
Expand Down
4 changes: 2 additions & 2 deletions hw/usb-ohci.c
Original file line number Diff line number Diff line change
Expand Up @@ -565,7 +565,7 @@ static int ohci_service_iso_td(OHCIState *ohci, struct ohci_ed *ed,
{
int dir;
size_t len = 0;
char *str = NULL;
const char *str = NULL;
int pid;
int ret;
int i;
Expand Down Expand Up @@ -800,7 +800,7 @@ static int ohci_service_td(OHCIState *ohci, struct ohci_ed *ed)
{
int dir;
size_t len = 0;
char *str = NULL;
const char *str = NULL;
int pid;
int ret;
int i;
Expand Down
6 changes: 3 additions & 3 deletions linux-user/arm/nwfpe/fpopcode.h
Original file line number Diff line number Diff line change
Expand Up @@ -366,19 +366,19 @@ TABLE 5
/* 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];
Expand Down
29 changes: 15 additions & 14 deletions linux-user/strace.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@ int do_strace=0;

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);
};

/*
Expand Down Expand Up @@ -131,7 +131,7 @@ static long newselect_arg4 = 0;
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)
{
Expand All @@ -155,7 +155,7 @@ print_newselect(struct syscallname *name,
#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)
{
Expand All @@ -165,7 +165,7 @@ print_semctl(struct syscallname *name,
}

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)
{
Expand Down Expand Up @@ -198,14 +198,15 @@ print_execve(struct syscallname *name,

#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 ")",
Expand All @@ -219,7 +220,7 @@ print_ipc(struct syscallname *name,
*/

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));
Expand All @@ -238,7 +239,7 @@ print_syscall_ret_raw(struct syscallname *name, abi_long ret)

#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);
Expand All @@ -256,7 +257,7 @@ print_syscall_ret_newselect(struct syscallname *name, abi_long ret)
* An array of all of the syscalls we know about
*/

static struct syscallname scnames[] = {
static const struct syscallname scnames[] = {
#include "strace.list"
};

Expand All @@ -271,7 +272,7 @@ print_syscall(int num,
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() );

Expand Down
16 changes: 8 additions & 8 deletions m68k-dis.c
Original file line number Diff line number Diff line change
Expand Up @@ -546,13 +546,13 @@ extern const int m68k_numopcodes, m68k_numaliases;

/* 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",
Expand All @@ -561,7 +561,7 @@ static char *const reg_names[] =

/* 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",
Expand Down Expand Up @@ -991,7 +991,7 @@ print_indexed (int basereg,
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];
Expand Down Expand Up @@ -1106,7 +1106,7 @@ print_insn_arg (const char *d,
{
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;
Expand Down Expand Up @@ -1157,7 +1157,7 @@ print_insn_arg (const char *d,
/* 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},
Expand Down Expand Up @@ -1201,7 +1201,7 @@ print_insn_arg (const char *d,
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]);
}
Expand Down Expand Up @@ -1633,7 +1633,7 @@ print_insn_arg (const char *d,
case '3':
{
int val = fetch_arg (buffer, place, 5, info);
char *name = 0;
const char *name = 0;

switch (val)
{
Expand Down
16 changes: 8 additions & 8 deletions sh4-dis.c
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,7 @@ SH4AL-dsp SH4A

typedef struct
{
char *name;
const char *name;
sh_arg_type arg[4];
sh_nibble_type nibbles[9];
unsigned int arch;
Expand Down Expand Up @@ -1386,13 +1386,13 @@ print_insn_ppi (field_b, info)
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)
Expand All @@ -1405,10 +1405,10 @@ print_insn_ppi (field_b, info)
}
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)
{
Expand Down
Loading

0 comments on commit 7ccfb2e

Please sign in to comment.