[libvirt] [PATCH 3/3] util: Fix fallocate stubs for mingw build

Martin Kletzander mkletzan at redhat.com
Tue Dec 16 19:13:55 UTC 2014


When any of the functions modified in commit 214c687b took false branch,
the function itself used none of its parameters resulting in "unused
parameter" error.  Rewriting these functions to the stubs we use
elsewhere should fix the problem.

Signed-off-by: Martin Kletzander <mkletzan at redhat.com>
---
 src/util/virfile.c | 38 +++++++++++++++++++++++++++++++-------
 1 file changed, 31 insertions(+), 7 deletions(-)

diff --git a/src/util/virfile.c b/src/util/virfile.c
index 4483cce..2076860 100644
--- a/src/util/virfile.c
+++ b/src/util/virfile.c
@@ -1037,36 +1037,52 @@ safewrite(int fd, const void *buf, size_t count)
     return nwritten;
 }

+#ifdef HAVE_POSIX_FALLOCATE
 static int
 safezero_posix_fallocate(int fd, off_t offset, off_t len)
 {
-#ifdef HAVE_POSIX_FALLOCATE
     int ret = posix_fallocate(fd, offset, len);
     if (ret == 0)
         return 0;
     errno = ret;
-#endif
     return -1;
 }
+#else /* !HAVE_POSIX_FALLOCATE */
+static int
+safezero_posix_fallocate(int fd ATTRIBUTE_UNUSED,
+                         off_t offset ATTRIBUTE_UNUSED,
+                         off_t len ATTRIBUTE_UNUSED)
+{
+    return -1;
+}
+#endif /* !HAVE_POSIX_FALLOCATE */

+#if HAVE_SYS_SYSCALL_H && defined(SYS_fallocate)
 static int
 safezero_sys_fallocate(int fd,
                        off_t offset,
                        off_t len)
 {
     int rc = -1;
-#if HAVE_SYS_SYSCALL_H && defined(SYS_fallocate)
     rc = syscall(SYS_fallocate, fd, 0, offset, len);
-#else
+    return rc;
+}
+#else /* !HAVE_SYS_SYSCALL_H || !defined(SYS_fallocate) */
+static int
+safezero_sys_fallocate(int fd ATTRIBUTE_UNUSED,
+                       off_t offset ATTRIBUTE_UNUSED,
+                       off_t len ATTRIBUTE_UNUSED)
+{
+    int rc = -1;
     errno = ENOSYS;
-#endif
     return rc;
 }
+#endif /* !HAVE_SYS_SYSCALL_H || !defined(SYS_fallocate) */

+#ifdef HAVE_MMAP
 static int
 safezero_mmap(int fd, off_t offset, off_t len)
 {
-#ifdef HAVE_MMAP
     int r;
     char *buf;
     static long pagemask;
@@ -1095,9 +1111,17 @@ safezero_mmap(int fd, off_t offset, off_t len)

     /* fall back to writing zeroes using safewrite if mmap fails (for
      * example because of virtual memory limits) */
-#endif /* HAVE_MMAP */
     return -1;
 }
+#else /* !HAVE_MMAP */
+static int
+safezero_mmap(int fd ATTRIBUTE_UNUSED,
+              off_t offset ATTRIBUTE_UNUSED,
+              off_t lenATTRIBUTE_UNUSED)
+{
+    return -1
+}
+#endif /* !HAVE_MMAP */

 static int
 safezero_slow(int fd, off_t offset, off_t len)
-- 
2.2.0




More information about the libvir-list mailing list