From 736a83fae4e00215537e91bffdde994ad08ec049 Mon Sep 17 00:00:00 2001 From: Stefan Weil Date: Sat, 19 Nov 2016 20:22:07 +0100 Subject: Fix documentation and some comments (article, grammar) Signed-off-by: Stefan Weil Signed-off-by: Michael Tokarev --- util/uri.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'util') diff --git a/util/uri.c b/util/uri.c index 70a9cbc..21b1828 100644 --- a/util/uri.c +++ b/util/uri.c @@ -342,7 +342,7 @@ rfc3986_parse_port(URI *uri, const char **str) * @uri: pointer to an URI structure * @str: the string to analyze * - * Parse an user informations part and fills in the appropriate fields + * Parse a user information part and fill in the appropriate fields * of the @uri structure * * userinfo = *( unreserved / pct-encoded / sub-delims / ":" ) @@ -508,7 +508,7 @@ rfc3986_parse_authority(URI *uri, const char **str) cur = *str; /* - * try to parse an userinfo and check for the trailing @ + * try to parse a userinfo and check for the trailing @ */ ret = rfc3986_parse_user_info(uri, &cur); if ((ret != 0) || (*cur != '@')) -- cgit v1.1 From 4a3ecf201a1a49a804e8506df5906e446707c3b1 Mon Sep 17 00:00:00 2001 From: Cao jin Date: Wed, 2 Nov 2016 21:44:46 +0800 Subject: util/mmap-alloc: check parameter before using Signed-off-by: Cao jin Reviewed-by: Thomas Huth Signed-off-by: Michael Tokarev --- util/mmap-alloc.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'util') diff --git a/util/mmap-alloc.c b/util/mmap-alloc.c index 5a85aa3..d713a72 100644 --- a/util/mmap-alloc.c +++ b/util/mmap-alloc.c @@ -12,6 +12,7 @@ #include "qemu/osdep.h" #include "qemu/mmap-alloc.h" +#include "qemu/host-utils.h" #define HUGETLBFS_MAGIC 0x958458f6 @@ -61,18 +62,18 @@ void *qemu_ram_mmap(int fd, size_t size, size_t align, bool shared) #else void *ptr = mmap(0, total, PROT_NONE, MAP_ANONYMOUS | MAP_PRIVATE, -1, 0); #endif - size_t offset = QEMU_ALIGN_UP((uintptr_t)ptr, align) - (uintptr_t)ptr; + size_t offset; void *ptr1; if (ptr == MAP_FAILED) { return MAP_FAILED; } - /* Make sure align is a power of 2 */ - assert(!(align & (align - 1))); + assert(is_power_of_2(align)); /* Always align to host page size */ assert(align >= getpagesize()); + offset = QEMU_ALIGN_UP((uintptr_t)ptr, align) - (uintptr_t)ptr; ptr1 = mmap(ptr + offset, size, PROT_READ | PROT_WRITE, MAP_FIXED | (fd == -1 ? MAP_ANONYMOUS : 0) | -- cgit v1.1 From 6e4c890e15b23f078650499fbde11760b8eccf10 Mon Sep 17 00:00:00 2001 From: Cao jin Date: Wed, 2 Nov 2016 21:44:47 +0800 Subject: util/mmap-alloc: refactor a little bit for readability 1st mmap returns *ptr* which aligns to host page size, | size + align | ------------------------------------------ ptr input param *align* could be 1M, or 2M, or host page size. After QEMU_ALIGN_UP, offset will >= 0 2nd mmap use flag MAP_FIXED, then it return ptr+offset, or else fail. If it success, then we will have something like: | offset | size | -------------------------------------- ptr ptr1 *ptr1* is what we really want to return, it equals ptr+offset. Signed-off-by: Cao jin Signed-off-by: Michael Tokarev --- util/mmap-alloc.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) (limited to 'util') diff --git a/util/mmap-alloc.c b/util/mmap-alloc.c index d713a72..2f55f5e 100644 --- a/util/mmap-alloc.c +++ b/util/mmap-alloc.c @@ -84,22 +84,20 @@ void *qemu_ram_mmap(int fd, size_t size, size_t align, bool shared) return MAP_FAILED; } - ptr += offset; - total -= offset; - if (offset > 0) { - munmap(ptr - offset, offset); + munmap(ptr, offset); } /* * Leave a single PROT_NONE page allocated after the RAM block, to serve as * a guard page guarding against potential buffer overflows. */ + total -= offset; if (total > size + getpagesize()) { - munmap(ptr + size + getpagesize(), total - size - getpagesize()); + munmap(ptr1 + size + getpagesize(), total - size - getpagesize()); } - return ptr; + return ptr1; } void qemu_ram_munmap(void *ptr, size_t size) -- cgit v1.1 From 1706e9d819ff610154fe47ef3a195c2fd6604efe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Date: Tue, 3 Jan 2017 20:19:33 +0100 Subject: win32: use glib gpoll if glib >= 2.50 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit A fix has been committed in upstream glib commit 210a9796f78eb90f76f1bd6a304e9fea05e97617. (See also related bug https://bugzilla.gnome.org/show_bug.cgi?id=764415) It is desirable to use the glib version instead of qemu copy, since it provides more debugging facilities (G_MAIN_POLL_DEBUG etc), and hopefully has a better maintainance. Hopefully, we can drop the qemu copy in a few years. Signed-off-by: Marc-André Lureau Reviewed-by: Daniel P. Berrange Reviewed-by: Stefan Weil Signed-off-by: Michael Tokarev --- util/oslib-win32.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'util') diff --git a/util/oslib-win32.c b/util/oslib-win32.c index d09863c..0b1890f 100644 --- a/util/oslib-win32.c +++ b/util/oslib-win32.c @@ -327,6 +327,7 @@ char *qemu_get_exec_dir(void) return g_strdup(exec_dir); } +#if !GLIB_CHECK_VERSION(2, 50, 0) /* * The original implementation of g_poll from glib has a problem on Windows * when using timeouts < 10 ms. @@ -530,6 +531,7 @@ gint g_poll(GPollFD *fds, guint nfds, gint timeout) return retval; } +#endif int getpagesize(void) { -- cgit v1.1