]> xenbits.xensource.com Git - libvirt.git/commitdiff
util: Fix fallocate stubs for mingw build
authorMartin Kletzander <mkletzan@redhat.com>
Tue, 16 Dec 2014 19:10:20 +0000 (20:10 +0100)
committerMartin Kletzander <mkletzan@redhat.com>
Tue, 16 Dec 2014 19:45:35 +0000 (20:45 +0100)
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@redhat.com>
src/util/virfile.c

index 4483ccee953afc25d2f6a5e6c3f6865b7b960427..725b057f51590a28312595f5a198b30da404a3c8 100644 (file)
@@ -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 len ATTRIBUTE_UNUSED)
+{
+    return -1
+}
+#endif /* !HAVE_MMAP */
 
 static int
 safezero_slow(int fd, off_t offset, off_t len)