From 91288a58a550be4dc80628456d5e1d2e91424827 Mon Sep 17 00:00:00 2001 From: "Daniel P. Berrange" Date: Thu, 4 Jun 2015 14:30:07 +0100 Subject: [PATCH 01/19] Add .dir-locals.el file to configure emacs coding style Some default emacs setups indent by 2 spaces and uses tabs which is counter to the QEMU coding style rules. Adding a .dir-locals.el file in the top level of the GIT repo will inform emacs about the QEMU coding style, and so assist contributors in avoiding common style mistakes before they submit patches. Signed-off-by: Daniel P. Berrange Reviewed-by: Markus Armbruster Signed-off-by: Michael Tokarev --- .dir-locals.el | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 .dir-locals.el diff --git a/.dir-locals.el b/.dir-locals.el new file mode 100644 index 0000000000..3ac0cfc6f0 --- /dev/null +++ b/.dir-locals.el @@ -0,0 +1,2 @@ +((c-mode . ((c-file-style . "stroustrup") + (indent-tabs-mode . nil)))) From be9c5ddeabb73e9dee2d6922c03ffee4e1f4c8ec Mon Sep 17 00:00:00 2001 From: Sai Pavan Boddu Date: Mon, 7 Sep 2015 23:36:40 +0530 Subject: [PATCH 02/19] sdhci: use PRIx64 for uint64_t type Fix compile time warnings, because of type mismatch for unsigned long long type. Signed-off-by: Sai Pavan Boddu Reviewed-by: Peter Crosthwaite Signed-off-by: Michael Tokarev --- hw/sd/sdhci.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/hw/sd/sdhci.c b/hw/sd/sdhci.c index 65304cff5e..436448c4fc 100644 --- a/hw/sd/sdhci.c +++ b/hw/sd/sdhci.c @@ -22,6 +22,7 @@ * with this program; if not, see . */ +#include #include "hw/hw.h" #include "sysemu/block-backend.h" #include "sysemu/blockdev.h" @@ -719,7 +720,8 @@ static void sdhci_do_adma(SDHCIState *s) break; case SDHC_ADMA_ATTR_ACT_LINK: /* link to next descriptor table */ s->admasysaddr = dscr.addr; - DPRINT_L1("ADMA link: admasysaddr=0x%lx\n", s->admasysaddr); + DPRINT_L1("ADMA link: admasysaddr=0x%" PRIx64 "\n", + s->admasysaddr); break; default: s->admasysaddr += dscr.incr; @@ -727,7 +729,8 @@ static void sdhci_do_adma(SDHCIState *s) } if (dscr.attr & SDHC_ADMA_ATTR_INT) { - DPRINT_L1("ADMA interrupt: admasysaddr=0x%lx\n", s->admasysaddr); + DPRINT_L1("ADMA interrupt: admasysaddr=0x%" PRIx64 "\n", + s->admasysaddr); if (s->norintstsen & SDHC_NISEN_DMA) { s->norintsts |= SDHC_NIS_DMA; } From 7af0fc994e85c0ff16eda6d7e328427b02a01008 Mon Sep 17 00:00:00 2001 From: Sai Pavan Boddu Date: Mon, 7 Sep 2015 23:36:41 +0530 Subject: [PATCH 03/19] sdhci: Change debug prints to compile unconditionally Conditional compilation hides few type mismatch warnings, fix it to compile unconditionally. Signed-off-by: Sai Pavan Boddu Suggested-by: Eric Blake Reviewed-by: Peter Crosthwaite Signed-off-by: Michael Tokarev --- hw/sd/sdhci.c | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/hw/sd/sdhci.c b/hw/sd/sdhci.c index 436448c4fc..8b0f9f0df5 100644 --- a/hw/sd/sdhci.c +++ b/hw/sd/sdhci.c @@ -37,24 +37,24 @@ #define SDHC_DEBUG 0 #endif -#if SDHC_DEBUG == 0 - #define DPRINT_L1(fmt, args...) do { } while (0) - #define DPRINT_L2(fmt, args...) do { } while (0) - #define ERRPRINT(fmt, args...) do { } while (0) -#elif SDHC_DEBUG == 1 - #define DPRINT_L1(fmt, args...) \ - do {fprintf(stderr, "QEMU SDHC: "fmt, ## args); } while (0) - #define DPRINT_L2(fmt, args...) do { } while (0) - #define ERRPRINT(fmt, args...) \ - do {fprintf(stderr, "QEMU SDHC ERROR: "fmt, ## args); } while (0) -#else - #define DPRINT_L1(fmt, args...) \ - do {fprintf(stderr, "QEMU SDHC: "fmt, ## args); } while (0) - #define DPRINT_L2(fmt, args...) \ - do {fprintf(stderr, "QEMU SDHC: "fmt, ## args); } while (0) - #define ERRPRINT(fmt, args...) \ - do {fprintf(stderr, "QEMU SDHC ERROR: "fmt, ## args); } while (0) -#endif +#define DPRINT_L1(fmt, args...) \ + do { \ + if (SDHC_DEBUG) { \ + fprintf(stderr, "QEMU SDHC: " fmt, ## args); \ + } \ + } while (0) +#define DPRINT_L2(fmt, args...) \ + do { \ + if (SDHC_DEBUG > 1) { \ + fprintf(stderr, "QEMU SDHC: " fmt, ## args); \ + } \ + } while (0) +#define ERRPRINT(fmt, args...) \ + do { \ + if (SDHC_DEBUG) { \ + fprintf(stderr, "QEMU SDHC ERROR: " fmt, ## args); \ + } \ + } while (0) /* Default SD/MMC host controller features information, which will be * presented in CAPABILITIES register of generic SD host controller at reset. From dc1442204a2235b1ad0c4bdceb3580c97f71f1b5 Mon Sep 17 00:00:00 2001 From: Guenter Roeck Date: Thu, 20 Aug 2015 08:52:35 -0700 Subject: [PATCH 04/19] imx_serial: Generate interrupt on tx empty if enabled Generate an interrupt if the tx buffer is empty and the tx empty interrupt is enabled. This fixes a problem seen when running a Linux image since Linux commit 55c3cb1358e ("serial: imx: remove unneeded imx_transmit_buffer() from imx_start_tx()"). Linux now waits for the tx empty interrupt before starting to send data, causing transmit stalls until there is an interrupt for another reason. Signed-off-by: Guenter Roeck Reviewed-by: Peter Crosthwaite Signed-off-by: Michael Tokarev --- hw/char/imx_serial.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/hw/char/imx_serial.c b/hw/char/imx_serial.c index e8f32c46c2..f0c4c722d6 100644 --- a/hw/char/imx_serial.c +++ b/hw/char/imx_serial.c @@ -66,7 +66,9 @@ static void imx_update(IMXSerialState *s) uint32_t flags; flags = (s->usr1 & s->ucr1) & (USR1_TRDY|USR1_RRDY); - if (!(s->ucr1 & UCR1_TXMPTYEN)) { + if (s->ucr1 & UCR1_TXMPTYEN) { + flags |= (s->uts1 & UTS1_TXEMPTY); + } else { flags &= ~USR1_TRDY; } From eab2ac9d3c1675a58989000c2647aa33e440906a Mon Sep 17 00:00:00 2001 From: Paolo Bonzini Date: Mon, 14 Sep 2015 13:12:34 +0200 Subject: [PATCH 05/19] block/ssh: remove dead code The "err" label cannot be reached with qp != NULL. Remove the free-ing of qp and avoid future regressions by removing the initializer. Signed-off-by: Paolo Bonzini ACKed-by: Richard W.M. Jones Reviewed-by: Fam Zheng Signed-off-by: Michael Tokarev --- block/ssh.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/block/ssh.c b/block/ssh.c index 8d0673903d..d35b51f987 100644 --- a/block/ssh.c +++ b/block/ssh.c @@ -193,7 +193,7 @@ sftp_error_report(BDRVSSHState *s, const char *fs, ...) static int parse_uri(const char *filename, QDict *options, Error **errp) { URI *uri = NULL; - QueryParams *qp = NULL; + QueryParams *qp; int i; uri = uri_parse(filename); @@ -249,9 +249,6 @@ static int parse_uri(const char *filename, QDict *options, Error **errp) return 0; err: - if (qp) { - query_params_free(qp); - } if (uri) { uri_free(uri); } From 16033ba577059c5675e4c786234c46027380c29b Mon Sep 17 00:00:00 2001 From: Paolo Bonzini Date: Tue, 15 Sep 2015 10:47:36 +0200 Subject: [PATCH 06/19] pci-assign: do not include sys/io.h This file does not exist on bionic libc and the functions it defines are in fact not used by pci-assign.c. Remove it. Reported-by: Houcheng Lin Signed-off-by: Paolo Bonzini Signed-off-by: Michael Tokarev --- hw/i386/kvm/pci-assign.c | 1 - 1 file changed, 1 deletion(-) diff --git a/hw/i386/kvm/pci-assign.c b/hw/i386/kvm/pci-assign.c index b1beaa66b2..44beee3a05 100644 --- a/hw/i386/kvm/pci-assign.c +++ b/hw/i386/kvm/pci-assign.c @@ -22,7 +22,6 @@ */ #include #include -#include #include #include #include From ec5fd402645fd4f03d89dcd5840b0e8542549e82 Mon Sep 17 00:00:00 2001 From: Paolo Bonzini Date: Mon, 14 Sep 2015 12:07:22 +0200 Subject: [PATCH 07/19] pc: check for underflow in load_linux If (setup_size+1)*512 is small enough, kernel_size -= setup_size can allocate a huge amount of memory. Avoid that. Signed-off-by: Paolo Bonzini Signed-off-by: Michael Tokarev --- hw/i386/pc.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/hw/i386/pc.c b/hw/i386/pc.c index 9275297adc..682867a8a9 100644 --- a/hw/i386/pc.c +++ b/hw/i386/pc.c @@ -985,6 +985,10 @@ static void load_linux(PCMachineState *pcms, setup_size = 4; } setup_size = (setup_size+1)*512; + if (setup_size > kernel_size) { + fprintf(stderr, "qemu: invalid kernel header\n"); + exit(1); + } kernel_size -= setup_size; setup = g_malloc(setup_size); From 4a7428c5a7e82f4dde3646e4a8cc8e54f3257e2a Mon Sep 17 00:00:00 2001 From: Christopher Covington Date: Fri, 25 Sep 2015 10:42:21 -0400 Subject: [PATCH 08/19] s/cpu_get_real_ticks/cpu_get_host_ticks/ This should help clarify the purpose of the function that returns the host system's CPU cycle count. Signed-off-by: Christopher Covington Acked-by: Paolo Bonzini ppc portion Acked-by: David Gibson Signed-off-by: Michael Tokarev --- bsd-user/main.c | 2 +- cpus.c | 6 +++--- hw/intc/xics.c | 2 +- hw/ppc/ppc.c | 4 ++-- include/qemu/timer.h | 20 ++++++++++---------- linux-user/main.c | 4 ++-- target-alpha/sys_helper.c | 2 +- 7 files changed, 20 insertions(+), 20 deletions(-) diff --git a/bsd-user/main.c b/bsd-user/main.c index f0a1268dda..adf2de0d90 100644 --- a/bsd-user/main.c +++ b/bsd-user/main.c @@ -108,7 +108,7 @@ void cpu_list_unlock(void) uint64_t cpu_get_tsc(CPUX86State *env) { - return cpu_get_real_ticks(); + return cpu_get_host_ticks(); } static void write_dt(void *ptr, unsigned long addr, unsigned long limit, diff --git a/cpus.c b/cpus.c index d44c0eda89..d2e9e4fd96 100644 --- a/cpus.c +++ b/cpus.c @@ -199,7 +199,7 @@ int64_t cpu_get_ticks(void) ticks = timers_state.cpu_ticks_offset; if (timers_state.cpu_ticks_enabled) { - ticks += cpu_get_real_ticks(); + ticks += cpu_get_host_ticks(); } if (timers_state.cpu_ticks_prev > ticks) { @@ -247,7 +247,7 @@ void cpu_enable_ticks(void) /* Here, the really thing protected by seqlock is cpu_clock_offset. */ seqlock_write_lock(&timers_state.vm_clock_seqlock); if (!timers_state.cpu_ticks_enabled) { - timers_state.cpu_ticks_offset -= cpu_get_real_ticks(); + timers_state.cpu_ticks_offset -= cpu_get_host_ticks(); timers_state.cpu_clock_offset -= get_clock(); timers_state.cpu_ticks_enabled = 1; } @@ -263,7 +263,7 @@ void cpu_disable_ticks(void) /* Here, the really thing protected by seqlock is cpu_clock_offset. */ seqlock_write_lock(&timers_state.vm_clock_seqlock); if (timers_state.cpu_ticks_enabled) { - timers_state.cpu_ticks_offset += cpu_get_real_ticks(); + timers_state.cpu_ticks_offset += cpu_get_host_ticks(); timers_state.cpu_clock_offset = cpu_get_clock_locked(); timers_state.cpu_ticks_enabled = 0; } diff --git a/hw/intc/xics.c b/hw/intc/xics.c index 67881c7109..9ff5796414 100644 --- a/hw/intc/xics.c +++ b/hw/intc/xics.c @@ -848,7 +848,7 @@ static target_ulong h_xirr_x(PowerPCCPU *cpu, sPAPRMachineState *spapr, uint32_t xirr = icp_accept(ss); args[0] = xirr; - args[1] = cpu_get_real_ticks(); + args[1] = cpu_get_host_ticks(); return H_SUCCESS; } diff --git a/hw/ppc/ppc.c b/hw/ppc/ppc.c index b77e30357a..2c604ef49d 100644 --- a/hw/ppc/ppc.c +++ b/hw/ppc/ppc.c @@ -834,7 +834,7 @@ static void cpu_ppc_set_tb_clk (void *opaque, uint32_t freq) static void timebase_pre_save(void *opaque) { PPCTimebase *tb = opaque; - uint64_t ticks = cpu_get_real_ticks(); + uint64_t ticks = cpu_get_host_ticks(); PowerPCCPU *first_ppc_cpu = POWERPC_CPU(first_cpu); if (!first_ppc_cpu->env.tb_env) { @@ -878,7 +878,7 @@ static int timebase_post_load(void *opaque, int version_id) NANOSECONDS_PER_SECOND); guest_tb = tb_remote->guest_timebase + MIN(0, migration_duration_tb); - tb_off_adj = guest_tb - cpu_get_real_ticks(); + tb_off_adj = guest_tb - cpu_get_host_ticks(); tb_off = first_ppc_cpu->env.tb_env->tb_offset; trace_ppc_tb_adjust(tb_off, tb_off_adj, tb_off_adj - tb_off, diff --git a/include/qemu/timer.h b/include/qemu/timer.h index 99392464a6..d0946cb953 100644 --- a/include/qemu/timer.h +++ b/include/qemu/timer.h @@ -857,7 +857,7 @@ int64_t cpu_icount_to_ns(int64_t icount); #if defined(_ARCH_PPC) -static inline int64_t cpu_get_real_ticks(void) +static inline int64_t cpu_get_host_ticks(void) { int64_t retval; #ifdef _ARCH_PPC64 @@ -883,7 +883,7 @@ static inline int64_t cpu_get_real_ticks(void) #elif defined(__i386__) -static inline int64_t cpu_get_real_ticks(void) +static inline int64_t cpu_get_host_ticks(void) { int64_t val; asm volatile ("rdtsc" : "=A" (val)); @@ -892,7 +892,7 @@ static inline int64_t cpu_get_real_ticks(void) #elif defined(__x86_64__) -static inline int64_t cpu_get_real_ticks(void) +static inline int64_t cpu_get_host_ticks(void) { uint32_t low,high; int64_t val; @@ -905,7 +905,7 @@ static inline int64_t cpu_get_real_ticks(void) #elif defined(__hppa__) -static inline int64_t cpu_get_real_ticks(void) +static inline int64_t cpu_get_host_ticks(void) { int val; asm volatile ("mfctl %%cr16, %0" : "=r"(val)); @@ -914,7 +914,7 @@ static inline int64_t cpu_get_real_ticks(void) #elif defined(__ia64) -static inline int64_t cpu_get_real_ticks(void) +static inline int64_t cpu_get_host_ticks(void) { int64_t val; asm volatile ("mov %0 = ar.itc" : "=r"(val) :: "memory"); @@ -923,7 +923,7 @@ static inline int64_t cpu_get_real_ticks(void) #elif defined(__s390__) -static inline int64_t cpu_get_real_ticks(void) +static inline int64_t cpu_get_host_ticks(void) { int64_t val; asm volatile("stck 0(%1)" : "=m" (val) : "a" (&val) : "cc"); @@ -932,7 +932,7 @@ static inline int64_t cpu_get_real_ticks(void) #elif defined(__sparc__) -static inline int64_t cpu_get_real_ticks (void) +static inline int64_t cpu_get_host_ticks (void) { #if defined(_LP64) uint64_t rval; @@ -970,7 +970,7 @@ static inline int64_t cpu_get_real_ticks (void) : "=r" (value)); \ } -static inline int64_t cpu_get_real_ticks(void) +static inline int64_t cpu_get_host_ticks(void) { /* On kernels >= 2.6.25 rdhwr , $2 and $3 are emulated */ uint32_t count; @@ -986,7 +986,7 @@ static inline int64_t cpu_get_real_ticks(void) #elif defined(__alpha__) -static inline int64_t cpu_get_real_ticks(void) +static inline int64_t cpu_get_host_ticks(void) { uint64_t cc; uint32_t cur, ofs; @@ -1001,7 +1001,7 @@ static inline int64_t cpu_get_real_ticks(void) /* The host CPU doesn't have an easily accessible cycle counter. Just return a monotonically increasing value. This will be totally wrong, but hopefully better than nothing. */ -static inline int64_t cpu_get_real_ticks (void) +static inline int64_t cpu_get_host_ticks (void) { static int64_t ticks = 0; return ticks++; diff --git a/linux-user/main.c b/linux-user/main.c index 1f60ff2a1f..d6af7cadd9 100644 --- a/linux-user/main.c +++ b/linux-user/main.c @@ -215,7 +215,7 @@ void cpu_list_unlock(void) uint64_t cpu_get_tsc(CPUX86State *env) { - return cpu_get_real_ticks(); + return cpu_get_host_ticks(); } static void write_dt(void *ptr, unsigned long addr, unsigned long limit, @@ -1425,7 +1425,7 @@ void cpu_loop (CPUSPARCState *env) #ifdef TARGET_PPC static inline uint64_t cpu_ppc_get_tb(CPUPPCState *env) { - return cpu_get_real_ticks(); + return cpu_get_host_ticks(); } uint64_t cpu_ppc_load_tbl(CPUPPCState *env) diff --git a/target-alpha/sys_helper.c b/target-alpha/sys_helper.c index 1f0e1a9671..75c96c1c20 100644 --- a/target-alpha/sys_helper.c +++ b/target-alpha/sys_helper.c @@ -34,7 +34,7 @@ uint64_t helper_load_pcc(CPUAlphaState *env) #else /* In user-mode, QEMU_CLOCK_VIRTUAL doesn't exist. Just pass through the host cpu clock ticks. Also, don't bother taking PCC_OFS into account. */ - return (uint32_t)cpu_get_real_ticks(); + return (uint32_t)cpu_get_host_ticks(); #endif } From 738c8b01ba4d020ee42c72e83a6aa3d9408a2530 Mon Sep 17 00:00:00 2001 From: Shraddha Barke Date: Fri, 25 Sep 2015 14:07:56 +0530 Subject: [PATCH 09/19] target-microblaze: Remove unnecessary variable Compress lines and remove the variable. Signed-off-by: Shraddha Barke Signed-off-by: Michael Tokarev --- target-microblaze/op_helper.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/target-microblaze/op_helper.c b/target-microblaze/op_helper.c index 092c4b594d..d32434770c 100644 --- a/target-microblaze/op_helper.c +++ b/target-microblaze/op_helper.c @@ -150,9 +150,7 @@ uint32_t helper_clz(uint32_t t0) uint32_t helper_carry(uint32_t a, uint32_t b, uint32_t cf) { - uint32_t ncf; - ncf = compute_carry(a, b, cf); - return ncf; + return compute_carry(a, b, cf); } static inline int div_prepare(CPUMBState *env, uint32_t a, uint32_t b) From f9b8e7f63acf9418238444aec654aba249a334ba Mon Sep 17 00:00:00 2001 From: Shraddha Barke Date: Fri, 25 Sep 2015 14:07:58 +0530 Subject: [PATCH 10/19] target-ppc: Remove unnecessary variable Compress lines and remove the variable. Signed-off-by: Shraddha Barke Signed-off-by: Michael Tokarev --- target-ppc/kvm.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/target-ppc/kvm.c b/target-ppc/kvm.c index e641680fb1..f8ea783a6d 100644 --- a/target-ppc/kvm.c +++ b/target-ppc/kvm.c @@ -1782,8 +1782,7 @@ uint32_t kvmppc_get_tbfreq(void) ns++; - retval = atoi(ns); - return retval; + return atoi(ns); } bool kvmppc_get_host_serial(char **value) From 885bdc95b165dc2b63bdc756be4919e948b9d27b Mon Sep 17 00:00:00 2001 From: Stefan Weil Date: Fri, 25 Sep 2015 22:25:32 +0200 Subject: [PATCH 11/19] MAINTAINERS: Add NSIS file for W32, W64 hosts The NSIS installer configuration is maintained by me. Signed-off-by: Stefan Weil Signed-off-by: Michael Tokarev --- MAINTAINERS | 1 + 1 file changed, 1 insertion(+) diff --git a/MAINTAINERS b/MAINTAINERS index 7603ea2d44..9bde8328e0 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -275,6 +275,7 @@ L: qemu-devel@nongnu.org M: Stefan Weil S: Maintained F: *win32* +F: qemu.nsi ARM Machines ------------ From f169f8fbca3999fe59f37a86822f305f7292949d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Date: Fri, 25 Sep 2015 16:03:30 +0200 Subject: [PATCH 12/19] qapi: add missing @ MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Marc-André Lureau Reviewed-by: Eric Blake Signed-off-by: Michael Tokarev --- qapi/block.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/qapi/block.json b/qapi/block.json index aad645c4a6..84022f12be 100644 --- a/qapi/block.json +++ b/qapi/block.json @@ -6,7 +6,7 @@ { 'include': 'block-core.json' } ## -# BiosAtaTranslation: +# @BiosAtaTranslation: # # Policy that BIOS should use to interpret cylinder/head/sector # addresses. Note that Bochs BIOS and SeaBIOS will not actually From bf5f78efed26054c2ce71e6f4c30ece13bf06e87 Mon Sep 17 00:00:00 2001 From: Shraddha Barke Date: Fri, 25 Sep 2015 20:06:03 +0530 Subject: [PATCH 13/19] hw: timer: Remove unnecessary variable Compress lines and remove the variable. Signed-off-by: Shraddha Barke Signed-off-by: Michael Tokarev --- hw/timer/m48t59.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/hw/timer/m48t59.c b/hw/timer/m48t59.c index 8ab683ddac..b3df8f9ec9 100644 --- a/hw/timer/m48t59.c +++ b/hw/timer/m48t59.c @@ -590,10 +590,8 @@ static void nvram_writel (void *opaque, hwaddr addr, uint32_t value) static uint32_t nvram_readb (void *opaque, hwaddr addr) { M48t59State *NVRAM = opaque; - uint32_t retval; - retval = m48t59_read(NVRAM, addr); - return retval; + return m48t59_read(NVRAM, addr); } static uint32_t nvram_readw (void *opaque, hwaddr addr) From 65cb2a14cacbc08c754f3cb41436fe6ece46593a Mon Sep 17 00:00:00 2001 From: Shraddha Barke Date: Fri, 25 Sep 2015 20:06:02 +0530 Subject: [PATCH 14/19] hw: char: Remove unnecessary variable Compress lines and remove the variable. Signed-off-by: Shraddha Barke Signed-off-by: Michael Tokarev --- hw/char/etraxfs_ser.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/hw/char/etraxfs_ser.c b/hw/char/etraxfs_ser.c index 857c13621c..562021e28b 100644 --- a/hw/char/etraxfs_ser.c +++ b/hw/char/etraxfs_ser.c @@ -182,15 +182,13 @@ static void serial_receive(void *opaque, const uint8_t *buf, int size) static int serial_can_receive(void *opaque) { ETRAXSerial *s = opaque; - int r; /* Is the receiver enabled? */ if (!(s->regs[RW_REC_CTRL] & (1 << 3))) { return 0; } - r = sizeof(s->rx_fifo) - s->rx_fifo_len; - return r; + return sizeof(s->rx_fifo) - s->rx_fifo_len; } static void serial_event(void *opaque, int event) From cb157af23833ca0762125f34b3fe73cfdbac297e Mon Sep 17 00:00:00 2001 From: David Gibson Date: Wed, 23 Sep 2015 15:27:12 +1000 Subject: [PATCH 15/19] .travis.yml: Run make check for all targets, not just some ed173cb ".travis.yml: remove "make check" from main matrix" stopped running make check for all the Travis build targets for various reasons. It continued to run make check on one Travis build, which builds for a big list of all (? nearly all) our supported softmmu targets. Unfortunately, due to a spacing / quoting error it only actually builds for the alpha, arm, aarch64 and cris targets. Specifically, the list of targets is split over several lines. Even with YAML folding, this will leave spaces in the list, meaning $TARGETS won't have the value we need. I had a look at the YAML spec and I couldn't quickly see a way of splitting the list so that it doesn't end up with spaces, so this patch fixes the problem by putting the whole list on one huge line. Signed-off-by: David Gibson Signed-off-by: Michael Tokarev --- .travis.yml | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/.travis.yml b/.travis.yml index 0ac170b467..6ca0260941 100644 --- a/.travis.yml +++ b/.travis.yml @@ -54,15 +54,7 @@ matrix: include: # Make check target (we only do this once) - env: - - TARGETS=alpha-softmmu,arm-softmmu,aarch64-softmmu,cris-softmmu, - i386-softmmu,x86_64-softmmu,m68k-softmmu,microblaze-softmmu, - microblazeel-softmmu,mips-softmmu,mips64-softmmu, - mips64el-softmmu,mipsel-softmmu,or32-softmmu,ppc-softmmu, - ppc64-softmmu,ppcemb-softmmu,s390x-softmmu,sh4-softmmu, - sh4eb-softmmu,sparc-softmmu,sparc64-softmmu, - unicore32-softmmu,unicore32-linux-user, - lm32-softmmu,moxie-softmmu,tricore-softmmu,xtensa-softmmu, - xtensaeb-softmmu + - TARGETS=alpha-softmmu,arm-softmmu,aarch64-softmmu,cris-softmmu,i386-softmmu,x86_64-softmmu,m68k-softmmu,microblaze-softmmu,microblazeel-softmmu,mips-softmmu,mips64-softmmu,mips64el-softmmu,mipsel-softmmu,or32-softmmu,ppc-softmmu,ppc64-softmmu,ppcemb-softmmu,s390x-softmmu,sh4-softmmu,sh4eb-softmmu,sparc-softmmu,sparc64-softmmu,unicore32-softmmu,unicore32-linux-user,lm32-softmmu,moxie-softmmu,tricore-softmmu,xtensa-softmmu,xtensaeb-softmmu TEST_CMD="make check" compiler: gcc # Debug related options From 778358d0a8f74a76488daea3c1b6fb327d8135b4 Mon Sep 17 00:00:00 2001 From: Markus Armbruster Date: Mon, 14 Sep 2015 13:52:23 +0200 Subject: [PATCH 16/19] rocker: Use g_new() & friends where that makes obvious sense g_new(T, n) is neater than g_malloc(sizeof(T) * n). It's also safer, for two reasons. One, it catches multiplication overflowing size_t. Two, it returns T * rather than void *, which lets the compiler catch more type errors. This commit only touches allocations with size arguments of the form sizeof(T). Same Coccinelle semantic patchas in commit b45c03f. Signed-off-by: Markus Armbruster Acked-by: Jiri Pirko Reviewed-by: Eric Blake Reviewed-by: Jiri Pirko Signed-off-by: Michael Tokarev --- hw/net/rocker/rocker.c | 2 +- hw/net/rocker/rocker_desc.c | 4 ++-- hw/net/rocker/rocker_fp.c | 2 +- hw/net/rocker/rocker_of_dpa.c | 9 ++++----- 4 files changed, 8 insertions(+), 9 deletions(-) diff --git a/hw/net/rocker/rocker.c b/hw/net/rocker/rocker.c index 7e7bda4987..bb6fdc364d 100644 --- a/hw/net/rocker/rocker.c +++ b/hw/net/rocker/rocker.c @@ -1362,7 +1362,7 @@ static int pci_rocker_init(PCIDevice *dev) r->fp_ports = ROCKER_FP_PORTS_MAX; } - r->rings = g_malloc(sizeof(DescRing *) * rocker_pci_ring_count(r)); + r->rings = g_new(DescRing *, rocker_pci_ring_count(r)); if (!r->rings) { goto err_rings_alloc; } diff --git a/hw/net/rocker/rocker_desc.c b/hw/net/rocker/rocker_desc.c index b5c0b4a241..5e697b19e3 100644 --- a/hw/net/rocker/rocker_desc.c +++ b/hw/net/rocker/rocker_desc.c @@ -142,7 +142,7 @@ bool desc_ring_set_size(DescRing *ring, uint32_t size) ring->size = size; ring->head = ring->tail = 0; - ring->info = g_realloc(ring->info, size * sizeof(DescInfo)); + ring->info = g_renew(DescInfo, ring->info, size); if (!ring->info) { return false; } @@ -345,7 +345,7 @@ DescRing *desc_ring_alloc(Rocker *r, int index) { DescRing *ring; - ring = g_malloc0(sizeof(DescRing)); + ring = g_new0(DescRing, 1); if (!ring) { return NULL; } diff --git a/hw/net/rocker/rocker_fp.c b/hw/net/rocker/rocker_fp.c index c693ae5081..5906396b9d 100644 --- a/hw/net/rocker/rocker_fp.c +++ b/hw/net/rocker/rocker_fp.c @@ -218,7 +218,7 @@ FpPort *fp_port_alloc(Rocker *r, char *sw_name, MACAddr *start_mac, unsigned int index, NICPeers *peers) { - FpPort *port = g_malloc0(sizeof(FpPort)); + FpPort *port = g_new0(FpPort, 1); if (!port) { return NULL; diff --git a/hw/net/rocker/rocker_of_dpa.c b/hw/net/rocker/rocker_of_dpa.c index 874fb01d69..1ad2791965 100644 --- a/hw/net/rocker/rocker_of_dpa.c +++ b/hw/net/rocker/rocker_of_dpa.c @@ -367,7 +367,7 @@ static OfDpaFlow *of_dpa_flow_alloc(uint64_t cookie) OfDpaFlow *flow; int64_t now = qemu_clock_get_ms(QEMU_CLOCK_VIRTUAL) / 1000; - flow = g_malloc0(sizeof(OfDpaFlow)); + flow = g_new0(OfDpaFlow, 1); if (!flow) { return NULL; } @@ -811,7 +811,7 @@ static int of_dpa_group_get_stats(OfDpa *of_dpa, uint32_t id) static OfDpaGroup *of_dpa_group_alloc(uint32_t id) { - OfDpaGroup *group = g_malloc0(sizeof(OfDpaGroup)); + OfDpaGroup *group = g_new0(OfDpaGroup, 1); if (!group) { return NULL; @@ -2039,15 +2039,14 @@ static int of_dpa_cmd_add_l2_flood(OfDpa *of_dpa, OfDpaGroup *group, group->l2_flood.group_count = rocker_tlv_get_le16(group_tlvs[ROCKER_TLV_OF_DPA_GROUP_COUNT]); - tlvs = g_malloc0((group->l2_flood.group_count + 1) * - sizeof(RockerTlv *)); + tlvs = g_new0(RockerTlv *, group->l2_flood.group_count + 1); if (!tlvs) { return -ROCKER_ENOMEM; } g_free(group->l2_flood.group_ids); group->l2_flood.group_ids = - g_malloc0(group->l2_flood.group_count * sizeof(uint32_t)); + g_new0(uint32_t, group->l2_flood.group_count); if (!group->l2_flood.group_ids) { err = -ROCKER_ENOMEM; goto err_out; From c78d65e8a7d87badf46eda3a0b41330f5d239132 Mon Sep 17 00:00:00 2001 From: Markus Armbruster Date: Mon, 14 Sep 2015 13:53:03 +0200 Subject: [PATCH 17/19] linux-user: Use g_new() & friends where that makes obvious sense g_new(T, n) is neater than g_malloc(sizeof(T) * n). It's also safer, for two reasons. One, it catches multiplication overflowing size_t. Two, it returns T * rather than void *, which lets the compiler catch more type errors. This commit only touches allocations with size arguments of the form sizeof(T). Same Coccinelle semantic patch as in commit b45c03f. Signed-off-by: Markus Armbruster Reviewed-by: Eric Blake Reviewed-by: Stefan Weil Signed-off-by: Michael Tokarev --- linux-user/elfload.c | 2 +- linux-user/main.c | 2 +- linux-user/syscall.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/linux-user/elfload.c b/linux-user/elfload.c index fdae6a6cd1..d68f5a16ca 100644 --- a/linux-user/elfload.c +++ b/linux-user/elfload.c @@ -2853,7 +2853,7 @@ static int fill_note_info(struct elf_note_info *info, TaskState *ts = (TaskState *)cpu->opaque; int i; - info->notes = g_malloc0(NUMNOTES * sizeof (struct memelfnote)); + info->notes = g_new0(struct memelfnote, NUMNOTES); if (info->notes == NULL) return (-ENOMEM); info->prstatus = g_malloc0(sizeof (*info->prstatus)); diff --git a/linux-user/main.c b/linux-user/main.c index d6af7cadd9..8acfe0fdf4 100644 --- a/linux-user/main.c +++ b/linux-user/main.c @@ -4270,7 +4270,7 @@ int main(int argc, char **argv, char **envp) } target_argv[target_argc] = NULL; - ts = g_malloc0 (sizeof(TaskState)); + ts = g_new0(TaskState, 1); init_task_state(ts); /* build Task State */ ts->info = info; diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 98b5766d4a..b8ce208d7d 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -4566,7 +4566,7 @@ static int do_fork(CPUArchState *env, unsigned int flags, abi_ulong newsp, new_thread_info info; pthread_attr_t attr; - ts = g_malloc0(sizeof(TaskState)); + ts = g_new0(TaskState, 1); init_task_state(ts); /* we create a new CPU instance. */ new_env = cpu_copy(env); From d1c002b6ae2dc81d97bbe23fe65e1960abdba9a4 Mon Sep 17 00:00:00 2001 From: Stefan Weil Date: Sun, 8 Feb 2015 15:40:58 +0100 Subject: [PATCH 18/19] linux-user: Remove type casts to union type Casting to a union type is a gcc (and clang) extension. Other compilers might not support it. This is not a problem today, but the type casts can be removed easily. Smatch now no longer complains like before: linux-user/syscall.c:3190:18: warning: cast to non-scalar linux-user/syscall.c:7348:44: warning: cast to non-scalar Cc: Riku Voipio Signed-off-by: Stefan Weil Signed-off-by: Michael Tokarev --- linux-user/syscall.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/linux-user/syscall.c b/linux-user/syscall.c index b8ce208d7d..8bfb24f05b 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -2728,8 +2728,9 @@ static inline abi_long host_to_target_semarray(int semid, abi_ulong target_addr, } static inline abi_long do_semctl(int semid, int semnum, int cmd, - union target_semun target_su) + abi_ulong target_arg) { + union target_semun target_su = { .buf = target_arg }; union semun arg; struct semid_ds dsarg; unsigned short *array = NULL; @@ -3251,8 +3252,7 @@ static abi_long do_ipc(unsigned int call, abi_long first, * ptr argument. */ abi_ulong atptr; get_user_ual(atptr, ptr); - ret = do_semctl(first, second, third, - (union target_semun) atptr); + ret = do_semctl(first, second, third, atptr); break; } @@ -7550,7 +7550,7 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1, #endif #ifdef TARGET_NR_semctl case TARGET_NR_semctl: - ret = do_semctl(arg1, arg2, arg3, (union target_semun)(abi_ulong)arg4); + ret = do_semctl(arg1, arg2, arg3, arg4); break; #endif #ifdef TARGET_NR_msgctl From deb847bfba7ee0ab8151842f5e9cb12d4daad3a3 Mon Sep 17 00:00:00 2001 From: "Dr. David Alan Gilbert" Date: Mon, 5 Oct 2015 12:04:20 +0100 Subject: [PATCH 19/19] tests: Unique test path for /string-visitor/output Newer GLib's want unique test paths, and thus moan at dupes. (Seen on Fedora 23 which has glib 2.46) Uniquify the paths. Signed-off-by: Dr. David Alan Gilbert Reviewed-by: Eric Blake Signed-off-by: Michael Tokarev --- tests/test-string-output-visitor.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/tests/test-string-output-visitor.c b/tests/test-string-output-visitor.c index 101fb27dd1..fd5e67be64 100644 --- a/tests/test-string-output-visitor.c +++ b/tests/test-string-output-visitor.c @@ -248,39 +248,39 @@ int main(int argc, char **argv) output_visitor_test_add("/string-visitor/output/int", &out_visitor_data, test_visitor_out_int, false); - output_visitor_test_add("/string-visitor/output/int", + output_visitor_test_add("/string-visitor/output/int-human", &out_visitor_data, test_visitor_out_int, true); output_visitor_test_add("/string-visitor/output/bool", &out_visitor_data, test_visitor_out_bool, false); - output_visitor_test_add("/string-visitor/output/bool", + output_visitor_test_add("/string-visitor/output/bool-human", &out_visitor_data, test_visitor_out_bool, true); output_visitor_test_add("/string-visitor/output/number", &out_visitor_data, test_visitor_out_number, false); - output_visitor_test_add("/string-visitor/output/number", + output_visitor_test_add("/string-visitor/output/number-human", &out_visitor_data, test_visitor_out_number, true); output_visitor_test_add("/string-visitor/output/string", &out_visitor_data, test_visitor_out_string, false); - output_visitor_test_add("/string-visitor/output/string", + output_visitor_test_add("/string-visitor/output/string-human", &out_visitor_data, test_visitor_out_string, true); output_visitor_test_add("/string-visitor/output/no-string", &out_visitor_data, test_visitor_out_no_string, false); - output_visitor_test_add("/string-visitor/output/no-string", + output_visitor_test_add("/string-visitor/output/no-string-human", &out_visitor_data, test_visitor_out_no_string, true); output_visitor_test_add("/string-visitor/output/enum", &out_visitor_data, test_visitor_out_enum, false); - output_visitor_test_add("/string-visitor/output/enum", + output_visitor_test_add("/string-visitor/output/enum-human", &out_visitor_data, test_visitor_out_enum, true); output_visitor_test_add("/string-visitor/output/enum-errors", &out_visitor_data, test_visitor_out_enum_errors, false); - output_visitor_test_add("/string-visitor/output/enum-errors", + output_visitor_test_add("/string-visitor/output/enum-errors-human", &out_visitor_data, test_visitor_out_enum_errors, true); output_visitor_test_add("/string-visitor/output/intList", &out_visitor_data, test_visitor_out_intList, false); - output_visitor_test_add("/string-visitor/output/intList", + output_visitor_test_add("/string-visitor/output/intList-human", &out_visitor_data, test_visitor_out_intList, true); g_test_run();