Merge remote-tracking branch 'remotes/mjt/tags/trivial-patches-fetch' into staging

trivial patches for 2018-05-20

# gpg: Signature made Sun 20 May 2018 07:13:20 BST
# gpg:                using RSA key 701B4F6B1A693E59
# gpg: Good signature from "Michael Tokarev <mjt@tls.msk.ru>"
# gpg:                 aka "Michael Tokarev <mjt@corpit.ru>"
# gpg:                 aka "Michael Tokarev <mjt@debian.org>"
# Primary key fingerprint: 6EE1 95D1 886E 8FFB 810D  4324 457C E0A0 8044 65C5
#      Subkey fingerprint: 7B73 BAD6 8BE7 A2C2 8931  4B22 701B 4F6B 1A69 3E59

* remotes/mjt/tags/trivial-patches-fetch: (22 commits)
  acpi: fix a comment about aml_call0()
  qapi/net.json: Fix the version number of the "vlan" removal
  gdbstub: Handle errors in gdb_accept()
  gdbstub: Use qemu_set_cloexec()
  replace functions which are only available in glib-2.24
  typedefs: Remove PcGuestInfo from qemu/typedefs.h
  qemu-options: Allow -no-user-config again
  hw/timer/mt48t59: Fix bit-rotten NVRAM_PRINTF format strings
  Remove unnecessary variables for function return value
  trivial: Do not include pci.h if it is not necessary
  tests: fix tpm-crb tpm-tis tests race
  hw/ide/ahci: Keep ALLWINNER_AHCI() macro internal
  qemu-img-cmds.hx: add passive-aggressive note
  qemu-img: Make documentation between .texi and .hx consistent
  qemu-img: remove references to GEN_DOCS
  qemu-img.texi: fix command ordering
  qemu-img-commands.hx: argument ordering fixups
  HACKING: document preference for g_new instead of g_malloc
  qemu-option-trace: -trace enable= is a pattern, not a file
  slirp/debug: Print IP addresses in human readable form
  ...

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
diff --git a/HACKING b/HACKING
index 4125c97..0fc3e0f 100644
--- a/HACKING
+++ b/HACKING
@@ -118,6 +118,15 @@
 is no need to test for failure (as you would have to with malloc).
 Calling g_malloc with a zero size is valid and will return NULL.
 
+Prefer g_new(T, n) instead of g_malloc(sizeof(T) * n) for the following
+reasons:
+
+  a. It catches multiplication overflowing size_t;
+  b. It returns T * instead of void *, letting compiler catch more type
+     errors.
+
+Declarations like T *v = g_malloc(sizeof(*v)) are acceptable, though.
+
 Memory allocated by qemu_memalign or qemu_blockalign must be freed with
 qemu_vfree, since breaking this will cause problems on Win32.
 
diff --git a/accel/tcg/translate-all.c b/accel/tcg/translate-all.c
index f409d42..732c9196 100644
--- a/accel/tcg/translate-all.c
+++ b/accel/tcg/translate-all.c
@@ -644,11 +644,8 @@
 static inline void *alloc_code_gen_buffer(void)
 {
     size_t size = tcg_ctx->code_gen_buffer_size;
-    void *buf;
-
-    buf = VirtualAlloc(NULL, size, MEM_RESERVE | MEM_COMMIT,
+    return VirtualAlloc(NULL, size, MEM_RESERVE | MEM_COMMIT,
                         PAGE_EXECUTE_READWRITE);
-    return buf;
 }
 #else
 static inline void *alloc_code_gen_buffer(void)
diff --git a/block/quorum.c b/block/quorum.c
index e448d7e..b6476c4 100644
--- a/block/quorum.c
+++ b/block/quorum.c
@@ -613,7 +613,7 @@
 static int read_quorum_children(QuorumAIOCB *acb)
 {
     BDRVQuorumState *s = acb->bs->opaque;
-    int i, ret;
+    int i;
 
     acb->children_read = s->num_children;
     for (i = 0; i < s->num_children; i++) {
@@ -648,9 +648,7 @@
         qemu_coroutine_yield();
     }
 
-    ret = acb->vote_ret;
-
-    return ret;
+    return acb->vote_ret;
 }
 
 static int read_fifo_child(QuorumAIOCB *acb)
diff --git a/gdbstub.c b/gdbstub.c
index 9682e16..e4ece2f 100644
--- a/gdbstub.c
+++ b/gdbstub.c
@@ -1814,7 +1814,7 @@
     put_packet(s, buf);
 }
 
-static void gdb_accept(void)
+static bool gdb_accept(void)
 {
     GDBState *s;
     struct sockaddr_in sockaddr;
@@ -1826,17 +1826,18 @@
         fd = accept(gdbserver_fd, (struct sockaddr *)&sockaddr, &len);
         if (fd < 0 && errno != EINTR) {
             perror("accept");
-            return;
+            return false;
         } else if (fd >= 0) {
-#ifndef _WIN32
-            fcntl(fd, F_SETFD, FD_CLOEXEC);
-#endif
+            qemu_set_cloexec(fd);
             break;
         }
     }
 
     /* set short latency */
-    socket_set_nodelay(fd);
+    if (socket_set_nodelay(fd)) {
+        perror("setsockopt");
+        return false;
+    }
 
     s = g_malloc0(sizeof(GDBState));
     s->c_cpu = first_cpu;
@@ -1845,6 +1846,7 @@
     gdb_has_xml = false;
 
     gdbserver_state = s;
+    return true;
 }
 
 static int gdbserver_open(int port)
@@ -1857,9 +1859,7 @@
         perror("socket");
         return -1;
     }
-#ifndef _WIN32
-    fcntl(fd, F_SETFD, FD_CLOEXEC);
-#endif
+    qemu_set_cloexec(fd);
 
     socket_set_fast_reuse(fd);
 
@@ -1887,7 +1887,11 @@
     if (gdbserver_fd < 0)
         return -1;
     /* accept connections */
-    gdb_accept();
+    if (!gdb_accept()) {
+        close(gdbserver_fd);
+        gdbserver_fd = -1;
+        return -1;
+    }
     return 0;
 }
 
diff --git a/hw/acpi/aml-build.c b/hw/acpi/aml-build.c
index 3fa557c..1e43cd7 100644
--- a/hw/acpi/aml-build.c
+++ b/hw/acpi/aml-build.c
@@ -627,7 +627,7 @@
     return var;
 }
 
-/* helper to call method with 1 argument */
+/* helper to call method without argument */
 Aml *aml_call0(const char *method)
 {
     Aml *var = aml_alloc();
diff --git a/hw/arm/exynos4210.c b/hw/arm/exynos4210.c
index 06f9d1f..b7463a7 100644
--- a/hw/arm/exynos4210.c
+++ b/hw/arm/exynos4210.c
@@ -156,12 +156,8 @@
 
 static uint64_t exynos4210_calc_affinity(int cpu)
 {
-    uint64_t mp_affinity;
-
     /* Exynos4210 has 0x9 as cluster ID */
-    mp_affinity = (0x9 << ARM_AFF1_SHIFT) | cpu;
-
-    return mp_affinity;
+    return (0x9 << ARM_AFF1_SHIFT) | cpu;
 }
 
 Exynos4210State *exynos4210_init(MemoryRegion *system_mem)
diff --git a/hw/block/vhost-user-blk.c b/hw/block/vhost-user-blk.c
index 262baca..975eae6 100644
--- a/hw/block/vhost-user-blk.c
+++ b/hw/block/vhost-user-blk.c
@@ -196,7 +196,6 @@
                                             Error **errp)
 {
     VHostUserBlk *s = VHOST_USER_BLK(vdev);
-    uint64_t get_features;
 
     /* Turn on pre-defined features */
     virtio_add_feature(&features, VIRTIO_BLK_F_SEG_MAX);
@@ -215,9 +214,7 @@
         virtio_add_feature(&features, VIRTIO_BLK_F_MQ);
     }
 
-    get_features = vhost_get_features(&s->dev, user_feature_bits, features);
-
-    return get_features;
+    return vhost_get_features(&s->dev, user_feature_bits, features);
 }
 
 static void vhost_user_blk_handle_output(VirtIODevice *vdev, VirtQueue *vq)
diff --git a/hw/hppa/dino.c b/hw/hppa/dino.c
index 15aefde..c5dcf31 100644
--- a/hw/hppa/dino.c
+++ b/hw/hppa/dino.c
@@ -403,13 +403,10 @@
 static int dino_pci_map_irq(PCIDevice *d, int irq_num)
 {
     int slot = d->devfn >> 3;
-    int local_irq;
 
     assert(irq_num >= 0 && irq_num <= 3);
 
-    local_irq = slot & 0x03;
-
-    return local_irq;
+    return slot & 0x03;
 }
 
 static void dino_set_timer_irq(void *opaque, int irq, int level)
diff --git a/hw/ide/ahci-allwinner.c b/hw/ide/ahci-allwinner.c
index 5397483..2fd9507 100644
--- a/hw/ide/ahci-allwinner.c
+++ b/hw/ide/ahci-allwinner.c
@@ -24,6 +24,9 @@
 
 #include "trace.h"
 
+#define ALLWINNER_AHCI(obj) \
+        OBJECT_CHECK(AllwinnerAHCIState, (obj), TYPE_ALLWINNER_AHCI)
+
 #define ALLWINNER_AHCI_BISTAFR    ((0xa0 - ALLWINNER_AHCI_MMIO_OFF) / 4)
 #define ALLWINNER_AHCI_BISTCR     ((0xa4 - ALLWINNER_AHCI_MMIO_OFF) / 4)
 #define ALLWINNER_AHCI_BISTFCTR   ((0xa8 - ALLWINNER_AHCI_MMIO_OFF) / 4)
diff --git a/hw/ide/ahci_internal.h b/hw/ide/ahci_internal.h
index 8c755d4..1a25d6c 100644
--- a/hw/ide/ahci_internal.h
+++ b/hw/ide/ahci_internal.h
@@ -375,7 +375,4 @@
 
 #define SYSBUS_AHCI(obj) OBJECT_CHECK(SysbusAHCIState, (obj), TYPE_SYSBUS_AHCI)
 
-#define ALLWINNER_AHCI(obj) OBJECT_CHECK(AllwinnerAHCIState, (obj), \
-                       TYPE_ALLWINNER_AHCI)
-
 #endif /* HW_IDE_AHCI_H */
diff --git a/hw/ide/trace-events b/hw/ide/trace-events
index 0c39cab..5c0e59e 100644
--- a/hw/ide/trace-events
+++ b/hw/ide/trace-events
@@ -108,8 +108,8 @@
 ahci_dma_rw_buf(void *s, int port, int l) "ahci(%p)[%d] len=0x%x"
 ahci_cmd_done(void *s, int port) "ahci(%p)[%d]: cmd done"
 ahci_reset(void *s) "ahci(%p): HBA reset"
-allwinner_ahci_mem_read(void *s, void *a, uint64_t addr, uint64_t val, unsigned size) "ahci(%p): read a=%p addr=0x%"HWADDR_PRIx" val=0x%"PRIx64", size=%d"
-allwinner_ahci_mem_write(void *s, void *a, uint64_t addr, uint64_t val, unsigned size) "ahci(%p): write a=%p addr=0x%"HWADDR_PRIx" val=0x%"PRIx64", size=%d"
+allwinner_ahci_mem_read(void *s, void *a, uint64_t addr, uint64_t val, unsigned size) "ahci(%p): read a=%p addr=0x%"PRIx64" val=0x%"PRIx64", size=%d"
+allwinner_ahci_mem_write(void *s, void *a, uint64_t addr, uint64_t val, unsigned size) "ahci(%p): write a=%p addr=0x%"PRIx64" val=0x%"PRIx64", size=%d"
 
 # Warning: Verbose
 handle_reg_h2d_fis_dump(void *s, int port, const char *fis) "ahci(%p)[%d]: %s"
diff --git a/hw/misc/mos6522.c b/hw/misc/mos6522.c
index 8ad9fc8..6163cea 100644
--- a/hw/misc/mos6522.c
+++ b/hw/misc/mos6522.c
@@ -176,12 +176,8 @@
 
 static uint64_t mos6522_get_counter_value(MOS6522State *s, MOS6522Timer *ti)
 {
-    uint64_t d;
-
-    d = muldiv64(qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL) - ti->load_time,
-                 ti->frequency, NANOSECONDS_PER_SECOND);
-
-    return d;
+    return muldiv64(qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL) - ti->load_time,
+                    ti->frequency, NANOSECONDS_PER_SECOND);
 }
 
 static uint64_t mos6522_get_load_time(MOS6522State *s, MOS6522Timer *ti)
diff --git a/hw/misc/trace-events b/hw/misc/trace-events
index 562d9ed..ec5a9f0 100644
--- a/hw/misc/trace-events
+++ b/hw/misc/trace-events
@@ -69,13 +69,13 @@
 mps2_fpgaio_leds(char led1, char led0) "MPS2 FPGAIO LEDs: %c%c"
 
 # hw/misc/msf2-sysreg.c
-msf2_sysreg_write(uint64_t offset, uint32_t val, uint32_t prev) "msf2-sysreg write: addr 0x%08" HWADDR_PRIx " data 0x%" PRIx32 " prev 0x%" PRIx32
-msf2_sysreg_read(uint64_t offset, uint32_t val) "msf2-sysreg read: addr 0x%08" HWADDR_PRIx " data 0x%08" PRIx32
+msf2_sysreg_write(uint64_t offset, uint32_t val, uint32_t prev) "msf2-sysreg write: addr 0x%08" PRIx64 " data 0x%" PRIx32 " prev 0x%" PRIx32
+msf2_sysreg_read(uint64_t offset, uint32_t val) "msf2-sysreg read: addr 0x%08" PRIx64 " data 0x%08" PRIx32
 msf2_sysreg_write_pll_status(void) "Invalid write to read only PLL status register"
 
 #hw/misc/imx7_gpr.c
-imx7_gpr_read(uint64_t offset) "addr 0x%08" HWADDR_PRIx
-imx7_gpr_write(uint64_t offset, uint64_t value) "addr 0x%08" HWADDR_PRIx "value 0x%08" HWADDR_PRIx
+imx7_gpr_read(uint64_t offset) "addr 0x%08" PRIx64
+imx7_gpr_write(uint64_t offset, uint64_t value) "addr 0x%08" PRIx64 "value 0x%08" PRIx64
 
 # hw/misc/mos6522.c
 mos6522_set_counter(int index, unsigned int val) "T%d.counter=%d"
diff --git a/hw/net/ftgmac100.c b/hw/net/ftgmac100.c
index 704f452..3300e8e 100644
--- a/hw/net/ftgmac100.c
+++ b/hw/net/ftgmac100.c
@@ -511,7 +511,6 @@
 
     uint32_t cnt = 1024 * FTGMAC100_APTC_RXPOLL_CNT(s->aptcr);
     uint32_t speed = (s->maccr & FTGMAC100_MACCR_FAST_MODE) ? 1 : 0;
-    uint32_t period;
 
     if (s->aptcr & FTGMAC100_APTC_RXPOLL_TIME_SEL) {
         cnt <<= 4;
@@ -521,9 +520,7 @@
         speed = 2;
     }
 
-    period = cnt / div[speed];
-
-    return period;
+    return cnt / div[speed];
 }
 
 static void ftgmac100_reset(DeviceState *d)
diff --git a/hw/ppc/pnv_lpc.c b/hw/ppc/pnv_lpc.c
index c42b4a8..2317d1e 100644
--- a/hw/ppc/pnv_lpc.c
+++ b/hw/ppc/pnv_lpc.c
@@ -125,25 +125,17 @@
 static bool opb_read(PnvLpcController *lpc, uint32_t addr, uint8_t *data,
                      int sz)
 {
-    bool success;
-
     /* XXX Handle access size limits and FW read caching here */
-    success = !address_space_rw(&lpc->opb_as, addr, MEMTXATTRS_UNSPECIFIED,
-                                data, sz, false);
-
-    return success;
+    return !address_space_rw(&lpc->opb_as, addr, MEMTXATTRS_UNSPECIFIED,
+                             data, sz, false);
 }
 
 static bool opb_write(PnvLpcController *lpc, uint32_t addr, uint8_t *data,
                       int sz)
 {
-    bool success;
-
     /* XXX Handle access size limits here */
-    success = !address_space_rw(&lpc->opb_as, addr, MEMTXATTRS_UNSPECIFIED,
-                                data, sz, true);
-
-    return success;
+    return !address_space_rw(&lpc->opb_as, addr, MEMTXATTRS_UNSPECIFIED,
+                             data, sz, true);
 }
 
 #define ECCB_CTL_READ           PPC_BIT(15)
diff --git a/hw/timer/m48t59-internal.h b/hw/timer/m48t59-internal.h
index 32ae957..d0f0caf 100644
--- a/hw/timer/m48t59-internal.h
+++ b/hw/timer/m48t59-internal.h
@@ -25,13 +25,10 @@
 #ifndef HW_M48T59_INTERNAL_H
 #define HW_M48T59_INTERNAL_H 1
 
-//#define DEBUG_NVRAM
+#define M48T59_DEBUG 0
 
-#if defined(DEBUG_NVRAM)
-#define NVRAM_PRINTF(fmt, ...) do { printf(fmt , ## __VA_ARGS__); } while (0)
-#else
-#define NVRAM_PRINTF(fmt, ...) do { } while (0)
-#endif
+#define NVRAM_PRINTF(fmt, ...) do { \
+    if (M48T59_DEBUG) { printf(fmt , ## __VA_ARGS__); } } while (0)
 
 /*
  * The M48T02, M48T08 and M48T59 chips are very similar. The newer '59 has
diff --git a/hw/timer/m48t59.c b/hw/timer/m48t59.c
index 742c576..f299176 100644
--- a/hw/timer/m48t59.c
+++ b/hw/timer/m48t59.c
@@ -456,7 +456,7 @@
 {
     M48t59State *NVRAM = opaque;
 
-    NVRAM_PRINTF("%s: 0x%08x => 0x%08x\n", __func__, addr, val);
+    NVRAM_PRINTF("%s: 0x%"HWADDR_PRIx" => 0x%"PRIx64"\n", __func__, addr, val);
     switch (addr) {
     case 0:
         NVRAM->addr &= ~0x00FF;
@@ -488,7 +488,7 @@
         retval = -1;
         break;
     }
-    NVRAM_PRINTF("%s: 0x%08x <= 0x%08x\n", __func__, addr, retval);
+    NVRAM_PRINTF("%s: 0x%"HWADDR_PRIx" <= 0x%08x\n", __func__, addr, retval);
 
     return retval;
 }
diff --git a/include/hw/ppc/ppc4xx.h b/include/hw/ppc/ppc4xx.h
index cb0bb55..3a2a04c 100644
--- a/include/hw/ppc/ppc4xx.h
+++ b/include/hw/ppc/ppc4xx.h
@@ -25,8 +25,6 @@
 #ifndef PPC4XX_H
 #define PPC4XX_H
 
-#include "hw/pci/pci.h"
-
 /* PowerPC 4xx core initialization */
 PowerPCCPU *ppc4xx_init(const char *cpu_model,
                         clk_setup_t *cpu_clk, clk_setup_t *tb_clk,
diff --git a/include/hw/virtio/virtio-balloon.h b/include/hw/virtio/virtio-balloon.h
index 1ea13bd..e0df352 100644
--- a/include/hw/virtio/virtio-balloon.h
+++ b/include/hw/virtio/virtio-balloon.h
@@ -17,7 +17,6 @@
 
 #include "standard-headers/linux/virtio_balloon.h"
 #include "hw/virtio/virtio.h"
-#include "hw/pci/pci.h"
 
 #define TYPE_VIRTIO_BALLOON "virtio-balloon-device"
 #define VIRTIO_BALLOON(obj) \
diff --git a/include/hw/virtio/virtio-gpu.h b/include/hw/virtio/virtio-gpu.h
index 22ac3c2..79bb3fb 100644
--- a/include/hw/virtio/virtio-gpu.h
+++ b/include/hw/virtio/virtio-gpu.h
@@ -18,7 +18,6 @@
 #include "ui/qemu-pixman.h"
 #include "ui/console.h"
 #include "hw/virtio/virtio.h"
-#include "hw/pci/pci.h"
 #include "qemu/log.h"
 
 #include "standard-headers/linux/virtio_gpu.h"
diff --git a/include/qemu/typedefs.h b/include/qemu/typedefs.h
index a46b0b3..325c72d 100644
--- a/include/qemu/typedefs.h
+++ b/include/qemu/typedefs.h
@@ -62,7 +62,6 @@
 typedef struct NetFilterState NetFilterState;
 typedef struct NICInfo NICInfo;
 typedef struct NumaNodeMem NumaNodeMem;
-typedef struct PcGuestInfo PcGuestInfo;
 typedef struct PCIBridge PCIBridge;
 typedef struct PCIBus PCIBus;
 typedef struct PCIDevice PCIDevice;
diff --git a/io/net-listener.c b/io/net-listener.c
index 555e8ac..3317aa6 100644
--- a/io/net-listener.c
+++ b/io/net-listener.c
@@ -25,11 +25,7 @@
 
 QIONetListener *qio_net_listener_new(void)
 {
-    QIONetListener *ret;
-
-    ret = QIO_NET_LISTENER(object_new(TYPE_QIO_NET_LISTENER));
-
-    return ret;
+    return QIO_NET_LISTENER(object_new(TYPE_QIO_NET_LISTENER));
 }
 
 void qio_net_listener_set_name(QIONetListener *listener,
diff --git a/qapi/net.json b/qapi/net.json
index b4fe4b6..b8adf1f 100644
--- a/qapi/net.json
+++ b/qapi/net.json
@@ -450,7 +450,7 @@
 #
 # Since: 2.7
 #
-# 'dump' - removed with 2.12
+# 'dump': dropped in 2.12
 ##
 { 'enum': 'NetClientDriver',
   'data': [ 'none', 'nic', 'user', 'tap', 'l2tpv3', 'socket', 'vde',
@@ -498,7 +498,7 @@
 #
 # Since: 1.2
 #
-# 'vlan' - removed with 2.12
+# 'vlan': dropped in 2.13
 ##
 { 'struct': 'NetLegacy',
   'data': {
diff --git a/qemu-img-cmds.hx b/qemu-img-cmds.hx
index 2fe3189..3d2f7b2 100644
--- a/qemu-img-cmds.hx
+++ b/qemu-img-cmds.hx
@@ -6,6 +6,9 @@
 HXCOMM command structures and help message.
 HXCOMM HXCOMM can be used for comments, discarded from both texi and C
 
+HXCOMM When amending the TEXI sections, please remember to copy the usage
+HXCOMM over to the per-command sections in qemu-img.texi.
+
 STEXI
 @table @option
 ETEXI
@@ -23,13 +26,13 @@
 ETEXI
 
 DEF("check", img_check,
-    "check [-q] [--object objectdef] [--image-opts] [-f fmt] [--output=ofmt] [-r [leaks | all]] [-T src_cache] [-U] filename")
+    "check [--object objectdef] [--image-opts] [-q] [-f fmt] [--output=ofmt] [-r [leaks | all]] [-T src_cache] [-U] filename")
 STEXI
 @item check [--object @var{objectdef}] [--image-opts] [-q] [-f @var{fmt}] [--output=@var{ofmt}] [-r [leaks | all]] [-T @var{src_cache}] [-U] @var{filename}
 ETEXI
 
 DEF("commit", img_commit,
-    "commit [-q] [--object objectdef] [--image-opts] [-f fmt] [-t cache] [-b base] [-d] [-p] filename")
+    "commit [--object objectdef] [--image-opts] [-q] [-f fmt] [-t cache] [-b base] [-d] [-p] filename")
 STEXI
 @item commit [--object @var{objectdef}] [--image-opts] [-q] [-f @var{fmt}] [-t @var{cache}] [-b @var{base}] [-d] [-p] @var{filename}
 ETEXI
@@ -47,7 +50,7 @@
 ETEXI
 
 DEF("create", img_create,
-    "create [-q] [--object objectdef] [-f fmt] [-b backing_file] [-F backing_fmt] [-u] [-o options] filename [size]")
+    "create [--object objectdef] [-q] [-f fmt] [-b backing_file] [-F backing_fmt] [-u] [-o options] filename [size]")
 STEXI
 @item create [--object @var{objectdef}] [-q] [-f @var{fmt}] [-b @var{backing_file}] [-F @var{backing_fmt}] [-u] [-o @var{options}] @var{filename} [@var{size}]
 ETEXI
@@ -89,9 +92,9 @@
 ETEXI
 
 DEF("resize", img_resize,
-    "resize [--object objectdef] [--image-opts] [-q] [--shrink] filename [+ | -]size")
+    "resize [--object objectdef] [--image-opts] [-f fmt] [--preallocation=prealloc] [-q] [--shrink] filename [+ | -]size")
 STEXI
-@item resize [--object @var{objectdef}] [--image-opts] [-q] [--shrink] @var{filename} [+ | -]@var{size}
+@item resize [--object @var{objectdef}] [--image-opts] [-f @var{fmt}] [--preallocation=@var{prealloc}] [-q] [--shrink] @var{filename} [+ | -]@var{size}
 ETEXI
 
 STEXI
diff --git a/qemu-img.c b/qemu-img.c
index 60e45ec..2b5a570 100644
--- a/qemu-img.c
+++ b/qemu-img.c
@@ -123,7 +123,6 @@
            "  " arg_string "\n"
 #include "qemu-img-cmds.h"
 #undef DEF
-#undef GEN_DOCS
            "\n"
            "Command parameters:\n"
            "  'filename' is a disk image filename\n"
@@ -4716,7 +4715,6 @@
     { option, callback },
 #include "qemu-img-cmds.h"
 #undef DEF
-#undef GEN_DOCS
     { NULL, NULL, },
 };
 
diff --git a/qemu-img.texi b/qemu-img.texi
index 8a26400..2be8206 100644
--- a/qemu-img.texi
+++ b/qemu-img.texi
@@ -193,7 +193,13 @@
 Command description:
 
 @table @option
-@item bench [-c @var{count}] [-d @var{depth}] [-f @var{fmt}] [--flush-interval=@var{flush_interval}] [-n] [--no-drain] [-o @var{offset}] [--pattern=@var{pattern}] [-q] [-s @var{buffer_size}] [-S @var{step_size}] [-t @var{cache}] [-w] @var{filename}
+
+@item amend [--object @var{objectdef}] [--image-opts] [-p] [-p] [-f @var{fmt}] [-t @var{cache}] -o @var{options} @var{filename}
+
+Amends the image format specific @var{options} for the image file
+@var{filename}. Not all file formats support this operation.
+
+@item bench [-c @var{count}] [-d @var{depth}] [-f @var{fmt}] [--flush-interval=@var{flush_interval}] [-n] [--no-drain] [-o @var{offset}] [--pattern=@var{pattern}] [-q] [-s @var{buffer_size}] [-S @var{step_size}] [-t @var{cache}] [-w] [-U] @var{filename}
 
 Run a simple sequential I/O benchmark on the specified image. If @code{-w} is
 specified, a write test is performed, otherwise a read test is performed.
@@ -217,7 +223,7 @@
 For write tests, by default a buffer filled with zeros is written. This can be
 overridden with a pattern byte specified by @var{pattern}.
 
-@item check [-f @var{fmt}] [--output=@var{ofmt}] [-r [leaks | all]] [-T @var{src_cache}] @var{filename}
+@item check [--object @var{objectdef}] [--image-opts] [-q] [-f @var{fmt}] [--output=@var{ofmt}] [-r [leaks | all]] [-T @var{src_cache}] [-U] @var{filename}
 
 Perform a consistency check on the disk image @var{filename}. The command can
 output in the format @var{ofmt} which is either @code{human} or @code{json}.
@@ -253,31 +259,7 @@
 state after (the attempt at) repairing it. That is, a successful @code{-r all}
 will yield the exit code 0, independently of the image state before.
 
-@item create [-f @var{fmt}] [-b @var{backing_file}] [-F @var{backing_fmt}] [-u] [-o @var{options}] @var{filename} [@var{size}]
-
-Create the new disk image @var{filename} of size @var{size} and format
-@var{fmt}. Depending on the file format, you can add one or more @var{options}
-that enable additional features of this format.
-
-If the option @var{backing_file} is specified, then the image will record
-only the differences from @var{backing_file}. No size needs to be specified in
-this case. @var{backing_file} will never be modified unless you use the
-@code{commit} monitor command (or qemu-img commit).
-
-If a relative path name is given, the backing file is looked up relative to
-the directory containing @var{filename}.
-
-Note that a given backing file will be opened to check that it is valid. Use
-the @code{-u} option to enable unsafe backing file mode, which means that the
-image will be created even if the associated backing file cannot be opened. A
-matching backing file must be created or additional options be used to make the
-backing file specification valid when you want to use an image created this
-way.
-
-The size can also be specified using the @var{size} option with @code{-o},
-it doesn't need to be specified separately in this case.
-
-@item commit [-q] [-f @var{fmt}] [-t @var{cache}] [-b @var{base}] [-d] [-p] @var{filename}
+@item commit [--object @var{objectdef}] [--image-opts] [-q] [-f @var{fmt}] [-t @var{cache}] [-b @var{base}] [-d] [-p] @var{filename}
 
 Commit the changes recorded in @var{filename} in its base image or backing file.
 If the backing file is smaller than the snapshot, then the backing file will be
@@ -299,7 +281,7 @@
 garbage data when read. For this reason, @code{-b} implies @code{-d} (so that
 the top image stays valid).
 
-@item compare [-f @var{fmt}] [-F @var{fmt}] [-T @var{src_cache}] [-p] [-s] [-q] @var{filename1} @var{filename2}
+@item compare [--object @var{objectdef}] [--image-opts] [-f @var{fmt}] [-F @var{fmt}] [-T @var{src_cache}] [-p] [-q] [-s] [-U] @var{filename1} @var{filename2}
 
 Check if two images have the same content. You can compare images with
 different format or settings.
@@ -340,7 +322,7 @@
 
 @end table
 
-@item convert [-c] [-p] [-n] [-f @var{fmt}] [-t @var{cache}] [-T @var{src_cache}] [-O @var{output_fmt}] [-B @var{backing_file}] [-o @var{options}] [-s @var{snapshot_id_or_name}] [-l @var{snapshot_param}] [-m @var{num_coroutines}] [-W] [-S @var{sparse_size}] @var{filename} [@var{filename2} [...]] @var{output_filename}
+@item convert [--object @var{objectdef}] [--image-opts] [--target-image-opts] [-U] [-c] [-p] [-q] [-n] [-f @var{fmt}] [-t @var{cache}] [-T @var{src_cache}] [-O @var{output_fmt}] [-B @var{backing_file}] [-o @var{options}] [-s @var{snapshot_id_or_name}] [-l @var{snapshot_param}] [-S @var{sparse_size}] [-m @var{num_coroutines}] [-W] @var{filename} [@var{filename2} [...]] @var{output_filename}
 
 Convert the disk image @var{filename} or a snapshot @var{snapshot_param}(@var{snapshot_id_or_name} is deprecated)
 to disk image @var{output_filename} using format @var{output_fmt}. It can be optionally compressed (@code{-c}
@@ -381,7 +363,31 @@
 @var{num_coroutines} specifies how many coroutines work in parallel during
 the convert process (defaults to 8).
 
-@item dd [-f @var{fmt}] [-O @var{output_fmt}] [bs=@var{block_size}] [count=@var{blocks}] [skip=@var{blocks}] if=@var{input} of=@var{output}
+@item create [--object @var{objectdef}] [-q] [-f @var{fmt}] [-b @var{backing_file}] [-F @var{backing_fmt}] [-u] [-o @var{options}] @var{filename} [@var{size}]
+
+Create the new disk image @var{filename} of size @var{size} and format
+@var{fmt}. Depending on the file format, you can add one or more @var{options}
+that enable additional features of this format.
+
+If the option @var{backing_file} is specified, then the image will record
+only the differences from @var{backing_file}. No size needs to be specified in
+this case. @var{backing_file} will never be modified unless you use the
+@code{commit} monitor command (or qemu-img commit).
+
+If a relative path name is given, the backing file is looked up relative to
+the directory containing @var{filename}.
+
+Note that a given backing file will be opened to check that it is valid. Use
+the @code{-u} option to enable unsafe backing file mode, which means that the
+image will be created even if the associated backing file cannot be opened. A
+matching backing file must be created or additional options be used to make the
+backing file specification valid when you want to use an image created this
+way.
+
+The size can also be specified using the @var{size} option with @code{-o},
+it doesn't need to be specified separately in this case.
+
+@item dd [--image-opts] [-U] [-f @var{fmt}] [-O @var{output_fmt}] [bs=@var{block_size}] [count=@var{blocks}] [skip=@var{blocks}] if=@var{input} of=@var{output}
 
 Dd copies from @var{input} file to @var{output} file converting it from
 @var{fmt} format to @var{output_fmt} format.
@@ -392,7 +398,7 @@
 
 The size syntax is similar to dd(1)'s size syntax.
 
-@item info [-f @var{fmt}] [--output=@var{ofmt}] [--backing-chain] @var{filename}
+@item info [--object @var{objectdef}] [--image-opts] [-f @var{fmt}] [--output=@var{ofmt}] [--backing-chain] [-U] @var{filename}
 
 Give information about the disk image @var{filename}. Use it in
 particular to know the size reserved on disk which can be different
@@ -500,11 +506,11 @@
 occupy with the exception of internal snapshots, dirty bitmaps, vmstate data,
 and other advanced image format features.
 
-@item snapshot [-l | -a @var{snapshot} | -c @var{snapshot} | -d @var{snapshot} ] @var{filename}
+@item snapshot [--object @var{objectdef}] [--image-opts] [-U] [-q] [-l | -a @var{snapshot} | -c @var{snapshot} | -d @var{snapshot}] @var{filename}
 
 List, apply, create or delete snapshots in image @var{filename}.
 
-@item rebase [-f @var{fmt}] [-t @var{cache}] [-T @var{src_cache}] [-p] [-u] -b @var{backing_file} [-F @var{backing_fmt}] @var{filename}
+@item rebase [--object @var{objectdef}] [--image-opts] [-U] [-q] [-f @var{fmt}] [-t @var{cache}] [-T @var{src_cache}] [-p] [-u] -b @var{backing_file} [-F @var{backing_fmt}] @var{filename}
 
 Changes the backing file of an image. Only the formats @code{qcow2} and
 @code{qed} support changing the backing file.
@@ -564,7 +570,7 @@
 At this point, @code{modified.img} can be discarded, since
 @code{base.img + diff.qcow2} contains the same information.
 
-@item resize [--shrink] [--preallocation=@var{prealloc}] @var{filename} [+ | -]@var{size}
+@item resize [--object @var{objectdef}] [--image-opts] [-f @var{fmt}] [--preallocation=@var{prealloc}] [-q] [--shrink] @var{filename} [+ | -]@var{size}
 
 Change the disk image as if it had been created with @var{size}.
 
@@ -585,10 +591,6 @@
 description in the @code{NOTES} section which values are allowed.  Using this
 option may result in slightly more data being allocated than necessary.
 
-@item amend [-p] [-f @var{fmt}] [-t @var{cache}] -o @var{options} @var{filename}
-
-Amends the image format specific @var{options} for the image file
-@var{filename}. Not all file formats support this operation.
 @end table
 @c man end
 
diff --git a/qemu-option-trace.texi b/qemu-option-trace.texi
index 4166d5c..7d1b7f0 100644
--- a/qemu-option-trace.texi
+++ b/qemu-option-trace.texi
@@ -2,9 +2,8 @@
 
 @table @option
 @item [enable=]@var{pattern}
-Immediately enable events matching @var{pattern}.
-The file must contain one event name (as listed in the @file{trace-events-all}
-file) per line; globbing patterns are accepted too.  This option is only
+Immediately enable events matching @var{pattern}
+(either event name or a globbing pattern).  This option is only
 available if QEMU has been compiled with the @var{simple}, @var{log}
 or @var{ftrace} tracing backend.  To specify multiple events or patterns,
 specify the @option{-trace} option multiple times.
diff --git a/qemu-options-wrapper.h b/qemu-options-wrapper.h
index 13bfea0..6f548e3 100644
--- a/qemu-options-wrapper.h
+++ b/qemu-options-wrapper.h
@@ -34,7 +34,6 @@
 #undef DEF
 #undef DEFHEADING
 #undef ARCHHEADING
-#undef GEN_DOCS
 
 #undef QEMU_OPTIONS_GENERATE_ENUM
 #undef QEMU_OPTIONS_GENERATE_HELP
diff --git a/slirp/arp_table.c b/slirp/arp_table.c
index 3547043..bac608f 100644
--- a/slirp/arp_table.c
+++ b/slirp/arp_table.c
@@ -33,7 +33,7 @@
     int i;
 
     DEBUG_CALL("arp_table_add");
-    DEBUG_ARG("ip = 0x%x", ip_addr);
+    DEBUG_ARG("ip = %s", inet_ntoa(*(struct in_addr *)&ip_addr));
     DEBUG_ARGS((dfd, " hw addr = %02x:%02x:%02x:%02x:%02x:%02x\n",
                 ethaddr[0], ethaddr[1], ethaddr[2],
                 ethaddr[3], ethaddr[4], ethaddr[5]));
@@ -67,7 +67,7 @@
     int i;
 
     DEBUG_CALL("arp_table_search");
-    DEBUG_ARG("ip = 0x%x", ip_addr);
+    DEBUG_ARG("ip = %s", inet_ntoa(*(struct in_addr *)&ip_addr));
 
     /* If broadcast address */
     if (ip_addr == 0xffffffff || ip_addr == broadcast_addr) {
diff --git a/slirp/socket.c b/slirp/socket.c
index cb7b5b6..61347d1 100644
--- a/slirp/socket.c
+++ b/slirp/socket.c
@@ -701,10 +701,10 @@
 	memset(&addr, 0, addrlen);
 
 	DEBUG_CALL("tcp_listen");
-	DEBUG_ARG("haddr = %x", haddr);
-	DEBUG_ARG("hport = %d", hport);
-	DEBUG_ARG("laddr = %x", laddr);
-	DEBUG_ARG("lport = %d", lport);
+	DEBUG_ARG("haddr = %s", inet_ntoa(*(struct in_addr *)&haddr));
+	DEBUG_ARG("hport = %d", ntohs(hport));
+	DEBUG_ARG("laddr = %s", inet_ntoa(*(struct in_addr *)&laddr));
+	DEBUG_ARG("lport = %d", ntohs(lport));
 	DEBUG_ARG("flags = %x", flags);
 
 	so = socreate(slirp);
diff --git a/slirp/udp.c b/slirp/udp.c
index 227d779..e5bf065 100644
--- a/slirp/udp.c
+++ b/slirp/udp.c
@@ -241,8 +241,8 @@
 	DEBUG_CALL("udp_output");
 	DEBUG_ARG("so = %p", so);
 	DEBUG_ARG("m = %p", m);
-	DEBUG_ARG("saddr = %lx", (long)saddr->sin_addr.s_addr);
-	DEBUG_ARG("daddr = %lx", (long)daddr->sin_addr.s_addr);
+	DEBUG_ARG("saddr = %s", inet_ntoa(saddr->sin_addr));
+	DEBUG_ARG("daddr = %s", inet_ntoa(daddr->sin_addr));
 
 	/*
 	 * Adjust for header
diff --git a/target/i386/hax-darwin.c b/target/i386/hax-darwin.c
index acdde47..a5426a6 100644
--- a/target/i386/hax-darwin.c
+++ b/target/i386/hax-darwin.c
@@ -257,10 +257,7 @@
 
 int hax_vcpu_run(struct hax_vcpu_state *vcpu)
 {
-    int ret;
-
-    ret = ioctl(vcpu->fd, HAX_VCPU_IOCTL_RUN, NULL);
-    return ret;
+    return ioctl(vcpu->fd, HAX_VCPU_IOCTL_RUN, NULL);
 }
 
 int hax_sync_fpu(CPUArchState *env, struct fx_layout *fl, int set)
@@ -315,13 +312,12 @@
 
 int hax_inject_interrupt(CPUArchState *env, int vector)
 {
-    int ret, fd;
+    int fd;
 
     fd = hax_vcpu_get_fd(env);
     if (fd <= 0) {
         return -1;
     }
 
-    ret = ioctl(fd, HAX_VCPU_IOCTL_INTERRUPT, &vector);
-    return ret;
+    return ioctl(fd, HAX_VCPU_IOCTL_INTERRUPT, &vector);
 }
diff --git a/target/i386/translate.c b/target/i386/translate.c
index b0f6983..7c21814 100644
--- a/target/i386/translate.c
+++ b/target/i386/translate.c
@@ -113,7 +113,7 @@
     int rex_x, rex_b;
 #endif
     int vex_l;  /* vex vector length */
-    int vex_v;  /* vex vvvv register, without 1's compliment.  */
+    int vex_v;  /* vex vvvv register, without 1's complement.  */
     int ss32;   /* 32 bit stack segment */
     CCOp cc_op;  /* current CC operation */
     bool cc_op_dirty;
diff --git a/target/m68k/translate.c b/target/m68k/translate.c
index 44a0ac4..8959e4d 100644
--- a/target/m68k/translate.c
+++ b/target/m68k/translate.c
@@ -4002,7 +4002,7 @@
     TCGv shift;
 
     /* In general, we're going to rotate the field so that it's at the
-       top of the word and then right-shift by the compliment of the
+       top of the word and then right-shift by the complement of the
        width to extend the field.  */
     if (ext & 0x20) {
         /* Variable width.  */
diff --git a/target/mips/dsp_helper.c b/target/mips/dsp_helper.c
index f152fea..739b69d 100644
--- a/target/mips/dsp_helper.c
+++ b/target/mips/dsp_helper.c
@@ -3274,14 +3274,11 @@
                             CPUMIPSState *env)
 {
     uint64_t temp[3];
-    target_ulong result;
 
     shift = shift & 0x3F;
 
     mipsdsp_rndrashift_acc(temp, ac, shift, env);
-    result = (temp[1] << 63) | (temp[0] >> 1);
-
-    return result;
+    return (temp[1] << 63) | (temp[0] >> 1);
 }
 
 target_ulong helper_dextr_r_l(target_ulong ac, target_ulong shift,
@@ -3289,7 +3286,6 @@
 {
     uint64_t temp[3];
     uint32_t temp128;
-    target_ulong result;
 
     shift = shift & 0x3F;
     mipsdsp_rndrashift_acc(temp, ac, shift, env);
@@ -3309,9 +3305,7 @@
         set_DSPControl_overflow_flag(1, 23, env);
     }
 
-    result = (temp[1] << 63) | (temp[0] >> 1);
-
-    return result;
+    return (temp[1] << 63) | (temp[0] >> 1);
 }
 
 target_ulong helper_dextr_rs_l(target_ulong ac, target_ulong shift,
@@ -3319,7 +3313,6 @@
 {
     uint64_t temp[3];
     uint32_t temp128;
-    target_ulong result;
 
     shift = shift & 0x3F;
     mipsdsp_rndrashift_acc(temp, ac, shift, env);
@@ -3345,9 +3338,7 @@
         }
         set_DSPControl_overflow_flag(1, 23, env);
     }
-    result = (temp[1] << 63) | (temp[0] >> 1);
-
-    return result;
+    return (temp[1] << 63) | (temp[0] >> 1);
 }
 #endif
 
diff --git a/target/xtensa/core-dc232b/xtensa-modules.inc.c b/target/xtensa/core-dc232b/xtensa-modules.inc.c
index d322c3f..164df3b 100644
--- a/target/xtensa/core-dc232b/xtensa-modules.inc.c
+++ b/target/xtensa/core-dc232b/xtensa-modules.inc.c
@@ -1736,9 +1736,7 @@
 static int
 Operand_arr_encode (uint32 *valp)
 {
-  int error;
-  error = (*valp & ~0xf) != 0;
-  return error;
+  return (*valp & ~0xf) != 0;
 }
 
 static int
@@ -1750,9 +1748,7 @@
 static int
 Operand_ars_encode (uint32 *valp)
 {
-  int error;
-  error = (*valp & ~0xf) != 0;
-  return error;
+  return (*valp & ~0xf) != 0;
 }
 
 static int
@@ -1764,9 +1760,7 @@
 static int
 Operand_art_encode (uint32 *valp)
 {
-  int error;
-  error = (*valp & ~0xf) != 0;
-  return error;
+  return (*valp & ~0xf) != 0;
 }
 
 static int
@@ -1778,9 +1772,7 @@
 static int
 Operand_ar0_encode (uint32 *valp)
 {
-  int error;
-  error = (*valp & ~0x1f) != 0;
-  return error;
+  return (*valp & ~0x1f) != 0;
 }
 
 static int
@@ -1792,9 +1784,7 @@
 static int
 Operand_ar4_encode (uint32 *valp)
 {
-  int error;
-  error = (*valp & ~0x1f) != 0;
-  return error;
+  return (*valp & ~0x1f) != 0;
 }
 
 static int
@@ -1806,9 +1796,7 @@
 static int
 Operand_ar8_encode (uint32 *valp)
 {
-  int error;
-  error = (*valp & ~0x1f) != 0;
-  return error;
+  return (*valp & ~0x1f) != 0;
 }
 
 static int
@@ -1820,9 +1808,7 @@
 static int
 Operand_ar12_encode (uint32 *valp)
 {
-  int error;
-  error = (*valp & ~0x1f) != 0;
-  return error;
+  return (*valp & ~0x1f) != 0;
 }
 
 static int
@@ -1834,9 +1820,7 @@
 static int
 Operand_ars_entry_encode (uint32 *valp)
 {
-  int error;
-  error = (*valp & ~0x1f) != 0;
-  return error;
+  return (*valp & ~0x1f) != 0;
 }
 
 static int
@@ -2406,9 +2390,7 @@
 static int
 Operand_mx_encode (uint32 *valp)
 {
-  int error;
-  error = (*valp & ~0x3) != 0;
-  return error;
+  return (*valp & ~0x3) != 0;
 }
 
 static int
@@ -2436,9 +2418,7 @@
 static int
 Operand_mw_encode (uint32 *valp)
 {
-  int error;
-  error = (*valp & ~0x3) != 0;
-  return error;
+  return (*valp & ~0x3) != 0;
 }
 
 static int
@@ -2450,9 +2430,7 @@
 static int
 Operand_mr0_encode (uint32 *valp)
 {
-  int error;
-  error = (*valp & ~0x3) != 0;
-  return error;
+  return (*valp & ~0x3) != 0;
 }
 
 static int
@@ -2464,9 +2442,7 @@
 static int
 Operand_mr1_encode (uint32 *valp)
 {
-  int error;
-  error = (*valp & ~0x3) != 0;
-  return error;
+  return (*valp & ~0x3) != 0;
 }
 
 static int
@@ -2478,9 +2454,7 @@
 static int
 Operand_mr2_encode (uint32 *valp)
 {
-  int error;
-  error = (*valp & ~0x3) != 0;
-  return error;
+  return (*valp & ~0x3) != 0;
 }
 
 static int
@@ -2492,9 +2466,7 @@
 static int
 Operand_mr3_encode (uint32 *valp)
 {
-  int error;
-  error = (*valp & ~0x3) != 0;
-  return error;
+  return (*valp & ~0x3) != 0;
 }
 
 static int
diff --git a/target/xtensa/core-dc233c/xtensa-modules.inc.c b/target/xtensa/core-dc233c/xtensa-modules.inc.c
index 7c20f82..0f32f08 100644
--- a/target/xtensa/core-dc233c/xtensa-modules.inc.c
+++ b/target/xtensa/core-dc233c/xtensa-modules.inc.c
@@ -1817,9 +1817,7 @@
 static int
 Operand_arr_encode (uint32 *valp)
 {
-  int error;
-  error = (*valp & ~0xf) != 0;
-  return error;
+  return (*valp & ~0xf) != 0;
 }
 
 static int
@@ -1831,9 +1829,7 @@
 static int
 Operand_ars_encode (uint32 *valp)
 {
-  int error;
-  error = (*valp & ~0xf) != 0;
-  return error;
+  return (*valp & ~0xf) != 0;
 }
 
 static int
@@ -1845,9 +1841,7 @@
 static int
 Operand_art_encode (uint32 *valp)
 {
-  int error;
-  error = (*valp & ~0xf) != 0;
-  return error;
+  return (*valp & ~0xf) != 0;
 }
 
 static int
@@ -1859,9 +1853,7 @@
 static int
 Operand_ar0_encode (uint32 *valp)
 {
-  int error;
-  error = (*valp & ~0x1f) != 0;
-  return error;
+  return (*valp & ~0x1f) != 0;
 }
 
 static int
@@ -1873,9 +1865,7 @@
 static int
 Operand_ar4_encode (uint32 *valp)
 {
-  int error;
-  error = (*valp & ~0x1f) != 0;
-  return error;
+  return (*valp & ~0x1f) != 0;
 }
 
 static int
@@ -1887,9 +1877,7 @@
 static int
 Operand_ar8_encode (uint32 *valp)
 {
-  int error;
-  error = (*valp & ~0x1f) != 0;
-  return error;
+  return (*valp & ~0x1f) != 0;
 }
 
 static int
@@ -1901,9 +1889,7 @@
 static int
 Operand_ar12_encode (uint32 *valp)
 {
-  int error;
-  error = (*valp & ~0x1f) != 0;
-  return error;
+  return (*valp & ~0x1f) != 0;
 }
 
 static int
@@ -1915,9 +1901,7 @@
 static int
 Operand_ars_entry_encode (uint32 *valp)
 {
-  int error;
-  error = (*valp & ~0x1f) != 0;
-  return error;
+  return (*valp & ~0x1f) != 0;
 }
 
 static int
@@ -2487,9 +2471,7 @@
 static int
 Operand_mx_encode (uint32 *valp)
 {
-  int error;
-  error = (*valp & ~0x3) != 0;
-  return error;
+  return (*valp & ~0x3) != 0;
 }
 
 static int
@@ -2517,9 +2499,7 @@
 static int
 Operand_mw_encode (uint32 *valp)
 {
-  int error;
-  error = (*valp & ~0x3) != 0;
-  return error;
+  return (*valp & ~0x3) != 0;
 }
 
 static int
@@ -2531,9 +2511,7 @@
 static int
 Operand_mr0_encode (uint32 *valp)
 {
-  int error;
-  error = (*valp & ~0x3) != 0;
-  return error;
+  return (*valp & ~0x3) != 0;
 }
 
 static int
@@ -2545,9 +2523,7 @@
 static int
 Operand_mr1_encode (uint32 *valp)
 {
-  int error;
-  error = (*valp & ~0x3) != 0;
-  return error;
+  return (*valp & ~0x3) != 0;
 }
 
 static int
@@ -2559,9 +2535,7 @@
 static int
 Operand_mr2_encode (uint32 *valp)
 {
-  int error;
-  error = (*valp & ~0x3) != 0;
-  return error;
+  return (*valp & ~0x3) != 0;
 }
 
 static int
@@ -2573,9 +2547,7 @@
 static int
 Operand_mr3_encode (uint32 *valp)
 {
-  int error;
-  error = (*valp & ~0x3) != 0;
-  return error;
+  return (*valp & ~0x3) != 0;
 }
 
 static int
diff --git a/target/xtensa/core-de212/xtensa-modules.inc.c b/target/xtensa/core-de212/xtensa-modules.inc.c
index ef7674d..480c68d 100644
--- a/target/xtensa/core-de212/xtensa-modules.inc.c
+++ b/target/xtensa/core-de212/xtensa-modules.inc.c
@@ -1798,9 +1798,7 @@
 static int
 OperandSem_opnd_sem_AR_encode (uint32 *valp)
 {
-  int error;
-  error = (*valp >= 32);
-  return error;
+  return (*valp >= 32);
 }
 
 static int
@@ -1812,9 +1810,7 @@
 static int
 OperandSem_opnd_sem_AR_0_encode (uint32 *valp)
 {
-  int error;
-  error = (*valp >= 32);
-  return error;
+  return (*valp >= 32);
 }
 
 static int
@@ -1826,9 +1822,7 @@
 static int
 OperandSem_opnd_sem_AR_1_encode (uint32 *valp)
 {
-  int error;
-  error = (*valp >= 32);
-  return error;
+  return (*valp >= 32);
 }
 
 static int
@@ -1840,9 +1834,7 @@
 static int
 OperandSem_opnd_sem_AR_2_encode (uint32 *valp)
 {
-  int error;
-  error = (*valp >= 32);
-  return error;
+  return (*valp >= 32);
 }
 
 static int
@@ -1854,9 +1846,7 @@
 static int
 OperandSem_opnd_sem_AR_3_encode (uint32 *valp)
 {
-  int error;
-  error = (*valp >= 32);
-  return error;
+  return (*valp >= 32);
 }
 
 static int
@@ -1868,9 +1858,7 @@
 static int
 OperandSem_opnd_sem_AR_4_encode (uint32 *valp)
 {
-  int error;
-  error = (*valp >= 32);
-  return error;
+  return (*valp >= 32);
 }
 
 static int
@@ -2464,9 +2452,7 @@
 static int
 OperandSem_opnd_sem_MR_encode (uint32 *valp)
 {
-  int error;
-  error = (*valp >= 4);
-  return error;
+  return (*valp >= 4);
 }
 
 static int
@@ -2478,9 +2464,7 @@
 static int
 OperandSem_opnd_sem_MR_1_encode (uint32 *valp)
 {
-  int error;
-  error = (*valp >= 4);
-  return error;
+  return (*valp >= 4);
 }
 
 static int
@@ -2492,9 +2476,7 @@
 static int
 OperandSem_opnd_sem_MR_2_encode (uint32 *valp)
 {
-  int error;
-  error = (*valp >= 4);
-  return error;
+  return (*valp >= 4);
 }
 
 static int
@@ -2506,9 +2488,7 @@
 static int
 OperandSem_opnd_sem_MR_3_encode (uint32 *valp)
 {
-  int error;
-  error = (*valp >= 4);
-  return error;
+  return (*valp >= 4);
 }
 
 static int
@@ -2520,9 +2500,7 @@
 static int
 OperandSem_opnd_sem_MR_4_encode (uint32 *valp)
 {
-  int error;
-  error = (*valp >= 4);
-  return error;
+  return (*valp >= 4);
 }
 
 static int
@@ -2534,9 +2512,7 @@
 static int
 OperandSem_opnd_sem_MR_5_encode (uint32 *valp)
 {
-  int error;
-  error = (*valp >= 4);
-  return error;
+  return (*valp >= 4);
 }
 
 static int
diff --git a/target/xtensa/core-fsf/xtensa-modules.inc.c b/target/xtensa/core-fsf/xtensa-modules.inc.c
index f7de2de..c32683f 100644
--- a/target/xtensa/core-fsf/xtensa-modules.inc.c
+++ b/target/xtensa/core-fsf/xtensa-modules.inc.c
@@ -1379,9 +1379,7 @@
 static int
 Operand_arr_encode (uint32 *valp)
 {
-  int error;
-  error = (*valp & ~0xf) != 0;
-  return error;
+  return (*valp & ~0xf) != 0;
 }
 
 static int
@@ -1393,9 +1391,7 @@
 static int
 Operand_ars_encode (uint32 *valp)
 {
-  int error;
-  error = (*valp & ~0xf) != 0;
-  return error;
+  return (*valp & ~0xf) != 0;
 }
 
 static int
@@ -1407,9 +1403,7 @@
 static int
 Operand_art_encode (uint32 *valp)
 {
-  int error;
-  error = (*valp & ~0xf) != 0;
-  return error;
+  return (*valp & ~0xf) != 0;
 }
 
 static int
@@ -1421,9 +1415,7 @@
 static int
 Operand_ar0_encode (uint32 *valp)
 {
-  int error;
-  error = (*valp & ~0x3f) != 0;
-  return error;
+  return (*valp & ~0x3f) != 0;
 }
 
 static int
@@ -1435,9 +1427,7 @@
 static int
 Operand_ar4_encode (uint32 *valp)
 {
-  int error;
-  error = (*valp & ~0x3f) != 0;
-  return error;
+  return (*valp & ~0x3f) != 0;
 }
 
 static int
@@ -1449,9 +1439,7 @@
 static int
 Operand_ar8_encode (uint32 *valp)
 {
-  int error;
-  error = (*valp & ~0x3f) != 0;
-  return error;
+  return (*valp & ~0x3f) != 0;
 }
 
 static int
@@ -1463,9 +1451,7 @@
 static int
 Operand_ar12_encode (uint32 *valp)
 {
-  int error;
-  error = (*valp & ~0x3f) != 0;
-  return error;
+  return (*valp & ~0x3f) != 0;
 }
 
 static int
@@ -1477,9 +1463,7 @@
 static int
 Operand_ars_entry_encode (uint32 *valp)
 {
-  int error;
-  error = (*valp & ~0x3f) != 0;
-  return error;
+  return (*valp & ~0x3f) != 0;
 }
 
 static int
diff --git a/target/xtensa/core-sample_controller/xtensa-modules.inc.c b/target/xtensa/core-sample_controller/xtensa-modules.inc.c
index fba41b9..7e87d21 100644
--- a/target/xtensa/core-sample_controller/xtensa-modules.inc.c
+++ b/target/xtensa/core-sample_controller/xtensa-modules.inc.c
@@ -1570,9 +1570,7 @@
 static int
 OperandSem_opnd_sem_AR_encode (uint32 *valp)
 {
-  int error;
-  error = (*valp >= 32);
-  return error;
+  return (*valp >= 32);
 }
 
 static int
@@ -1584,9 +1582,7 @@
 static int
 OperandSem_opnd_sem_AR_0_encode (uint32 *valp)
 {
-  int error;
-  error = (*valp >= 32);
-  return error;
+  return (*valp >= 32);
 }
 
 static int
@@ -1598,9 +1594,7 @@
 static int
 OperandSem_opnd_sem_AR_1_encode (uint32 *valp)
 {
-  int error;
-  error = (*valp >= 32);
-  return error;
+  return (*valp >= 32);
 }
 
 static int
@@ -1612,9 +1606,7 @@
 static int
 OperandSem_opnd_sem_AR_2_encode (uint32 *valp)
 {
-  int error;
-  error = (*valp >= 32);
-  return error;
+  return (*valp >= 32);
 }
 
 static int
@@ -1626,9 +1618,7 @@
 static int
 OperandSem_opnd_sem_AR_3_encode (uint32 *valp)
 {
-  int error;
-  error = (*valp >= 32);
-  return error;
+  return (*valp >= 32);
 }
 
 static int
@@ -1640,9 +1630,7 @@
 static int
 OperandSem_opnd_sem_AR_4_encode (uint32 *valp)
 {
-  int error;
-  error = (*valp >= 32);
-  return error;
+  return (*valp >= 32);
 }
 
 static int
diff --git a/target/xtensa/translate.c b/target/xtensa/translate.c
index 53f6f5d..720bc59 100644
--- a/target/xtensa/translate.c
+++ b/target/xtensa/translate.c
@@ -1272,11 +1272,8 @@
 xtensa_find_opcode_ops(const XtensaOpcodeTranslators *t,
                        const char *name)
 {
-    XtensaOpcodeOps *ops;
-
-    ops = bsearch(name, t->opcode, t->num_opcodes,
-                  sizeof(XtensaOpcodeOps), compare_opcode_ops);
-    return ops;
+    return bsearch(name, t->opcode, t->num_opcodes,
+                   sizeof(XtensaOpcodeOps), compare_opcode_ops);
 }
 
 static void translate_abs(DisasContext *dc, const uint32_t arg[],
diff --git a/tcg/README b/tcg/README
index a5237a9..d22ee08 100644
--- a/tcg/README
+++ b/tcg/README
@@ -561,7 +561,7 @@
 * orc_vec   v0, v1, v2
 * not_vec   v0, v1
 
-  Similarly, logical operations with and without compliment.
+  Similarly, logical operations with and without complement.
   Note that VECE is unused.
 
 * shli_vec   v0, v1, i2
diff --git a/tests/m48t59-test.c b/tests/m48t59-test.c
index 26af7d6..5b69597 100644
--- a/tests/m48t59-test.c
+++ b/tests/m48t59-test.c
@@ -256,8 +256,6 @@
 
 int main(int argc, char **argv)
 {
-    int ret;
-
     base_setup();
 
     g_test_init(&argc, &argv, NULL);
@@ -267,7 +265,5 @@
         qtest_add_func("/rtc/bcd-check-time", bcd_check_time);
     }
     qtest_add_func("/rtc/fuzz-registers", fuzz_registers);
-    ret = g_test_run();
-
-    return ret;
+    return g_test_run();
 }
diff --git a/tests/test-thread-pool.c b/tests/test-thread-pool.c
index 91b4ec5..9cdccb3 100644
--- a/tests/test-thread-pool.c
+++ b/tests/test-thread-pool.c
@@ -224,8 +224,6 @@
 
 int main(int argc, char **argv)
 {
-    int ret;
-
     qemu_init_main_loop(&error_abort);
     ctx = qemu_get_current_aio_context();
     pool = aio_get_thread_pool(ctx);
@@ -238,7 +236,5 @@
     g_test_add_func("/thread-pool/cancel", test_cancel);
     g_test_add_func("/thread-pool/cancel-async", test_cancel_async);
 
-    ret = g_test_run();
-
-    return ret;
+    return g_test_run();
 }
diff --git a/tests/tpm-emu.c b/tests/tpm-emu.c
index 4dada76..8c2bd53 100644
--- a/tests/tpm-emu.c
+++ b/tests/tpm-emu.c
@@ -125,7 +125,7 @@
         case CMD_SHUTDOWN: {
             ptm_res res = 0;
             qio_channel_write(ioc, (char *)&res, sizeof(res), &error_abort);
-            qio_channel_close(s->tpm_ioc, &error_abort);
+            /* the tpm data thread is expected to finish now */
             g_thread_join(s->emu_tpm_thread);
             break;
         }
diff --git a/util/uri.c b/util/uri.c
index 93ecefd..8624a7a 100644
--- a/util/uri.c
+++ b/util/uri.c
@@ -1065,10 +1065,7 @@
  */
 URI *uri_new(void)
 {
-    URI *ret;
-
-    ret = g_new0(URI, 1);
-    return ret;
+    return g_new0(URI, 1);
 }
 
 /**
diff --git a/util/vfio-helpers.c b/util/vfio-helpers.c
index 006674c..1d9272e 100644
--- a/util/vfio-helpers.c
+++ b/util/vfio-helpers.c
@@ -522,8 +522,7 @@
 
     assert(index >= 0);
     s->nr_mappings++;
-    s->mappings = g_realloc_n(s->mappings, sizeof(s->mappings[0]),
-                              s->nr_mappings);
+    s->mappings = g_renew(IOVAMapping, s->mappings, s->nr_mappings);
     insert = &s->mappings[index];
     shift = s->nr_mappings - index - 1;
     if (shift) {
@@ -577,8 +576,7 @@
     memmove(mapping, &s->mappings[index + 1],
             sizeof(s->mappings[0]) * (s->nr_mappings - index - 1));
     s->nr_mappings--;
-    s->mappings = g_realloc_n(s->mappings, sizeof(s->mappings[0]),
-                              s->nr_mappings);
+    s->mappings = g_renew(IOVAMapping, s->mappings, s->nr_mappings);
 }
 
 /* Check if the mapping list is (ascending) ordered. */
diff --git a/vl.c b/vl.c
index 3b39bbd..d5836c6 100644
--- a/vl.c
+++ b/vl.c
@@ -4011,6 +4011,10 @@
                     exit(1);
                 }
                 break;
+            case QEMU_OPTION_nodefconfig:
+            case QEMU_OPTION_nouserconfig:
+                /* Nothing to be parsed here. Especially, do not error out below. */
+                break;
             default:
                 if (os_parse_cmd_args(popt->index, optarg)) {
                     error_report("Option not supported in this build");