* [PATCH] fallocate: avoid preprocessor token redefinitions
@ 2014-01-07 22:04 Sami Kerola
2014-01-13 13:56 ` Karel Zak
0 siblings, 1 reply; 2+ messages in thread
From: Sami Kerola @ 2014-01-07 22:04 UTC (permalink / raw)
To: util-linux; +Cc: kerolasa
The FALLOC_FL_KEEP_SIZE and FALLOC_FL_PUNCH_HOLE are part of
bits/fcntl-linux.h, and one should prefer use of libc rather than
kernel header linux/falloc.h when possible.
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
---
sys-utils/fallocate.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/sys-utils/fallocate.c b/sys-utils/fallocate.c
index 6a87673..9fa1e58 100644
--- a/sys-utils/fallocate.c
+++ b/sys-utils/fallocate.c
@@ -36,8 +36,10 @@
# include <sys/syscall.h>
#endif
-#ifdef HAVE_LINUX_FALLOC_H
-# include <linux/falloc.h> /* for FALLOC_FL_* flags */
+#ifndef HAVE_LINUX_FALLOC_H
+# ifndef FALLOC_FL_KEEP_SIZE /* FALLOC_FL_* should be part of */
+# include <linux/falloc.h> /* bits/fcntl-linux.h that is */
+# endif /* included by fcntl.h */
#endif
#ifndef FALLOC_FL_KEEP_SIZE
--
1.8.5.2
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] fallocate: avoid preprocessor token redefinitions
2014-01-07 22:04 [PATCH] fallocate: avoid preprocessor token redefinitions Sami Kerola
@ 2014-01-13 13:56 ` Karel Zak
0 siblings, 0 replies; 2+ messages in thread
From: Karel Zak @ 2014-01-13 13:56 UTC (permalink / raw)
To: Sami Kerola; +Cc: util-linux
On Tue, Jan 07, 2014 at 10:04:59PM +0000, Sami Kerola wrote:
> The FALLOC_FL_KEEP_SIZE and FALLOC_FL_PUNCH_HOLE are part of
> bits/fcntl-linux.h, and one should prefer use of libc rather than
> kernel header linux/falloc.h when possible.
>
> Signed-off-by: Sami Kerola <kerolasa@iki.fi>
> ---
> sys-utils/fallocate.c | 6 ++++--
> 1 file changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/sys-utils/fallocate.c b/sys-utils/fallocate.c
> index 6a87673..9fa1e58 100644
> --- a/sys-utils/fallocate.c
> +++ b/sys-utils/fallocate.c
> @@ -36,8 +36,10 @@
> # include <sys/syscall.h>
> #endif
>
> -#ifdef HAVE_LINUX_FALLOC_H
> -# include <linux/falloc.h> /* for FALLOC_FL_* flags */
> +#ifndef HAVE_LINUX_FALLOC_H
^^^^^
> +# ifndef FALLOC_FL_KEEP_SIZE /* FALLOC_FL_* should be part of */
> +# include <linux/falloc.h> /* bits/fcntl-linux.h that is */
> +# endif /* included by fcntl.h */
> #endif
Maybe I read the patch incorrectly, but you're trying to include
<linux/falloc.h> when HAVE_LINUX_FALLOC_H is undefined :-)
I have applied the patch below.
Karel
commit bc5ddf0c0011d1ffc21e29cef9d07420013697b0
Author: Karel Zak <kzak@redhat.com>
Date: Mon Jan 13 14:53:18 2014 +0100
fallocate: prefer FALLOC_FL_* flags from libc headers
Reported-by: Sami Kerola <kerolasa@iki.fi>
Signed-off-by: Karel Zak <kzak@redhat.com>
diff --git a/sys-utils/fallocate.c b/sys-utils/fallocate.c
index 6a87673..cd35b2d 100644
--- a/sys-utils/fallocate.c
+++ b/sys-utils/fallocate.c
@@ -36,8 +36,9 @@
# include <sys/syscall.h>
#endif
-#ifdef HAVE_LINUX_FALLOC_H
-# include <linux/falloc.h> /* for FALLOC_FL_* flags */
+#if defined(HAVE_LINUX_FALLOC_H) && \
+ (!defined(FALLOC_FL_KEEP_SIZE) || !defined(FALLOC_FL_PUNCH_HOLE))
+# include <linux/falloc.h> /* non-libc fallback for FALLOC_FL_* flags */
#endif
#ifndef FALLOC_FL_KEEP_SIZE
^ permalink raw reply related [flat|nested] 2+ messages in thread
end of thread, other threads:[~2014-01-13 13:56 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-01-07 22:04 [PATCH] fallocate: avoid preprocessor token redefinitions Sami Kerola
2014-01-13 13:56 ` Karel Zak
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox