From 03318641afc3e2d6dc18614aaa75d6a0125cb933 Mon Sep 17 00:00:00 2001 From: Brian Behlendorf Date: Tue, 19 Apr 2011 09:26:48 -0700 Subject: Fix gcc configure warnings Newer versions of gcc are getting smart enough to detect the sloppy syntax used for the autoconf tests. It is now generating warnings for unused/undeclared variables. Newer version of gcc even have the -Wunused-but-set-variable option set by default. This isn't a problem except when -Werror is set and they get promoted to an error. In this case the autoconf test will return an incorrect result which will result in a build failure latter on. To handle this I'm tightening up many of the autoconf tests to explicitly mark variables as unused to suppress the gcc warning. Remember, all of the autoconf code can never actually be run we just want to get a clean build error to detect which APIs are available. Never using a variable is absolutely fine for this. --- config/spl-build.m4 | 45 +++++++++++++++------------ configure | 90 +++++++++++++++++++++++++++++------------------------ 2 files changed, 75 insertions(+), 60 deletions(-) diff --git a/config/spl-build.m4 b/config/spl-build.m4 index 84fbb8b92..1a7512c96 100644 --- a/config/spl-build.m4 +++ b/config/spl-build.m4 @@ -638,7 +638,7 @@ AC_DEFUN([SPL_AC_ATOMIC_SPINLOCK], [ SPL_LINUX_TRY_COMPILE([ #include ],[ - atomic64_t *ptr; + atomic64_t *ptr __attribute__ ((unused)); ],[ have_atomic64_t=yes AC_DEFINE(HAVE_ATOMIC64_T, 1, @@ -720,7 +720,7 @@ AC_DEFUN([SPL_AC_TYPE_UINTPTR_T], SPL_LINUX_TRY_COMPILE([ #include ],[ - uintptr_t *ptr; + uintptr_t *ptr __attribute__ ((unused)); ],[ AC_MSG_RESULT([yes]) AC_DEFINE(HAVE_UINTPTR_T, 1, @@ -739,7 +739,7 @@ AC_DEFUN([SPL_AC_3ARGS_INIT_WORK], SPL_LINUX_TRY_COMPILE([ #include ],[ - struct work_struct work; + struct work_struct work __attribute__ ((unused)); INIT_WORK(&work, NULL, NULL); ],[ AC_MSG_RESULT(yes) @@ -759,7 +759,7 @@ AC_DEFUN([SPL_AC_2ARGS_REGISTER_SYSCTL], SPL_LINUX_TRY_COMPILE([ #include ],[ - return register_sysctl_table(NULL,0); + (void) register_sysctl_table(NULL, 0); ],[ AC_MSG_RESULT(yes) AC_DEFINE(HAVE_2ARGS_REGISTER_SYSCTL, 1, @@ -825,7 +825,7 @@ AC_DEFUN([SPL_AC_PATH_IN_NAMEIDATA], SPL_LINUX_TRY_COMPILE([ #include ],[ - struct nameidata nd; + struct nameidata nd __attribute__ ((unused)); nd.path.mnt = NULL; nd.path.dentry = NULL; @@ -877,7 +877,7 @@ AC_DEFUN([SPL_AC_CTL_NAME], [ SPL_LINUX_TRY_COMPILE([ #include ],[ - struct ctl_table ctl; + struct ctl_table ctl __attribute__ ((unused)); ctl.ctl_name = 0; ],[ AC_MSG_RESULT(yes) @@ -997,7 +997,9 @@ AC_DEFUN([SPL_AC_TIMESPEC_SUB], [ SPL_LINUX_TRY_COMPILE([ #include ],[ - struct timespec a, b, c = { 0 }; + struct timespec a = { 0 }; + struct timespec b = { 0 }; + struct timespec c __attribute__ ((unused)); c = timespec_sub(a, b); ],[ AC_MSG_RESULT(yes) @@ -1016,7 +1018,8 @@ AC_DEFUN([SPL_AC_INIT_UTSNAME], [ SPL_LINUX_TRY_COMPILE([ #include ],[ - struct new_utsname *a = init_utsname(); + struct new_utsname *a __attribute__ ((unused)); + a = init_utsname(); ],[ AC_MSG_RESULT(yes) AC_DEFINE(HAVE_INIT_UTSNAME, 1, [init_utsname() is available]) @@ -1047,7 +1050,8 @@ AC_DEFUN([SPL_AC_FILES_FDTABLE], [ #endif ],[ struct files_struct *files = current->files; - struct fdtable *fdt = files_fdtable(files); + struct fdtable *fdt __attribute__ ((unused)); + fdt = files_fdtable(files); ],[ AC_MSG_RESULT(yes) AC_DEFINE(HAVE_FILES_FDTABLE, 1, [files_fdtable() is available]) @@ -1073,7 +1077,8 @@ AC_DEFUN([SPL_AC_KMALLOC_NODE], [ SPL_LINUX_TRY_COMPILE([ #include ],[ - void *a = kmalloc_node(1, GFP_KERNEL, 0); + void *a __attribute__ ((unused)); + a = kmalloc_node(1, GFP_KERNEL, 0); ],[ AC_MSG_RESULT(yes) AC_DEFINE(HAVE_KMALLOC_NODE, 1, [kmalloc_node() is available]) @@ -1125,7 +1130,7 @@ AC_DEFUN([SPL_AC_MUTEX_OWNER], [ SPL_LINUX_TRY_COMPILE([ #include ],[ - struct mutex mtx; + struct mutex mtx __attribute__ ((unused)); mtx.owner = NULL; ],[ AC_MSG_RESULT(yes) @@ -1301,7 +1306,7 @@ AC_DEFUN([SPL_AC_GLOBAL_PAGE_STATE], [ SPL_LINUX_TRY_COMPILE([ #include ],[ - unsigned long state; + unsigned long state __attribute__ ((unused)); state = global_page_state(0); ],[ AC_MSG_RESULT(yes) @@ -1327,7 +1332,7 @@ AC_DEFUN([SPL_AC_ZONE_STAT_ITEM_FREE], [ SPL_LINUX_TRY_COMPILE([ #include ],[ - enum zone_stat_item zsi; + enum zone_stat_item zsi __attribute__ ((unused)); zsi = NR_FREE_PAGES; ],[ AC_MSG_RESULT(yes) @@ -1354,7 +1359,7 @@ AC_DEFUN([SPL_AC_ZONE_STAT_ITEM_INACTIVE], [ SPL_LINUX_TRY_COMPILE([ #include ],[ - enum zone_stat_item zsi; + enum zone_stat_item zsi __attribute__ ((unused)); zsi = NR_INACTIVE; ],[ AC_MSG_RESULT(yes) @@ -1368,7 +1373,7 @@ AC_DEFUN([SPL_AC_ZONE_STAT_ITEM_INACTIVE], [ SPL_LINUX_TRY_COMPILE([ #include ],[ - enum zone_stat_item zsi; + enum zone_stat_item zsi __attribute__ ((unused)); zsi = NR_INACTIVE_ANON; ],[ AC_MSG_RESULT(yes) @@ -1382,7 +1387,7 @@ AC_DEFUN([SPL_AC_ZONE_STAT_ITEM_INACTIVE], [ SPL_LINUX_TRY_COMPILE([ #include ],[ - enum zone_stat_item zsi; + enum zone_stat_item zsi __attribute__ ((unused)); zsi = NR_INACTIVE_FILE; ],[ AC_MSG_RESULT(yes) @@ -1409,7 +1414,7 @@ AC_DEFUN([SPL_AC_ZONE_STAT_ITEM_ACTIVE], [ SPL_LINUX_TRY_COMPILE([ #include ],[ - enum zone_stat_item zsi; + enum zone_stat_item zsi __attribute__ ((unused)); zsi = NR_ACTIVE; ],[ AC_MSG_RESULT(yes) @@ -1423,7 +1428,7 @@ AC_DEFUN([SPL_AC_ZONE_STAT_ITEM_ACTIVE], [ SPL_LINUX_TRY_COMPILE([ #include ],[ - enum zone_stat_item zsi; + enum zone_stat_item zsi __attribute__ ((unused)); zsi = NR_ACTIVE_ANON; ],[ AC_MSG_RESULT(yes) @@ -1437,7 +1442,7 @@ AC_DEFUN([SPL_AC_ZONE_STAT_ITEM_ACTIVE], [ SPL_LINUX_TRY_COMPILE([ #include ],[ - enum zone_stat_item zsi; + enum zone_stat_item zsi __attribute__ ((unused)); zsi = NR_ACTIVE_FILE; ],[ AC_MSG_RESULT(yes) @@ -1604,7 +1609,7 @@ AC_DEFUN([SPL_AC_CRED_STRUCT], [ SPL_LINUX_TRY_COMPILE([ #include ],[ - struct cred *cr; + struct cred *cr __attribute__ ((unused)); cr = NULL; ],[ AC_MSG_RESULT(yes) diff --git a/configure b/configure index f8dbd6465..6a322ce4e 100755 --- a/configure +++ b/configure @@ -11989,7 +11989,7 @@ int main (void) { - atomic64_t *ptr; + atomic64_t *ptr __attribute__ ((unused)); ; return 0; @@ -12232,7 +12232,7 @@ int main (void) { - uintptr_t *ptr; + uintptr_t *ptr __attribute__ ((unused)); ; return 0; @@ -12296,7 +12296,7 @@ int main (void) { - struct work_struct work; + struct work_struct work __attribute__ ((unused)); INIT_WORK(&work, NULL, NULL); ; @@ -12361,7 +12361,7 @@ int main (void) { - return register_sysctl_table(NULL,0); + (void) register_sysctl_table(NULL, 0); ; return 0; @@ -12563,7 +12563,7 @@ int main (void) { - struct nameidata nd; + struct nameidata nd __attribute__ ((unused)); nd.path.mnt = NULL; nd.path.dentry = NULL; @@ -12738,7 +12738,7 @@ int main (void) { - struct ctl_table ctl; + struct ctl_table ctl __attribute__ ((unused)); ctl.ctl_name = 0; ; @@ -13124,7 +13124,9 @@ int main (void) { - struct timespec a, b, c = { 0 }; + struct timespec a = { 0 }; + struct timespec b = { 0 }; + struct timespec c __attribute__ ((unused)); c = timespec_sub(a, b); ; @@ -13190,7 +13192,8 @@ int main (void) { - struct new_utsname *a = init_utsname(); + struct new_utsname *a __attribute__ ((unused)); + a = init_utsname(); ; return 0; @@ -13328,7 +13331,8 @@ main (void) { struct files_struct *files = current->files; - struct fdtable *fdt = files_fdtable(files); + struct fdtable *fdt __attribute__ ((unused)); + fdt = files_fdtable(files); ; return 0; @@ -13461,7 +13465,8 @@ int main (void) { - void *a = kmalloc_node(1, GFP_KERNEL, 0); + void *a __attribute__ ((unused)); + a = kmalloc_node(1, GFP_KERNEL, 0); ; return 0; @@ -13634,7 +13639,7 @@ int main (void) { - struct mutex mtx; + struct mutex mtx __attribute__ ((unused)); mtx.owner = NULL; ; @@ -14096,7 +14101,7 @@ int main (void) { - unsigned long state; + unsigned long state __attribute__ ((unused)); state = global_page_state(0); ; @@ -14162,7 +14167,7 @@ int main (void) { - enum zone_stat_item zsi; + enum zone_stat_item zsi __attribute__ ((unused)); zsi = NR_FREE_PAGES; ; @@ -14228,7 +14233,7 @@ int main (void) { - enum zone_stat_item zsi; + enum zone_stat_item zsi __attribute__ ((unused)); zsi = NR_INACTIVE; ; @@ -14293,7 +14298,7 @@ int main (void) { - enum zone_stat_item zsi; + enum zone_stat_item zsi __attribute__ ((unused)); zsi = NR_INACTIVE_ANON; ; @@ -14358,7 +14363,7 @@ int main (void) { - enum zone_stat_item zsi; + enum zone_stat_item zsi __attribute__ ((unused)); zsi = NR_INACTIVE_FILE; ; @@ -14424,7 +14429,7 @@ int main (void) { - enum zone_stat_item zsi; + enum zone_stat_item zsi __attribute__ ((unused)); zsi = NR_ACTIVE; ; @@ -14489,7 +14494,7 @@ int main (void) { - enum zone_stat_item zsi; + enum zone_stat_item zsi __attribute__ ((unused)); zsi = NR_ACTIVE_ANON; ; @@ -14554,7 +14559,7 @@ int main (void) { - enum zone_stat_item zsi; + enum zone_stat_item zsi __attribute__ ((unused)); zsi = NR_ACTIVE_FILE; ; @@ -15080,7 +15085,7 @@ int main (void) { - struct cred *cr; + struct cred *cr __attribute__ ((unused)); cr = NULL; ; @@ -15957,7 +15962,7 @@ int main (void) { - atomic64_t *ptr; + atomic64_t *ptr __attribute__ ((unused)); ; return 0; @@ -16200,7 +16205,7 @@ int main (void) { - uintptr_t *ptr; + uintptr_t *ptr __attribute__ ((unused)); ; return 0; @@ -16264,7 +16269,7 @@ int main (void) { - struct work_struct work; + struct work_struct work __attribute__ ((unused)); INIT_WORK(&work, NULL, NULL); ; @@ -16329,7 +16334,7 @@ int main (void) { - return register_sysctl_table(NULL,0); + (void) register_sysctl_table(NULL, 0); ; return 0; @@ -16531,7 +16536,7 @@ int main (void) { - struct nameidata nd; + struct nameidata nd __attribute__ ((unused)); nd.path.mnt = NULL; nd.path.dentry = NULL; @@ -16706,7 +16711,7 @@ int main (void) { - struct ctl_table ctl; + struct ctl_table ctl __attribute__ ((unused)); ctl.ctl_name = 0; ; @@ -17092,7 +17097,9 @@ int main (void) { - struct timespec a, b, c = { 0 }; + struct timespec a = { 0 }; + struct timespec b = { 0 }; + struct timespec c __attribute__ ((unused)); c = timespec_sub(a, b); ; @@ -17158,7 +17165,8 @@ int main (void) { - struct new_utsname *a = init_utsname(); + struct new_utsname *a __attribute__ ((unused)); + a = init_utsname(); ; return 0; @@ -17296,7 +17304,8 @@ main (void) { struct files_struct *files = current->files; - struct fdtable *fdt = files_fdtable(files); + struct fdtable *fdt __attribute__ ((unused)); + fdt = files_fdtable(files); ; return 0; @@ -17429,7 +17438,8 @@ int main (void) { - void *a = kmalloc_node(1, GFP_KERNEL, 0); + void *a __attribute__ ((unused)); + a = kmalloc_node(1, GFP_KERNEL, 0); ; return 0; @@ -17602,7 +17612,7 @@ int main (void) { - struct mutex mtx; + struct mutex mtx __attribute__ ((unused)); mtx.owner = NULL; ; @@ -18064,7 +18074,7 @@ int main (void) { - unsigned long state; + unsigned long state __attribute__ ((unused)); state = global_page_state(0); ; @@ -18130,7 +18140,7 @@ int main (void) { - enum zone_stat_item zsi; + enum zone_stat_item zsi __attribute__ ((unused)); zsi = NR_FREE_PAGES; ; @@ -18196,7 +18206,7 @@ int main (void) { - enum zone_stat_item zsi; + enum zone_stat_item zsi __attribute__ ((unused)); zsi = NR_INACTIVE; ; @@ -18261,7 +18271,7 @@ int main (void) { - enum zone_stat_item zsi; + enum zone_stat_item zsi __attribute__ ((unused)); zsi = NR_INACTIVE_ANON; ; @@ -18326,7 +18336,7 @@ int main (void) { - enum zone_stat_item zsi; + enum zone_stat_item zsi __attribute__ ((unused)); zsi = NR_INACTIVE_FILE; ; @@ -18392,7 +18402,7 @@ int main (void) { - enum zone_stat_item zsi; + enum zone_stat_item zsi __attribute__ ((unused)); zsi = NR_ACTIVE; ; @@ -18457,7 +18467,7 @@ int main (void) { - enum zone_stat_item zsi; + enum zone_stat_item zsi __attribute__ ((unused)); zsi = NR_ACTIVE_ANON; ; @@ -18522,7 +18532,7 @@ int main (void) { - enum zone_stat_item zsi; + enum zone_stat_item zsi __attribute__ ((unused)); zsi = NR_ACTIVE_FILE; ; @@ -19048,7 +19058,7 @@ int main (void) { - struct cred *cr; + struct cred *cr __attribute__ ((unused)); cr = NULL; ; -- cgit v1.2.3