LINUX: Fix "unused but set var" autoconf warnings
authorAndrew Deason <adeason@sinenomine.net>
Mon, 13 Jan 2014 05:24:55 +0000 (23:24 -0600)
committerBenjamin Kaduk <kaduk@mit.edu>
Sat, 22 Aug 2015 14:28:13 +0000 (10:28 -0400)
A few of the linux autoconf tests generate -Wunused-but-set-variable
warnings, unless the test is run with -Wno-unused-but-set-variable.
Since we run these tests with -Werror, this can cause the tests to
incorrectly fail if they are not run with
-Wno-unused-but-set-variable.

The Linux kernel build process normally does run with that option, but
due to some other (possibly buggy) behavior, sometimes these configure
tests do not run with that option. So, make our tests work without
generating that warning, so we will work in more cases.

Reorganize a few of these tests so we are setting a field in a global
structure, instead of a function-local one. Make the test function
names and style little more consistent while we are here, but do not
make the global structure 'static', in case the compiler recognizes we
are setting fields for a structure that cannot be used by anything.

In particular, the "revalidate takes nameidata" test had been wrongly
succeeding, but that didn't usually matter because of how the feature
tests are ordered in the code.  It does matter in the case when the
"revalidate takes unsigned" check also gets a wrong result, which
can cause kernel BUGs, which should be fixed by these changes.

See:
<http://lists.openafs.org/pipermail/openafs-devel/2014-January/019727.html>
<http://thread.gmane.org/gmane.comp.file-systems.openafs.devel/11361>

Change-Id: Ic29c4fc61da17633d8d1af81949b3917beb58cf6
Reviewed-on: http://gerrit.openafs.org/10706
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Tested-by: BuildBot <buildbot@rampaginggeek.com>

src/cf/linux-test4.m4

index 9b31f31..798a27b 100644 (file)
@@ -290,14 +290,14 @@ void *cookie;
 AC_DEFUN([LINUX_DOP_D_REVALIDATE_TAKES_NAMEIDATA], [
   AC_CHECK_LINUX_BUILD([whether dentry_operations.d_revalidate takes a nameidata],
                       [ac_cv_linux_func_d_revalidate_takes_nameidata],
-[#include <linux/fs.h>
-#include <linux/namei.h>],
-[struct dentry _dentry;
-struct nameidata _nameidata;
-(void)_dentry.d_op->d_revalidate(&_dentry, &_nameidata);],
+                        [#include <linux/fs.h>
+                        #include <linux/namei.h>
+                        static int reval(struct dentry *d, struct nameidata *nd) { return 0; }
+                        struct dentry_operations dops;],
+                        [dops.d_revalidate = reval;],
                       [DOP_REVALIDATE_TAKES_NAMEIDATA],
                       [define if your dops.d_revalidate takes a nameidata argument],
-                      [])
+                      [-Werror])
 ])
 
 
@@ -632,10 +632,10 @@ AC_DEFUN([LINUX_DOP_D_DELETE_TAKES_CONST], [
   AC_CHECK_LINUX_BUILD([whether dentry.d_op->d_delete takes a const argument],
                        [ac_cv_linux_dop_d_delete_takes_const],
                        [#include <linux/fs.h>
-                       #include <linux/dcache.h>],
-                       [struct dentry_operations _d_ops;
-                       int _d_del(const struct dentry *de) {return 0;};
-                       _d_ops.d_delete = _d_del;],
+                       #include <linux/dcache.h>
+                       static int _d_del(const struct dentry *de) { return 0; }
+                       struct dentry_operations _d_ops;],
+                       [_d_ops.d_delete = _d_del;],
                        [DOP_D_DELETE_TAKES_CONST],
                        [define if dentry.d_op->d_delete takes a const argument],
                        [-Werror])
@@ -645,10 +645,10 @@ AC_DEFUN([LINUX_DOP_D_DELETE_TAKES_CONST], [
 AC_DEFUN([LINUX_IOP_MKDIR_TAKES_UMODE_T], [
   AC_CHECK_LINUX_BUILD([whether inode.i_op->mkdir takes a umode_t argument],
                        [ac_cv_linux_iop_mkdir_takes_umode_t],
-                       [#include <linux/fs.h>],
-                       [struct inode_operations _i_ops;
-                       int _mkdir(struct inode *i, struct dentry *d, umode_t m) {return 0;};
-                       _i_ops.mkdir = _mkdir;],
+                       [#include <linux/fs.h>
+                       static int _mkdir(struct inode *i, struct dentry *d, umode_t m) { return 0; }
+                       struct inode_operations _i_ops;],
+                       [_i_ops.mkdir = _mkdir;],
                        [IOP_MKDIR_TAKES_UMODE_T],
                        [define if inode.i_op->mkdir takes a umode_t argument],
                        [-Werror])
@@ -672,11 +672,10 @@ AC_DEFUN([LINUX_IOP_CREATE_TAKES_UMODE_T], [
 AC_DEFUN([LINUX_EXPORT_OP_ENCODE_FH_TAKES_INODES], [
   AC_CHECK_LINUX_BUILD([whether export operation encode_fh takes inode arguments],
                        [ac_cv_linux_export_op_encode_fh__takes_inodes],
-                       [#include <linux/exportfs.h>],
-                       [struct export_operations _exp_ops;
-                       int _encode_fh(struct inode *i, __u32 *fh, int *len, struct inode *p)
-                               {return 0;};
-                       _exp_ops.encode_fh = _encode_fh;],
+                       [#include <linux/exportfs.h>
+                       static int _encode_fh(struct inode *i, __u32 *fh, int *len, struct inode *p) { return 0; }
+                       struct export_operations _exp_ops;],
+                       [_exp_ops.encode_fh = _encode_fh;],
                        [EXPORT_OP_ENCODE_FH_TAKES_INODES],
                        [define if encode_fh export op takes inode arguments],
                        [-Werror])
@@ -761,10 +760,10 @@ AC_DEFUN([LINUX_DOP_D_REVALIDATE_TAKES_UNSIGNED], [
   AC_CHECK_LINUX_BUILD([whether dentry_operations.d_revalidate takes an unsigned int],
                        [ac_cv_linux_func_d_revalidate_takes_unsigned],
                        [#include <linux/fs.h>
-                       #include <linux/namei.h>],
-                       [struct dentry_operations dops;
-                       int reval(struct dentry *d, unsigned int i) { return 0; };
-                       dops.d_revalidate = reval;],
+                       #include <linux/namei.h>
+                       static int reval(struct dentry *d, unsigned int i) { return 0; }
+                       struct dentry_operations _d_ops;],
+                       [_d_ops.d_revalidate = reval;],
                       [DOP_REVALIDATE_TAKES_UNSIGNED],
                       [define if your dops.d_revalidate takes an unsigned int argument],
                       [-Werror])
@@ -775,10 +774,10 @@ AC_DEFUN([LINUX_IOP_LOOKUP_TAKES_UNSIGNED], [
   AC_CHECK_LINUX_BUILD([whether inode operation lookup takes an unsigned int],
                        [ac_cv_linux_func_lookup_takes_unsigned],
                        [#include <linux/fs.h>
-                       #include <linux/namei.h>],
-                       [struct inode_operations iops;
-                       struct dentry *look(struct inode *i, struct dentry *d, unsigned int j) { return NULL; };
-                       iops.lookup = look;],
+                       #include <linux/namei.h>
+                       static struct dentry *look(struct inode *i, struct dentry *d, unsigned int j) { return NULL; }
+                       struct inode_operations _i_ops;],
+                       [_i_ops.lookup = look;],
                       [IOP_LOOKUP_TAKES_UNSIGNED],
                       [define if your iops.lookup takes an unsigned int argument],
                       [-Werror])