aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CODING_STYLE3
-rw-r--r--cpu-exec.c10
-rw-r--r--hw/fmopl.c4
-rw-r--r--hw/ide/pci.c2
-rw-r--r--hw/ide/piix.c4
-rw-r--r--hw/virtio.c3
-rw-r--r--linux-user/syscall.c25
-rw-r--r--net/socket.c8
-rw-r--r--vl.c10
9 files changed, 40 insertions, 29 deletions
diff --git a/CODING_STYLE b/CODING_STYLE
index 6e61c49089..7c82d4d0af 100644
--- a/CODING_STYLE
+++ b/CODING_STYLE
@@ -44,7 +44,8 @@ Rationale:
3. Naming
Variables are lower_case_with_underscores; easy to type and read. Structured
-type names are in CamelCase; harder to type but standing out. Scalar type
+type names are in CamelCase; harder to type but standing out. Enum type
+names and function type names should also be in CamelCase. Scalar type
names are lower_case_with_underscores_ending_with_a_t, like the POSIX
uint64_t and family. Note that this last convention contradicts POSIX
and is therefore likely to be changed.
diff --git a/cpu-exec.c b/cpu-exec.c
index a9fa608cff..2c2d24ea04 100644
--- a/cpu-exec.c
+++ b/cpu-exec.c
@@ -1,5 +1,5 @@
/*
- * i386 emulator main execution loop
+ * emulator main execution loop
*
* Copyright (c) 2003-2005 Fabrice Bellard
*
@@ -304,7 +304,7 @@ int cpu_exec(CPUState *env)
env->hflags2 |= HF2_NMI_MASK;
do_interrupt_x86_hardirq(env, EXCP02_NMI, 1);
next_tb = 0;
- } else if (interrupt_request & CPU_INTERRUPT_MCE) {
+ } else if (interrupt_request & CPU_INTERRUPT_MCE) {
env->interrupt_request &= ~CPU_INTERRUPT_MCE;
do_interrupt_x86_hardirq(env, EXCP12_MCHK, 0);
next_tb = 0;
@@ -390,7 +390,7 @@ int cpu_exec(CPUState *env)
next_tb = 0;
}
}
- }
+ }
#elif defined(TARGET_ARM)
if (interrupt_request & CPU_INTERRUPT_FIQ
&& !(env->uncached_cpsr & CPSR_F)) {
@@ -429,7 +429,7 @@ int cpu_exec(CPUState *env)
{
int idx = -1;
/* ??? This hard-codes the OSF/1 interrupt levels. */
- switch (env->pal_mode ? 7 : env->ps & PS_INT_MASK) {
+ switch (env->pal_mode ? 7 : env->ps & PS_INT_MASK) {
case 0 ... 3:
if (interrupt_request & CPU_INTERRUPT_HARD) {
idx = EXCP_DEV_INTERRUPT;
@@ -562,7 +562,7 @@ int cpu_exec(CPUState *env)
barrier();
if (likely(!env->exit_request)) {
tc_ptr = tb->tc_ptr;
- /* execute the generated code */
+ /* execute the generated code */
next_tb = tcg_qemu_tb_exec(env, tc_ptr);
if ((next_tb & 3) == 2) {
/* Instruction counter expired. */
diff --git a/hw/fmopl.c b/hw/fmopl.c
index 734d2f4aae..f0a023477d 100644
--- a/hw/fmopl.c
+++ b/hw/fmopl.c
@@ -733,7 +733,7 @@ INLINE void CSMKeyControll(OPL_CH *CH)
}
/* ---------- opl initialize ---------- */
-static void OPL_initalize(FM_OPL *OPL)
+static void OPL_initialize(FM_OPL *OPL)
{
int fn;
@@ -1239,7 +1239,7 @@ FM_OPL *OPLCreate(int type, int clock, int rate)
OPL->rate = rate;
OPL->max_ch = max_ch;
/* init grobal tables */
- OPL_initalize(OPL);
+ OPL_initialize(OPL);
/* reset chip */
OPLResetChip(OPL);
#ifdef OPL_OUTPUT_LOG
diff --git a/hw/ide/pci.c b/hw/ide/pci.c
index 246dd5704b..88c0942e34 100644
--- a/hw/ide/pci.c
+++ b/hw/ide/pci.c
@@ -336,7 +336,7 @@ static uint64_t bmdma_addr_read(void *opaque, target_phys_addr_t addr,
data = (bm->addr >> (addr * 8)) & mask;
#ifdef DEBUG_IDE
- printf("%s: 0x%08x\n", __func__, (unsigned)*data);
+ printf("%s: 0x%08x\n", __func__, (unsigned)data);
#endif
return data;
}
diff --git a/hw/ide/piix.c b/hw/ide/piix.c
index aee60aa390..1030fcc31c 100644
--- a/hw/ide/piix.c
+++ b/hw/ide/piix.c
@@ -53,7 +53,7 @@ static uint64_t bmdma_read(void *opaque, target_phys_addr_t addr, unsigned size)
break;
}
#ifdef DEBUG_IDE
- printf("bmdma: readb 0x%02x : 0x%02x\n", addr, val);
+ printf("bmdma: readb 0x%02x : 0x%02x\n", (uint8_t)addr, val);
#endif
return val;
}
@@ -68,7 +68,7 @@ static void bmdma_write(void *opaque, target_phys_addr_t addr,
}
#ifdef DEBUG_IDE
- printf("bmdma: writeb 0x%02x : 0x%02x\n", addr, val);
+ printf("bmdma: writeb 0x%02x : 0x%02x\n", (uint8_t)addr, (uint8_t)val);
#endif
switch(addr & 3) {
case 0:
diff --git a/hw/virtio.c b/hw/virtio.c
index 74cc038af9..064aecf553 100644
--- a/hw/virtio.c
+++ b/hw/virtio.c
@@ -845,8 +845,7 @@ int virtio_load(VirtIODevice *vdev, QEMUFile *f)
void virtio_cleanup(VirtIODevice *vdev)
{
qemu_del_vm_change_state_handler(vdev->vmstate);
- if (vdev->config)
- g_free(vdev->config);
+ g_free(vdev->config);
g_free(vdev->vq);
g_free(vdev);
}
diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index ee8899ef3d..8a11213402 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -756,14 +756,15 @@ abi_long do_brk(abi_ulong new_brk)
abi_long mapped_addr;
int new_alloc_size;
- DEBUGF_BRK("do_brk(%#010x) -> ", new_brk);
+ DEBUGF_BRK("do_brk(" TARGET_ABI_FMT_lx ") -> ", new_brk);
if (!new_brk) {
- DEBUGF_BRK("%#010x (!new_brk)\n", target_brk);
+ DEBUGF_BRK(TARGET_ABI_FMT_lx " (!new_brk)\n", target_brk);
return target_brk;
}
if (new_brk < target_original_brk) {
- DEBUGF_BRK("%#010x (new_brk < target_original_brk)\n", target_brk);
+ DEBUGF_BRK(TARGET_ABI_FMT_lx " (new_brk < target_original_brk)\n",
+ target_brk);
return target_brk;
}
@@ -776,7 +777,7 @@ abi_long do_brk(abi_ulong new_brk)
memset(g2h(target_brk), 0, new_brk - target_brk);
}
target_brk = new_brk;
- DEBUGF_BRK("%#010x (new_brk <= brk_page)\n", target_brk);
+ DEBUGF_BRK(TARGET_ABI_FMT_lx " (new_brk <= brk_page)\n", target_brk);
return target_brk;
}
@@ -803,7 +804,8 @@ abi_long do_brk(abi_ulong new_brk)
target_brk = new_brk;
brk_page = HOST_PAGE_ALIGN(target_brk);
- DEBUGF_BRK("%#010x (mapped_addr == brk_page)\n", target_brk);
+ DEBUGF_BRK(TARGET_ABI_FMT_lx " (mapped_addr == brk_page)\n",
+ target_brk);
return target_brk;
} else if (mapped_addr != -1) {
/* Mapped but at wrong address, meaning there wasn't actually
@@ -811,10 +813,10 @@ abi_long do_brk(abi_ulong new_brk)
*/
target_munmap(mapped_addr, new_alloc_size);
mapped_addr = -1;
- DEBUGF_BRK("%#010x (mapped_addr != -1)\n", target_brk);
+ DEBUGF_BRK(TARGET_ABI_FMT_lx " (mapped_addr != -1)\n", target_brk);
}
else {
- DEBUGF_BRK("%#010x (otherwise)\n", target_brk);
+ DEBUGF_BRK(TARGET_ABI_FMT_lx " (otherwise)\n", target_brk);
}
#if defined(TARGET_ALPHA)
@@ -4949,6 +4951,7 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1,
abi_ulong guest_envp;
abi_ulong addr;
char **q;
+ int total_size = 0;
argc = 0;
guest_argp = arg2;
@@ -4980,6 +4983,7 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1,
break;
if (!(*q = lock_user_string(addr)))
goto execve_efault;
+ total_size += strlen(*q) + 1;
}
*q = NULL;
@@ -4991,9 +4995,16 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1,
break;
if (!(*q = lock_user_string(addr)))
goto execve_efault;
+ total_size += strlen(*q) + 1;
}
*q = NULL;
+ /* This case will not be caught by the host's execve() if its
+ page size is bigger than the target's. */
+ if (total_size > MAX_ARG_PAGES * TARGET_PAGE_SIZE) {
+ ret = -TARGET_E2BIG;
+ goto execve_end;
+ }
if (!(p = lock_user_string(arg1)))
goto execve_efault;
ret = get_errno(execve(p, argp, envp));
diff --git a/net/socket.c b/net/socket.c
index d4c2002923..0bcf229c24 100644
--- a/net/socket.c
+++ b/net/socket.c
@@ -664,8 +664,8 @@ int net_init_socket(QemuOpts *opts,
qemu_opt_get(opts, "connect") ||
qemu_opt_get(opts, "listen") ||
qemu_opt_get(opts, "mcast")) {
- error_report("fd=, connect=, listen=\
- and mcast= is invalid with udp=");
+ error_report("fd=, connect=, listen="
+ " and mcast= is invalid with udp=");
return -1;
}
@@ -680,8 +680,8 @@ int net_init_socket(QemuOpts *opts,
return -1;
}
} else {
- error_report("-socket requires fd=, listen=, \
- connect=, mcast= or udp=");
+ error_report("-socket requires fd=, listen=,"
+ " connect=, mcast= or udp=");
return -1;
}
return 0;
diff --git a/vl.c b/vl.c
index 37f2f96928..9609d2bee8 100644
--- a/vl.c
+++ b/vl.c
@@ -2030,7 +2030,7 @@ static int configure_accelerator(void)
const char *p = NULL;
char buf[10];
int i, ret;
- bool accel_initalised = 0;
+ bool accel_initialised = 0;
bool init_failed = 0;
QemuOptsList *list = qemu_find_opts("machine");
@@ -2043,7 +2043,7 @@ static int configure_accelerator(void)
p = "tcg";
}
- while (!accel_initalised && *p != '\0') {
+ while (!accel_initialised && *p != '\0') {
if (*p == ':') {
p++;
}
@@ -2064,7 +2064,7 @@ static int configure_accelerator(void)
}
*(accel_list[i].allowed) = 0;
} else {
- accel_initalised = 1;
+ accel_initialised = 1;
}
break;
}
@@ -2074,7 +2074,7 @@ static int configure_accelerator(void)
}
}
- if (!accel_initalised) {
+ if (!accel_initialised) {
fprintf(stderr, "No accelerator found!\n");
exit(1);
}
@@ -2083,7 +2083,7 @@ static int configure_accelerator(void)
fprintf(stderr, "Back to %s accelerator.\n", accel_list[i].name);
}
- return !accel_initalised;
+ return !accel_initialised;
}
void qemu_add_exit_notifier(Notifier *notify)