[libvirt] [PATCH] Add a define for NFS_SUPER_MAGIC

Commit 3c12a67b766cce51b47861ccde2be41de369f832 added a dependency on the NFS_SUPER_MAGIC macro, which is defined in linux/magic.h. Unfortunately linux/magic.h is not available in RHEL-5, and causes a compile error. Just define it locally, since this is something that can't change. Signed-off-by: Chris Lalancette <clalance@redhat.com> --- src/qemu/qemu_driver.c | 6 ++++-- 1 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index ccb9ef9..efc3be1 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -49,8 +49,10 @@ #ifdef __linux__ #include <sys/vfs.h> -#include <linux/magic.h> -#endif +#ifndef NFS_SUPER_MAGIC +#define NFS_SUPER_MAGIC 0x6969 +#endif /* NFS_SUPER_MAGIC */ +#endif /* __linux__ */ #include "virterror_internal.h" #include "logging.h" -- 1.6.6.1

According to Chris Lalancette on 3/3/2010 9:44 AM:
Commit 3c12a67b766cce51b47861ccde2be41de369f832 added a dependency on the NFS_SUPER_MAGIC macro, which is defined in linux/magic.h. Unfortunately linux/magic.h is not available in RHEL-5, and causes a compile error. Just define it locally, since this is something that can't change.
ACK.
#ifdef __linux__ #include <sys/vfs.h> -#include <linux/magic.h> -#endif +#ifndef NFS_SUPER_MAGIC +#define NFS_SUPER_MAGIC 0x6969 +#endif /* NFS_SUPER_MAGIC */ +#endif /* __linux__ */
Style question (and yet another thing for me to add to my pending HACKING patch): any objections to indenting preprocessor directives to make it easier to track nesting? As in: #ifdef __linux__ # include <sys/vfs.h> # ifndef NFS_SUPER_MAGIC # define NFS_SUPER_MAGIC 0x6969 # endif /* NFS_SUPER_MAGIC */ #endif /* __linux__ */ -- Eric Blake eblake@redhat.com +1-801-349-2682 Libvirt virtualization library http://libvirt.org

On 03/03/2010 11:56 AM, Eric Blake wrote:
According to Chris Lalancette on 3/3/2010 9:44 AM:
Commit 3c12a67b766cce51b47861ccde2be41de369f832 added a dependency on the NFS_SUPER_MAGIC macro, which is defined in linux/magic.h. Unfortunately linux/magic.h is not available in RHEL-5, and causes a compile error. Just define it locally, since this is something that can't change.
ACK.
Thanks, pushed.
#ifdef __linux__ #include <sys/vfs.h> -#include <linux/magic.h> -#endif +#ifndef NFS_SUPER_MAGIC +#define NFS_SUPER_MAGIC 0x6969 +#endif /* NFS_SUPER_MAGIC */ +#endif /* __linux__ */
Style question (and yet another thing for me to add to my pending HACKING patch): any objections to indenting preprocessor directives to make it easier to track nesting? As in:
#ifdef __linux__ # include <sys/vfs.h> # ifndef NFS_SUPER_MAGIC # define NFS_SUPER_MAGIC 0x6969 # endif /* NFS_SUPER_MAGIC */ #endif /* __linux__ */
I do it without indentation because I vaguely remember that spaces in preprocessor directives are not standards compliant. That may not be true anymore, and/or I might be mis-remembering, but that's the reason. I don't really care either way; I'm happy to indent it if that is the agreed-upon way to do it. -- Chris Lalancette

According to Chris Lalancette on 3/3/2010 10:44 AM:
#ifdef __linux__ # include <sys/vfs.h> # ifndef NFS_SUPER_MAGIC # define NFS_SUPER_MAGIC 0x6969 # endif /* NFS_SUPER_MAGIC */ #endif /* __linux__ */
I do it without indentation because I vaguely remember that spaces in preprocessor directives are not standards compliant.
With K&R preprocessors, the # had to be in column 1, but you could have space between the # and the directive. But C89 (21 years ago!) changed things and required support for arbitrary indentation on both sides of # (not that everyone obeyed C89 right away, but still...). Autoconf-generated files are proof of the portability of arbitrary CPP indentation - just look at ./configure, and notice all the sample C programs it compiles, with preprocessor indentation all over the place.
That may not be true anymore, and/or I might be mis-remembering, but that's the reason. I don't really care either way; I'm happy to indent it if that is the agreed-upon way to do it.
Jim introduced me to it via coreutils and gnulib, and it really does save some headaches when dealing with deep nestings of #ifdef (of course, the goal is to not nest deeply in the first place; but even that goal is served by following consistent indentation rules, to call visual attention to the depth). -- Eric Blake eblake@redhat.com +1-801-349-2682 Libvirt virtualization library http://libvirt.org

Eric Blake wrote: ...
#ifdef __linux__ #include <sys/vfs.h> -#include <linux/magic.h> -#endif +#ifndef NFS_SUPER_MAGIC +#define NFS_SUPER_MAGIC 0x6969 +#endif /* NFS_SUPER_MAGIC */ +#endif /* __linux__ */
Style question (and yet another thing for me to add to my pending HACKING patch): any objections to indenting preprocessor directives to make it easier to track nesting? As in:
#ifdef __linux__ # include <sys/vfs.h> # ifndef NFS_SUPER_MAGIC # define NFS_SUPER_MAGIC 0x6969 # endif /* NFS_SUPER_MAGIC */ #endif /* __linux__ */
I find that more readable. If enough people prefer that style here, we could even mass-indent the code and ensure it stays that way with an optional syntax-check rule that'd run only if you have the required tool. I use cppi for that: http://savannah.gnu.org/projects/cppi Speaking of this made me realize there'd been no "official" release of that tool in some time, so I have just made one: http://meyering.net/cppi/cppi-1.14.tar.xz http://meyering.net/cppi/cppi-1.14.tar.xz.sig [may have to wait a day or two for the tarball to appear on ftp.gnu.org ] This doesn't really matter for libvirt, since it doesn't have many nested cpp directives, but when you *do* have many, consistent indentation is the only way to remain effective. Here's its --help output: Usage: cppi [FILE] or: cppi -c [OPTION] [FILE]... Indent the C preprocessor directives in FILE to reflect their nesting and ensure that there is exactly one space character between each #if, #elif, #define directive and the following token, and write the result to standard output. The number of spaces between the `#' and the following directive must correspond to the level of nesting of that directive. With no FILE, or when FILE is -, read standard input. -a, --ansi when checking, fail if text follows #else or #endif -c, --check set exit code, but don't produce any output -l, --list-files-only don't generate diagnostics about indentation; print to stdout only the names of files that are not properly indented -m, --max-string-length=LENGTH fail if there is a double-quoted string longer than LENGTH; if LENGTH is 0 (the default), then there is no limit --help display this help and exit --version output version information and exit With the -c option, don't write to stdout. Instead, check the indentation of the specified files giving diagnostics for preprocessor lines that aren't properly indented or are otherwise invalid. Note that --ansi without --check does not correct the problem of non-ANSI text following #else and #endif directives. The exit code will be one of these: 0 all directives properly indented 1 some cpp directive(s) improperly indented, or if text follows #else/#endif (enabled with --check --ansi), or found a double-quoted string longer than the specified maximum 2 #if/#endif mismatch, EOF in comment or string 3 file (e.g. open/read/write) error A pragma directive may have its `#' indented. Report bugs to <bug-cppi@gnu.org>.

On Wed, Mar 03, 2010 at 11:44:51AM -0500, Chris Lalancette wrote:
Commit 3c12a67b766cce51b47861ccde2be41de369f832 added a dependency on the NFS_SUPER_MAGIC macro, which is defined in linux/magic.h. Unfortunately linux/magic.h is not available in RHEL-5, and causes a compile error. Just define it locally, since this is something that can't change.
Signed-off-by: Chris Lalancette <clalance@redhat.com> --- src/qemu/qemu_driver.c | 6 ++++-- 1 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index ccb9ef9..efc3be1 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -49,8 +49,10 @@
#ifdef __linux__ #include <sys/vfs.h> -#include <linux/magic.h> -#endif +#ifndef NFS_SUPER_MAGIC +#define NFS_SUPER_MAGIC 0x6969 +#endif /* NFS_SUPER_MAGIC */ +#endif /* __linux__ */
#include "virterror_internal.h" #include "logging.h"
ACK, Daniel -- Daniel Veillard | libxml Gnome XML XSLT toolkit http://xmlsoft.org/ daniel@veillard.com | Rpmfind RPM search engine http://rpmfind.net/ http://veillard.com/ | virtualization library http://libvirt.org/
participants (4)
-
Chris Lalancette
-
Daniel Veillard
-
Eric Blake
-
Jim Meyering