From: Andrew Deason Date: Mon, 13 Jan 2014 05:24:55 +0000 (-0600) Subject: LINUX: Fix "unused but set var" autoconf warnings X-Git-Tag: openafs-stable-1_8_0pre1~277 X-Git-Url: http://git.openafs.org/?p=openafs.git;a=commitdiff_plain;h=4e05184264bf1c0d54e20741563ba9dadc2ef522 LINUX: Fix "unused but set var" autoconf warnings 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: Change-Id: Ic29c4fc61da17633d8d1af81949b3917beb58cf6 Reviewed-on: http://gerrit.openafs.org/10706 Reviewed-by: Benjamin Kaduk Tested-by: BuildBot --- diff --git a/src/cf/linux-test4.m4 b/src/cf/linux-test4.m4 index 9b31f31..798a27b 100644 --- a/src/cf/linux-test4.m4 +++ b/src/cf/linux-test4.m4 @@ -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 -#include ], -[struct dentry _dentry; -struct nameidata _nameidata; -(void)_dentry.d_op->d_revalidate(&_dentry, &_nameidata);], + [#include + #include + 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 - #include ], - [struct dentry_operations _d_ops; - int _d_del(const struct dentry *de) {return 0;}; - _d_ops.d_delete = _d_del;], + #include + 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 ], - [struct inode_operations _i_ops; - int _mkdir(struct inode *i, struct dentry *d, umode_t m) {return 0;}; - _i_ops.mkdir = _mkdir;], + [#include + 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 ], - [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 + 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 - #include ], - [struct dentry_operations dops; - int reval(struct dentry *d, unsigned int i) { return 0; }; - dops.d_revalidate = reval;], + #include + 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 - #include ], - [struct inode_operations iops; - struct dentry *look(struct inode *i, struct dentry *d, unsigned int j) { return NULL; }; - iops.lookup = look;], + #include + 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])