From 9bce4386e94b24fe9a8aca670c3e3b191187fd9c Mon Sep 17 00:00:00 2001 From: Martin Kletzander Date: Tue, 16 Dec 2014 20:10:20 +0100 Subject: [PATCH] util: Fix fallocate stubs for mingw build 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 --- src/util/virfile.c | 40 ++++++++++++++++++++++++++++++++-------- 1 file changed, 32 insertions(+), 8 deletions(-) diff --git a/src/util/virfile.c b/src/util/virfile.c index 4483ccee95..725b057f51 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 - errno = ENOSYS; -#endif 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; + 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)