qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH v6 07/33] util: introduce qemu_file_get_page_siz


From: Xiao Guangrong
Subject: Re: [Qemu-devel] [PATCH v6 07/33] util: introduce qemu_file_get_page_size()
Date: Sat, 31 Oct 2015 16:25:52 +0800
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.3.0



On 10/30/2015 11:54 PM, Eduardo Habkost wrote:
On Fri, Oct 30, 2015 at 01:56:01PM +0800, Xiao Guangrong wrote:
There are three places use the some logic to get the page size on
the file path or file fd

This patch introduces qemu_file_get_page_size() to unify the code

Signed-off-by: Xiao Guangrong <address@hidden>
[...]
diff --git a/util/oslib-posix.c b/util/oslib-posix.c
index 914cef5..ad94c5a 100644
--- a/util/oslib-posix.c
+++ b/util/oslib-posix.c
@@ -360,6 +360,22 @@ static size_t fd_getpagesize(int fd)
      return getpagesize();
  }

+size_t qemu_file_get_page_size(const char *path)
+{
+    size_t size = 0;
+    int fd = qemu_open(path, O_RDONLY);
+
+    if (fd < 0) {
+        fprintf(stderr, "Could not open %s.\n", path);
+        goto exit;

Have you considered using a Error** argument here?

No.

But it looks it a good way to detect error by check if Error
is NULL. Will use it. :)




reply via email to

[Prev in Thread] Current Thread [Next in Thread]