From 4fc00556ab68fc91c6d0150152f824d262c0be12 Mon Sep 17 00:00:00 2001 From: Michael Tokarev Date: Fri, 2 May 2014 15:36:39 +0400 Subject: configure: remove bashism Commit e26110cfc67d48 added a check for shacmd to create a hash for modules. This check in configure is using bash construct &> to redirect both stdout and stderr, which does fun things on some shells. Get rid of it, use standard redirection instead. Signed-off-by: Michael Tokarev Reviewed-by: Fam Zheng --- configure | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure b/configure index 8c50d78f87..f2ee87c0d6 100755 --- a/configure +++ b/configure @@ -2624,7 +2624,7 @@ done if test "$modules" = yes; then shacmd_probe="sha1sum sha1 shasum" for c in $shacmd_probe; do - if which $c &>/dev/null; then + if which $c >/dev/null 2>&1; then shacmd="$c" break fi -- cgit v1.2.1 From 8e8be266af067277664c96670c779d8924b4d61e Mon Sep 17 00:00:00 2001 From: Stefan Weil Date: Tue, 29 Apr 2014 08:24:34 +0200 Subject: qga: Fix typo (plural) in comment Signed-off-by: Stefan Weil Signed-off-by: Michael Tokarev --- qga/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/qga/main.c b/qga/main.c index d838c3e32a..38219c9d77 100644 --- a/qga/main.c +++ b/qga/main.c @@ -1110,7 +1110,7 @@ int main(int argc, char **argv) if (ga_is_frozen(s)) { if (daemonize) { - /* delay opening/locking of pidfile till filesystem are unfrozen */ + /* delay opening/locking of pidfile till filesystems are unfrozen */ s->deferred_options.pid_filepath = pid_filepath; become_daemon(NULL); } -- cgit v1.2.1 From ad0a118fa322b39887938185911d4fb332617b5c Mon Sep 17 00:00:00 2001 From: Peter Maydell Date: Tue, 29 Apr 2014 12:09:24 +0100 Subject: tests/tcg: Fix compilation of test_path The test_path binary is (unlike the other test binaries in tests/tcg) actually intended to be compiled with the same compiler used to build the main QEMU executables. It actually #includes a number of the QEMU source files in an attempt to unit-test the util/path.c functions, and so if it is not compiled with the same compiler used by configure to set CONFIG_ settings then it is liable to fail to build. Fix the makefile to build it with the default C compiler rules, not CC_I386, and fix the test itself not to include a lot of unnecessary trace related source files which cause the build to fail if the trace backend is anything other than 'simple'. Signed-off-by: Peter Maydell Signed-off-by: Michael Tokarev --- tests/tcg/Makefile | 2 -- tests/tcg/test_path.c | 7 ------- 2 files changed, 9 deletions(-) diff --git a/tests/tcg/Makefile b/tests/tcg/Makefile index 24e3154cae..89e3342f3d 100644 --- a/tests/tcg/Makefile +++ b/tests/tcg/Makefile @@ -81,10 +81,8 @@ run-test_path: test_path # rules to compile tests test_path: test_path.o - $(CC_I386) $(LDFLAGS) -o $@ $^ $(LIBS) test_path.o: test_path.c - $(CC_I386) $(QEMU_INCLUDES) $(GLIB_CFLAGS) $(CFLAGS) -c -o $@ $^ hello-i386: hello-i386.c $(CC_I386) -nostdlib $(CFLAGS) -static $(LDFLAGS) -o $@ $< diff --git a/tests/tcg/test_path.c b/tests/tcg/test_path.c index f8dd36aab2..1c29bce263 100644 --- a/tests/tcg/test_path.c +++ b/tests/tcg/test_path.c @@ -1,17 +1,10 @@ /* Test path override code */ -#define _GNU_SOURCE #include "config-host.h" #include "util/cutils.c" #include "util/hexdump.c" #include "util/iov.c" #include "util/path.c" #include "util/qemu-timer-common.c" -#include "trace/control.c" -#include "../trace/generated-events.c" -#ifdef CONFIG_TRACE_SIMPLE -#include "trace/simple.c" -#endif - #include #include #include -- cgit v1.2.1 From 4798fe55c4d539ddf8c7f5befcddfa145b3c6102 Mon Sep 17 00:00:00 2001 From: Chen Gang Date: Thu, 1 May 2014 21:28:11 +0800 Subject: arch_init: Be sure of only one exit entry with DPRINTF() for ram_load() When DPRINTF() has effect, the original author wants to print all ram_load() calling results. So need use 'goto' instead of 'return' within ram_load(), just like other areas have done. Signed-off-by: Chen Gang Signed-off-by: Michael Tokarev --- arch_init.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/arch_init.c b/arch_init.c index be743fd1d0..995f56d504 100644 --- a/arch_init.c +++ b/arch_init.c @@ -1036,7 +1036,8 @@ static int ram_load(QEMUFile *f, void *opaque, int version_id) seq_iter++; if (version_id != 4) { - return -EINVAL; + ret = -EINVAL; + goto done; } do { @@ -1091,7 +1092,8 @@ static int ram_load(QEMUFile *f, void *opaque, int version_id) host = host_from_stream_offset(f, addr, flags); if (!host) { - return -EINVAL; + ret = -EINVAL; + goto done; } ch = qemu_get_byte(f); @@ -1101,14 +1103,16 @@ static int ram_load(QEMUFile *f, void *opaque, int version_id) host = host_from_stream_offset(f, addr, flags); if (!host) { - return -EINVAL; + ret = -EINVAL; + goto done; } qemu_get_buffer(f, host, TARGET_PAGE_SIZE); } else if (flags & RAM_SAVE_FLAG_XBZRLE) { void *host = host_from_stream_offset(f, addr, flags); if (!host) { - return -EINVAL; + ret = -EINVAL; + goto done; } if (load_xbzrle(f, addr, host) < 0) { -- cgit v1.2.1 From f5a014d2368b7a309cafc724e36089ab9e2af8c2 Mon Sep 17 00:00:00 2001 From: Stefan Weil Date: Fri, 2 May 2014 22:22:57 +0200 Subject: hw/9pfs: Add missing 'static' attributes Signed-off-by: Stefan Weil Signed-off-by: Michael Tokarev --- hw/9pfs/virtio-9p-synth.c | 2 +- hw/core/qdev.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/hw/9pfs/virtio-9p-synth.c b/hw/9pfs/virtio-9p-synth.c index 840e4ebb5a..71262bccd2 100644 --- a/hw/9pfs/virtio-9p-synth.c +++ b/hw/9pfs/virtio-9p-synth.c @@ -21,7 +21,7 @@ #include /* Root node for synth file system */ -V9fsSynthNode v9fs_synth_root = { +static V9fsSynthNode v9fs_synth_root = { .name = "/", .actual_attr = { .mode = 0555 | S_IFDIR, diff --git a/hw/core/qdev.c b/hw/core/qdev.c index 2fd5100522..936eae6412 100644 --- a/hw/core/qdev.c +++ b/hw/core/qdev.c @@ -660,8 +660,8 @@ static void qdev_get_legacy_property(Object *obj, Visitor *v, void *opaque, * Legacy properties are string versions of other OOM properties. The format * of the string depends on the property type. */ -void qdev_property_add_legacy(DeviceState *dev, Property *prop, - Error **errp) +static void qdev_property_add_legacy(DeviceState *dev, Property *prop, + Error **errp) { gchar *name; -- cgit v1.2.1 From f73cdbc6acdb85f5fdb42a75121d0c97e00663ac Mon Sep 17 00:00:00 2001 From: Stefan Weil Date: Fri, 2 May 2014 22:29:33 +0200 Subject: hw/mips: Add missing 'static' and 'const' attributes This fixes a warning from the static code analysis (smatch). Signed-off-by: Stefan Weil Signed-off-by: Michael Tokarev Acked-by: Aurelien Jarno --- hw/mips/mips_fulong2e.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/mips/mips_fulong2e.c b/hw/mips/mips_fulong2e.c index e1551aabe2..30d9f19df7 100644 --- a/hw/mips/mips_fulong2e.c +++ b/hw/mips/mips_fulong2e.c @@ -211,7 +211,7 @@ static void main_cpu_reset(void *opaque) } } -uint8_t eeprom_spd[0x80] = { +static const uint8_t eeprom_spd[0x80] = { 0x80,0x08,0x07,0x0d,0x09,0x02,0x40,0x00,0x04,0x70, 0x70,0x00,0x82,0x10,0x00,0x01,0x0e,0x04,0x0c,0x01, 0x02,0x20,0x80,0x75,0x70,0x00,0x00,0x50,0x3c,0x50, -- cgit v1.2.1 From bfaaad02814b1f4e86eb4ba1978a93a6dccd1e7d Mon Sep 17 00:00:00 2001 From: Stefan Weil Date: Fri, 2 May 2014 22:39:12 +0200 Subject: hw/s390x: Add missing 'static' attribute Signed-off-by: Stefan Weil Signed-off-by: Michael Tokarev --- hw/s390x/event-facility.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/s390x/event-facility.c b/hw/s390x/event-facility.c index 0777a93916..2e9e62fe1f 100644 --- a/hw/s390x/event-facility.c +++ b/hw/s390x/event-facility.c @@ -32,7 +32,7 @@ struct SCLPEventFacility { unsigned int receive_mask; }; -SCLPEvent cpu_hotplug; +static SCLPEvent cpu_hotplug; /* return true if any child has event pending set */ static bool event_pending(SCLPEventFacility *ef) -- cgit v1.2.1 From 79f320246c8ee972e4b3469027492533fca178d8 Mon Sep 17 00:00:00 2001 From: Stefan Weil Date: Fri, 2 May 2014 22:43:57 +0200 Subject: monitor: Add missing 'static' attribute This fixes a warning from the static code analysis (smatch). Signed-off-by: Stefan Weil Signed-off-by: Michael Tokarev --- monitor.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/monitor.c b/monitor.c index 1266ba06fb..2d3fb3f0ef 100644 --- a/monitor.c +++ b/monitor.c @@ -488,7 +488,7 @@ static const char *monitor_event_names[] = { }; QEMU_BUILD_BUG_ON(ARRAY_SIZE(monitor_event_names) != QEVENT_MAX) -MonitorEventState monitor_event_state[QEVENT_MAX]; +static MonitorEventState monitor_event_state[QEVENT_MAX]; /* * Emits the event to every monitor instance -- cgit v1.2.1 From 6075137d949e078744b332ba2279348bff64bf83 Mon Sep 17 00:00:00 2001 From: Stefan Weil Date: Fri, 2 May 2014 22:48:30 +0200 Subject: ui: Add missing 'static' attribute There was already a forward declaration using 'static', but the attribute was missing in the implementation. This fixes a warning from the static code analysis (smatch). Signed-off-by: Stefan Weil Signed-off-by: Michael Tokarev --- ui/console.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ui/console.c b/ui/console.c index e057755c04..34d1eaa955 100644 --- a/ui/console.c +++ b/ui/console.c @@ -1407,7 +1407,7 @@ void dpy_gfx_replace_surface(QemuConsole *con, qemu_free_displaysurface(old_surface); } -void dpy_refresh(DisplayState *s) +static void dpy_refresh(DisplayState *s) { DisplayChangeListener *dcl; -- cgit v1.2.1 From fbdb664cb69730d043e7eb3b89db1cc8b419080f Mon Sep 17 00:00:00 2001 From: Stefan Weil Date: Sat, 3 May 2014 08:12:15 +0200 Subject: qemu-timer: Add missing 'static' attribute This fixes a warning from the static code analysis (smatch). Signed-off-by: Stefan Weil Signed-off-by: Michael Tokarev --- qemu-timer.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/qemu-timer.c b/qemu-timer.c index e15ce477cc..9be1a4131d 100644 --- a/qemu-timer.c +++ b/qemu-timer.c @@ -56,7 +56,7 @@ typedef struct QEMUClock { } QEMUClock; QEMUTimerListGroup main_loop_tlg; -QEMUClock qemu_clocks[QEMU_CLOCK_MAX]; +static QEMUClock qemu_clocks[QEMU_CLOCK_MAX]; /* A QEMUTimerList is a list of timers attached to a clock. More * than one QEMUTimerList can be attached to each clock, for instance -- cgit v1.2.1 From 6a0a70b0f51001ca86a9671ef6b6352f537c2d64 Mon Sep 17 00:00:00 2001 From: Stefan Weil Date: Fri, 2 May 2014 22:34:40 +0200 Subject: hw: Add missing 'static' attributes This fixes warnings from the static code analysis (smatch). Signed-off-by: Stefan Weil Signed-off-by: Michael Tokarev --- hw/net/cadence_gem.c | 2 +- hw/net/vmxnet3.c | 6 +++--- hw/net/xgmac.c | 2 +- hw/ppc/spapr_iommu.c | 2 +- hw/ppc/spapr_rtas.c | 2 +- hw/scsi/scsi-bus.c | 2 +- 6 files changed, 8 insertions(+), 8 deletions(-) diff --git a/hw/net/cadence_gem.c b/hw/net/cadence_gem.c index e34b25e734..cdb18253b6 100644 --- a/hw/net/cadence_gem.c +++ b/hw/net/cadence_gem.c @@ -388,7 +388,7 @@ typedef struct GemState { } GemState; /* The broadcast MAC address: 0xFFFFFFFFFFFF */ -const uint8_t broadcast_addr[] = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF }; +static const uint8_t broadcast_addr[] = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF }; /* * gem_init_register_masks: diff --git a/hw/net/vmxnet3.c b/hw/net/vmxnet3.c index ddcee4bd21..1bb9259df2 100644 --- a/hw/net/vmxnet3.c +++ b/hw/net/vmxnet3.c @@ -2305,7 +2305,7 @@ static void vmxnet3_put_txq_descr(QEMUFile *f, void *pv, size_t size) vmxnet3_put_tx_stats_to_file(f, &r->txq_stats); } -const VMStateInfo txq_descr_info = { +static const VMStateInfo txq_descr_info = { .name = "txq_descr", .get = vmxnet3_get_txq_descr, .put = vmxnet3_put_txq_descr @@ -2397,7 +2397,7 @@ static int vmxnet3_post_load(void *opaque, int version_id) return 0; } -const VMStateInfo rxq_descr_info = { +static const VMStateInfo rxq_descr_info = { .name = "rxq_descr", .get = vmxnet3_get_rxq_descr, .put = vmxnet3_put_rxq_descr @@ -2423,7 +2423,7 @@ static void vmxnet3_put_int_state(QEMUFile *f, void *pv, size_t size) qemu_put_byte(f, r->is_asserted); } -const VMStateInfo int_state_info = { +static const VMStateInfo int_state_info = { .name = "int_state", .get = vmxnet3_get_int_state, .put = vmxnet3_put_int_state diff --git a/hw/net/xgmac.c b/hw/net/xgmac.c index 9384fa0c5c..88349ac6a2 100644 --- a/hw/net/xgmac.c +++ b/hw/net/xgmac.c @@ -152,7 +152,7 @@ typedef struct XgmacState { uint32_t regs[R_MAX]; } XgmacState; -const VMStateDescription vmstate_rxtx_stats = { +static const VMStateDescription vmstate_rxtx_stats = { .name = "xgmac_stats", .version_id = 1, .minimum_version_id = 1, diff --git a/hw/ppc/spapr_iommu.c b/hw/ppc/spapr_iommu.c index d9fe946818..72493d802a 100644 --- a/hw/ppc/spapr_iommu.c +++ b/hw/ppc/spapr_iommu.c @@ -35,7 +35,7 @@ enum sPAPRTCEAccess { SPAPR_TCE_RW = 3, }; -QLIST_HEAD(spapr_tce_tables, sPAPRTCETable) spapr_tce_tables; +static QLIST_HEAD(spapr_tce_tables, sPAPRTCETable) spapr_tce_tables; static sPAPRTCETable *spapr_tce_find_by_liobn(uint32_t liobn) { diff --git a/hw/ppc/spapr_rtas.c b/hw/ppc/spapr_rtas.c index 73860d0486..ea4a2b2698 100644 --- a/hw/ppc/spapr_rtas.c +++ b/hw/ppc/spapr_rtas.c @@ -272,7 +272,7 @@ static struct rtas_call { spapr_rtas_fn fn; } rtas_table[TOKEN_MAX]; -struct rtas_call *rtas_next = rtas_table; +static struct rtas_call *rtas_next = rtas_table; target_ulong spapr_rtas_call(PowerPCCPU *cpu, sPAPREnvironment *spapr, uint32_t token, uint32_t nargs, target_ulong args, diff --git a/hw/scsi/scsi-bus.c b/hw/scsi/scsi-bus.c index ae921a6a75..abe73022c0 100644 --- a/hw/scsi/scsi-bus.c +++ b/hw/scsi/scsi-bus.c @@ -1179,7 +1179,7 @@ static uint64_t scsi_cmd_lba(SCSICommand *cmd) return lba; } -int scsi_req_parse(SCSICommand *cmd, SCSIDevice *dev, uint8_t *buf) +static int scsi_req_parse(SCSICommand *cmd, SCSIDevice *dev, uint8_t *buf) { int rc; -- cgit v1.2.1 From 770e39f743e9070964a78903950348af67cd0788 Mon Sep 17 00:00:00 2001 From: Jim Meyering Date: Sat, 3 May 2014 08:04:40 +0200 Subject: xen: remove unused global, xen_xcg Reviewed-by: Stefan Weil Signed-off-by: Jim Meyering Acked-by: Stefano Stabellini Signed-off-by: Michael Tokarev --- hw/xen/xen_backend.c | 1 - 1 file changed, 1 deletion(-) diff --git a/hw/xen/xen_backend.c b/hw/xen/xen_backend.c index 197795ffe1..3cd45b407c 100644 --- a/hw/xen/xen_backend.c +++ b/hw/xen/xen_backend.c @@ -45,7 +45,6 @@ /* public */ XenXC xen_xc = XC_HANDLER_INITIAL_VALUE; -XenGnttab xen_xcg = XC_HANDLER_INITIAL_VALUE; struct xs_handle *xenstore = NULL; const char *xen_protocol; -- cgit v1.2.1 From 69b15212d761889b2768b654f09a0eac78951674 Mon Sep 17 00:00:00 2001 From: Stefan Weil Date: Fri, 2 May 2014 22:22:32 +0200 Subject: hw/9pfs: Add include file for exported symbol Signed-off-by: Stefan Weil Signed-off-by: Michael Tokarev --- hw/9pfs/virtio-9p-local.c | 1 + 1 file changed, 1 insertion(+) diff --git a/hw/9pfs/virtio-9p-local.c b/hw/9pfs/virtio-9p-local.c index 56b302c122..3b0b6a9b1d 100644 --- a/hw/9pfs/virtio-9p-local.c +++ b/hw/9pfs/virtio-9p-local.c @@ -14,6 +14,7 @@ #include "hw/virtio/virtio.h" #include "virtio-9p.h" #include "virtio-9p-xattr.h" +#include "fsdev/qemu-fsdev.h" /* local_ops */ #include #include #include -- cgit v1.2.1 From f33cc84dd4af7776309d118412df008ec4108a57 Mon Sep 17 00:00:00 2001 From: Michael Tokarev Date: Fri, 2 May 2014 18:35:55 +0400 Subject: do not call g_thread_init() for glib >= 2.31 glib >= 2.31 always enables thread support and g_thread_supported() is #defined to 1, there's no need to call g_thread_init() anymore, and it definitely does not need to report error which never happens. Keep code for old < 2.31 glibc anyway for now, just #ifdef it differently. Signed-off-by: Michael Tokarev Reviewed-by: Stefan Hajnoczi Cc: qemu-trivial@nongnu.org --- coroutine-gthread.c | 7 ++----- util/osdep.c | 21 +++++++++------------ 2 files changed, 11 insertions(+), 17 deletions(-) diff --git a/coroutine-gthread.c b/coroutine-gthread.c index d3e5b991f7..a61efe01dc 100644 --- a/coroutine-gthread.c +++ b/coroutine-gthread.c @@ -115,14 +115,11 @@ static inline GThread *create_thread(GThreadFunc func, gpointer data) static void __attribute__((constructor)) coroutine_init(void) { - if (!g_thread_supported()) { #if !GLIB_CHECK_VERSION(2, 31, 0) + if (!g_thread_supported()) { g_thread_init(NULL); -#else - fprintf(stderr, "glib threading failed to initialize.\n"); - exit(1); -#endif } +#endif init_coroutine_cond(); } diff --git a/util/osdep.c b/util/osdep.c index a9029f8894..b2bd1542c5 100644 --- a/util/osdep.c +++ b/util/osdep.c @@ -436,23 +436,20 @@ int socket_init(void) return 0; } -/* Ensure that glib is running in multi-threaded mode */ +#if !GLIB_CHECK_VERSION(2, 31, 0) +/* Ensure that glib is running in multi-threaded mode + * Old versions of glib require explicit initialization. Failure to do + * this results in the single-threaded code paths being taken inside + * glib. For example, the g_slice allocator will not be thread-safe + * and cause crashes. + */ static void __attribute__((constructor)) thread_init(void) { if (!g_thread_supported()) { -#if !GLIB_CHECK_VERSION(2, 31, 0) - /* Old versions of glib require explicit initialization. Failure to do - * this results in the single-threaded code paths being taken inside - * glib. For example, the g_slice allocator will not be thread-safe - * and cause crashes. - */ - g_thread_init(NULL); -#else - fprintf(stderr, "glib threading failed to initialize.\n"); - exit(1); -#endif + g_thread_init(NULL); } } +#endif #ifndef CONFIG_IOVEC /* helper function for iov_send_recv() */ -- cgit v1.2.1 From f95c967a7950797109d2a96fcfa2e3a2899f2c99 Mon Sep 17 00:00:00 2001 From: Stefan Hajnoczi Date: Fri, 2 May 2014 18:35:56 +0400 Subject: glib: move g_poll() replacement into glib-compat.h We have a dedicated header file for wrappers to smooth over glib version differences. Move the g_poll() definition into glib-compat.h for consistency. Signed-off-by: Stefan Hajnoczi Signed-off-by: Michael Tokarev Cc: qemu-trivial@nongnu.org --- include/glib-compat.h | 12 ++++++++++++ include/qemu-common.h | 12 ------------ 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/include/glib-compat.h b/include/glib-compat.h index 8aa77afd62..8d25900700 100644 --- a/include/glib-compat.h +++ b/include/glib-compat.h @@ -24,4 +24,16 @@ static inline guint g_timeout_add_seconds(guint interval, GSourceFunc function, } #endif +#if !GLIB_CHECK_VERSION(2, 20, 0) +/* + * Glib before 2.20.0 doesn't implement g_poll, so wrap it to compile properly + * on older systems. + */ +static inline gint g_poll(GPollFD *fds, guint nfds, gint timeout) +{ + GMainContext *ctx = g_main_context_default(); + return g_main_context_get_poll_func(ctx)(fds, nfds, timeout); +} +#endif + #endif diff --git a/include/qemu-common.h b/include/qemu-common.h index a998e8d36c..3f3fd60f5b 100644 --- a/include/qemu-common.h +++ b/include/qemu-common.h @@ -124,18 +124,6 @@ int qemu_main(int argc, char **argv, char **envp); void qemu_get_timedate(struct tm *tm, int offset); int qemu_timedate_diff(struct tm *tm); -#if !GLIB_CHECK_VERSION(2, 20, 0) -/* - * Glib before 2.20.0 doesn't implement g_poll, so wrap it to compile properly - * on older systems. - */ -static inline gint g_poll(GPollFD *fds, guint nfds, gint timeout) -{ - GMainContext *ctx = g_main_context_default(); - return g_main_context_get_poll_func(ctx)(fds, nfds, timeout); -} -#endif - /** * is_help_option: * @s: string to test -- cgit v1.2.1 From a22f8f38942623dc473bf5ced5b4117b8bdf4821 Mon Sep 17 00:00:00 2001 From: Michael Tokarev Date: Fri, 2 May 2014 18:35:59 +0400 Subject: libcacard: replace pstrcpy() with memcpy() Commit 2e679780ae86c6ca8 replaced strncpy() with pstrcpy() in one place in libcacard. This is a qemu-specific function, while libcacard is a stand-alone library (or tries to be). But since we know the exact length of the string to copy, and know that it definitely will fit in the destination buffer, use memcpy() instead, and null-terminate the string after that. An alternative is to use g_strlcpy() or strncpy(), but memcpy() is more than adequate in this place. Signed-off-by: Michael Tokarev Cc: qemu-trivial@nongnu.org Cc: Alon Levy --- libcacard/vcard_emul_nss.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libcacard/vcard_emul_nss.c b/libcacard/vcard_emul_nss.c index ee2dfaee82..e2b196d8c5 100644 --- a/libcacard/vcard_emul_nss.c +++ b/libcacard/vcard_emul_nss.c @@ -1162,7 +1162,8 @@ vcard_emul_options(const char *args) NEXT_TOKEN(vname) NEXT_TOKEN(type_params) type_params_length = MIN(type_params_length, sizeof(type_str)-1); - pstrcpy(type_str, type_params_length, type_params); + memcpy(type_str, type_params, type_params_length); + type_str[type_params_length] = '\0'; type = vcard_emul_type_from_string(type_str); NEXT_TOKEN(type_params) -- cgit v1.2.1 From 797720876a5c24dd6adb3c2d6e0c872ac3b35c11 Mon Sep 17 00:00:00 2001 From: Michael Tokarev Date: Sun, 4 May 2014 12:23:59 +0400 Subject: qmp: report path ambiguity error Without this, ambiguous path is reported to the user as "not found", which is confusing at least. Signed-off-by: Michael Tokarev --- qmp.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/qmp.c b/qmp.c index c4836dfb6c..233325dd7e 100644 --- a/qmp.c +++ b/qmp.c @@ -200,7 +200,11 @@ ObjectPropertyInfoList *qmp_qom_list(const char *path, Error **errp) obj = object_resolve_path(path, &ambiguous); if (obj == NULL) { - error_set(errp, QERR_DEVICE_NOT_FOUND, path); + if (ambiguous) { + error_setg(errp, "Path '%s' is ambiguous", path); + } else { + error_set(errp, QERR_DEVICE_NOT_FOUND, path); + } return NULL; } -- cgit v1.2.1 From 6ad7c326a1b62a71a83b46de79b8d8391bb768ff Mon Sep 17 00:00:00 2001 From: Michael Tokarev Date: Mon, 5 May 2014 13:23:50 +0400 Subject: readline: use g_strndup instead of open-coding it MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Michael Tokarev Reviewed-by: Andreas Färber --- util/readline.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/util/readline.c b/util/readline.c index 8441be484c..a3fd2cb466 100644 --- a/util/readline.c +++ b/util/readline.c @@ -279,9 +279,7 @@ static void readline_completion(ReadLineState *rs) rs->nb_completions = 0; - cmdline = g_malloc(rs->cmd_buf_index + 1); - memcpy(cmdline, rs->cmd_buf, rs->cmd_buf_index); - cmdline[rs->cmd_buf_index] = '\0'; + cmdline = g_strndup(rs->cmd_buf, rs->cmd_buf_index); rs->completion_finder(rs->opaque, cmdline); g_free(cmdline); -- cgit v1.2.1 From 307b2f01488ae0fab18a8f0538e7c750842e74dd Mon Sep 17 00:00:00 2001 From: Hani Benhabiles Date: Thu, 1 May 2014 15:26:42 +0100 Subject: readline: Sort completions before printing them. Signed-off-by: Hani Benhabiles Signed-off-by: Michael Tokarev --- util/readline.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/util/readline.c b/util/readline.c index a3fd2cb466..8baec55509 100644 --- a/util/readline.c +++ b/util/readline.c @@ -272,6 +272,11 @@ void readline_set_completion_index(ReadLineState *rs, int index) rs->completion_index = index; } +static int completion_comp(const void *a, const void *b) +{ + return strcmp(*(const char **) a, *(const char **) b); +} + static void readline_completion(ReadLineState *rs) { int len, i, j, max_width, nb_cols, max_prefix; @@ -295,6 +300,8 @@ static void readline_completion(ReadLineState *rs) if (len > 0 && rs->completions[0][len - 1] != '/') readline_insert_char(rs, ' '); } else { + qsort(rs->completions, rs->nb_completions, sizeof(char *), + completion_comp); rs->printf_func(rs->opaque, "\n"); max_width = 0; max_prefix = 0; -- cgit v1.2.1 From edc1ba7a7a13b1c721f2a7791ff809633d85fb9b Mon Sep 17 00:00:00 2001 From: Fam Zheng Date: Mon, 5 May 2014 15:53:41 +0800 Subject: docs/memory.txt: Fix document on MMIO operations .impl.valid should be .impl.unaligned and the description needs some fixes. .old_portio is removed since commit b40acf99b (ioport: Switch dispatching to memory core layer). Signed-off-by: Fam Zheng Signed-off-by: Michael Tokarev --- docs/memory.txt | 10 +++++----- include/exec/memory.h | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/docs/memory.txt b/docs/memory.txt index 22eaec780e..5bdbdb3691 100644 --- a/docs/memory.txt +++ b/docs/memory.txt @@ -232,8 +232,8 @@ various constraints can be supplied to control how these callbacks are called: (in bytes) supported by the *implementation*; other access sizes will be emulated using the ones available. For example a 4-byte write will be emulated using four 1-byte writes, if .impl.max_access_size = 1. - - .impl.valid specifies that the *implementation* only supports unaligned - accesses; unaligned accesses will be emulated by two aligned accesses. - - .old_portio and .old_mmio can be used to ease porting from code using - cpu_register_io_memory() and register_ioport(). They should not be used - in new code. + - .impl.unaligned specifies that the *implementation* supports unaligned + accesses; if false, unaligned accesses will be emulated by two aligned + accesses. + - .old_mmio can be used to ease porting from code using + cpu_register_io_memory(). It should not be used in new code. diff --git a/include/exec/memory.h b/include/exec/memory.h index c084db2d9d..1d55ad94a4 100644 --- a/include/exec/memory.h +++ b/include/exec/memory.h @@ -110,7 +110,7 @@ struct MemoryRegionOps { /* If true, unaligned accesses are supported. Otherwise all accesses * are converted to (possibly multiple) naturally aligned accesses. */ - bool unaligned; + bool unaligned; } impl; /* If .read and .write are not present, old_mmio may be used for -- cgit v1.2.1 From 8e25c274ae5830cf879fa5d2d7f98f4d6f5aecfa Mon Sep 17 00:00:00 2001 From: Alon Levy Date: Mon, 5 May 2014 17:41:32 +0300 Subject: libcacard: remove unnecessary EOL from debug prints Signed-off-by: Alon Levy Signed-off-by: Michael Tokarev --- libcacard/vreader.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libcacard/vreader.c b/libcacard/vreader.c index 5793d73ff5..77202951fb 100644 --- a/libcacard/vreader.c +++ b/libcacard/vreader.c @@ -273,12 +273,12 @@ vreader_xfr_bytes(VReader *reader, response = vcard_make_response(status); card_status = VCARD_DONE; } else { - g_debug("%s: CLS=0x%x,INS=0x%x,P1=0x%x,P2=0x%x,Lc=%d,Le=%d %s\n", + g_debug("%s: CLS=0x%x,INS=0x%x,P1=0x%x,P2=0x%x,Lc=%d,Le=%d %s", __func__, apdu->a_cla, apdu->a_ins, apdu->a_p1, apdu->a_p2, apdu->a_Lc, apdu->a_Le, apdu_ins_to_string(apdu->a_ins)); card_status = vcard_process_apdu(card, apdu, &response); if (response) { - g_debug("%s: status=%d sw1=0x%x sw2=0x%x len=%d (total=%d)\n", + g_debug("%s: status=%d sw1=0x%x sw2=0x%x len=%d (total=%d)", __func__, response->b_status, response->b_sw1, response->b_sw2, response->b_len, response->b_total_len); } -- cgit v1.2.1