diff options
author | Peter Maydell <peter.maydell@linaro.org> | 2014-05-07 18:38:39 +0100 |
---|---|---|
committer | Peter Maydell <peter.maydell@linaro.org> | 2014-05-07 18:38:39 +0100 |
commit | ff788b6fe67f694666781f821c1af812e8c7999b (patch) | |
tree | 147f6ba5fce34b5002551029ce84c8bed5031a72 /util | |
parent | 5894145a26afd29c077452f7e93981b797c912a5 (diff) | |
parent | 8e25c274ae5830cf879fa5d2d7f98f4d6f5aecfa (diff) | |
download | qemu-ff788b6fe67f694666781f821c1af812e8c7999b.zip qemu-ff788b6fe67f694666781f821c1af812e8c7999b.tar.gz qemu-ff788b6fe67f694666781f821c1af812e8c7999b.tar.bz2 |
Merge remote-tracking branch 'remotes/mjt/tags/trivial-patches-2014-05-07' into staging
trivial patches for 2014-05-07
# gpg: Signature made Wed 07 May 2014 18:01:15 BST using RSA key ID A4C3D7DB
# gpg: Good signature from "Michael Tokarev <mjt@tls.msk.ru>"
# gpg: aka "Michael Tokarev <mjt@corpit.ru>"
# gpg: aka "Michael Tokarev <mjt@debian.org>"
# gpg: WARNING: This key is not certified with a trusted signature!
# gpg: There is no indication that the signature belongs to the owner.
# Primary key fingerprint: 6EE1 95D1 886E 8FFB 810D 4324 457C E0A0 8044 65C5
# Subkey fingerprint: 6F67 E18E 7C91 C5B1 5514 66A7 BEE5 9D74 A4C3 D7DB
* remotes/mjt/tags/trivial-patches-2014-05-07: (21 commits)
libcacard: remove unnecessary EOL from debug prints
docs/memory.txt: Fix document on MMIO operations
readline: Sort completions before printing them.
readline: use g_strndup instead of open-coding it
qmp: report path ambiguity error
libcacard: replace pstrcpy() with memcpy()
glib: move g_poll() replacement into glib-compat.h
do not call g_thread_init() for glib >= 2.31
hw/9pfs: Add include file for exported symbol
xen: remove unused global, xen_xcg
hw: Add missing 'static' attributes
qemu-timer: Add missing 'static' attribute
ui: Add missing 'static' attribute
monitor: Add missing 'static' attribute
hw/s390x: Add missing 'static' attribute
hw/mips: Add missing 'static' and 'const' attributes
hw/9pfs: Add missing 'static' attributes
arch_init: Be sure of only one exit entry with DPRINTF() for ram_load()
tests/tcg: Fix compilation of test_path
qga: Fix typo (plural) in comment
...
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Diffstat (limited to 'util')
-rw-r--r-- | util/osdep.c | 21 | ||||
-rw-r--r-- | util/readline.c | 11 |
2 files changed, 17 insertions, 15 deletions
diff --git a/util/osdep.c b/util/osdep.c index a9029f8..b2bd154 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() */ diff --git a/util/readline.c b/util/readline.c index 8441be4..8baec55 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; @@ -279,9 +284,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); @@ -297,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; |