fs/hugetlbfs/inode.c:1579:1: warning: ISO C90 forbids mixing declarations and code

From: kernel test robot
Date: Mon Nov 01 2021 - 11:59:45 EST


tree: https://github.com/0day-ci/linux/commits/UPDATE-20211101-194552/zhangyiru/mm-hugetlb-remove-mlock-ulimit-for-SHM_HUGETLB/20211009-094538
head: 00d28e7a2b1786c1ab3b63cc3abb4aca5c02fdfd
commit: 00d28e7a2b1786c1ab3b63cc3abb4aca5c02fdfd mm,hugetlb: remove mlock ulimit for SHM_HUGETLB
date: 4 hours ago
config: riscv-randconfig-r034-20211101 (attached as .config)
compiler: clang version 14.0.0 (https://github.com/llvm/llvm-project 264d3b6d4e08401c5b50a85bd76e80b3461d77e6)
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# install riscv cross compiling tool for clang build
# apt-get install binutils-riscv64-linux-gnu
# https://github.com/0day-ci/linux/commit/00d28e7a2b1786c1ab3b63cc3abb4aca5c02fdfd
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review UPDATE-20211101-194552/zhangyiru/mm-hugetlb-remove-mlock-ulimit-for-SHM_HUGETLB/20211009-094538
git checkout 00d28e7a2b1786c1ab3b63cc3abb4aca5c02fdfd
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 ARCH=riscv

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@xxxxxxxxx>

All warnings (new ones prefixed by >>):

d_count
include/linux/compiler.h:56:47: note: expanded from macro 'if'
#define if(cond, ...) if ( __trace_if_var( !!(cond , ## __VA_ARGS__) ) )
^
include/linux/compiler.h:58:61: note: expanded from macro '__trace_if_var'
#define __trace_if_var(cond) (__builtin_constant_p(cond) ? (cond) : __trace_if_value(cond))
^
include/linux/dcache.h:290:24: note: 'd_count' declared here
static inline unsigned d_count(const struct dentry *dentry)
^
fs/hugetlbfs/inode.c:1467:28: error: use of undeclared identifier 'ucounts'; did you mean 'd_count'?
if (user_shm_lock(size, *ucounts)) {
^~~~~~~
d_count
include/linux/compiler.h:56:47: note: expanded from macro 'if'
#define if(cond, ...) if ( __trace_if_var( !!(cond , ## __VA_ARGS__) ) )
^
include/linux/compiler.h:58:86: note: expanded from macro '__trace_if_var'
#define __trace_if_var(cond) (__builtin_constant_p(cond) ? (cond) : __trace_if_value(cond))
^
include/linux/compiler.h:69:3: note: expanded from macro '__trace_if_value'
(cond) ? \
^
include/linux/dcache.h:290:24: note: 'd_count' declared here
static inline unsigned d_count(const struct dentry *dentry)
^
fs/hugetlbfs/inode.c:1470:27: error: use of undeclared identifier 'ucounts'; did you mean 'd_count'?
user_shm_unlock(size, *ucounts);
^~~~~~~
d_count
include/linux/dcache.h:290:24: note: 'd_count' declared here
static inline unsigned d_count(const struct dentry *dentry)
^
fs/hugetlbfs/inode.c:1496:7: error: use of undeclared identifier 'ucounts'; did you mean 'd_count'?
if (*ucounts) {
^~~~~~~
d_count
include/linux/compiler.h:56:47: note: expanded from macro 'if'
#define if(cond, ...) if ( __trace_if_var( !!(cond , ## __VA_ARGS__) ) )
^
include/linux/compiler.h:58:52: note: expanded from macro '__trace_if_var'
#define __trace_if_var(cond) (__builtin_constant_p(cond) ? (cond) : __trace_if_value(cond))
^
include/linux/dcache.h:290:24: note: 'd_count' declared here
static inline unsigned d_count(const struct dentry *dentry)
^
fs/hugetlbfs/inode.c:1496:7: error: use of undeclared identifier 'ucounts'; did you mean 'd_count'?
if (*ucounts) {
^~~~~~~
d_count
include/linux/compiler.h:56:47: note: expanded from macro 'if'
#define if(cond, ...) if ( __trace_if_var( !!(cond , ## __VA_ARGS__) ) )
^
include/linux/compiler.h:58:61: note: expanded from macro '__trace_if_var'
#define __trace_if_var(cond) (__builtin_constant_p(cond) ? (cond) : __trace_if_value(cond))
^
include/linux/dcache.h:290:24: note: 'd_count' declared here
static inline unsigned d_count(const struct dentry *dentry)
^
fs/hugetlbfs/inode.c:1496:7: error: use of undeclared identifier 'ucounts'; did you mean 'd_count'?
if (*ucounts) {
^~~~~~~
d_count
include/linux/compiler.h:56:47: note: expanded from macro 'if'
#define if(cond, ...) if ( __trace_if_var( !!(cond , ## __VA_ARGS__) ) )
^
include/linux/compiler.h:58:86: note: expanded from macro '__trace_if_var'
#define __trace_if_var(cond) (__builtin_constant_p(cond) ? (cond) : __trace_if_value(cond))
^
include/linux/compiler.h:69:3: note: expanded from macro '__trace_if_value'
(cond) ? \
^
include/linux/dcache.h:290:24: note: 'd_count' declared here
static inline unsigned d_count(const struct dentry *dentry)
^
fs/hugetlbfs/inode.c:1497:26: error: use of undeclared identifier 'ucounts'; did you mean 'd_count'?
user_shm_unlock(size, *ucounts);
^~~~~~~
d_count
include/linux/dcache.h:290:24: note: 'd_count' declared here
static inline unsigned d_count(const struct dentry *dentry)
^
fs/hugetlbfs/inode.c:1498:4: error: use of undeclared identifier 'ucounts'
*ucounts = NULL;
^
fs/hugetlbfs/inode.c:1504:1: error: function definition is not allowed here
{
^
fs/hugetlbfs/inode.c:1524:1: error: function definition is not allowed here
{
^
fs/hugetlbfs/inode.c:1579:13: error: use of undeclared identifier 'init_hugetlbfs_fs'
fs_initcall(init_hugetlbfs_fs)
^
fs/hugetlbfs/inode.c:1579:31: error: expected '}'
fs_initcall(init_hugetlbfs_fs)
^
fs/hugetlbfs/inode.c:1451:1: note: to match this '{'
{
^
>> fs/hugetlbfs/inode.c:1579:1: warning: ISO C90 forbids mixing declarations and code [-Wdeclaration-after-statement]
fs_initcall(init_hugetlbfs_fs)
^
include/linux/init.h:288:27: note: expanded from macro 'fs_initcall'
#define fs_initcall(fn) __define_initcall(fn, 5)
^
include/linux/init.h:262:35: note: expanded from macro '__define_initcall'
#define __define_initcall(fn, id) ___define_initcall(fn, id, .initcall##id)
^
include/linux/init.h:260:2: note: expanded from macro '___define_initcall'
__unique_initcall(fn, id, __sec, __initcall_id(fn))
^
note: (skipping 2 expansions in backtrace; use -fmacro-backtrace-limit=0 to see all)
include/linux/compiler_types.h:60:22: note: expanded from macro '__PASTE'
#define __PASTE(a,b) ___PASTE(a,b)
^
include/linux/compiler_types.h:59:23: note: expanded from macro '___PASTE'
#define ___PASTE(a,b) a##b
^
<scratch space>:175:1: note: expanded from here
__initcall__kmod_hugetlbfs__317_1579_init_hugetlbfs_fs5
^
1 warning and 15 errors generated.


vim +1579 fs/hugetlbfs/inode.c

32021982a324dc David Howells 2018-11-01 1522
^1da177e4c3f41 Linus Torvalds 2005-04-16 1523 static int __init init_hugetlbfs_fs(void)
^1da177e4c3f41 Linus Torvalds 2005-04-16 1524 {
32021982a324dc David Howells 2018-11-01 1525 struct vfsmount *mnt;
42d7395feb56f0 Andi Kleen 2012-12-11 1526 struct hstate *h;
^1da177e4c3f41 Linus Torvalds 2005-04-16 1527 int error;
42d7395feb56f0 Andi Kleen 2012-12-11 1528 int i;
^1da177e4c3f41 Linus Torvalds 2005-04-16 1529
457c1b27ed56ec Nishanth Aravamudan 2014-05-06 1530 if (!hugepages_supported()) {
9b857d26d08f00 Andrew Morton 2014-06-04 1531 pr_info("disabling because there are no supported hugepage sizes\n");
457c1b27ed56ec Nishanth Aravamudan 2014-05-06 1532 return -ENOTSUPP;
457c1b27ed56ec Nishanth Aravamudan 2014-05-06 1533 }
457c1b27ed56ec Nishanth Aravamudan 2014-05-06 1534
d1d5e05ffdc110 Hillf Danton 2012-03-21 1535 error = -ENOMEM;
^1da177e4c3f41 Linus Torvalds 2005-04-16 1536 hugetlbfs_inode_cachep = kmem_cache_create("hugetlbfs_inode_cache",
^1da177e4c3f41 Linus Torvalds 2005-04-16 1537 sizeof(struct hugetlbfs_inode_info),
5d097056c9a017 Vladimir Davydov 2016-01-14 1538 0, SLAB_ACCOUNT, init_once);
^1da177e4c3f41 Linus Torvalds 2005-04-16 1539 if (hugetlbfs_inode_cachep == NULL)
8fc312b32b25c6 Mike Kravetz 2019-11-30 1540 goto out;
^1da177e4c3f41 Linus Torvalds 2005-04-16 1541
^1da177e4c3f41 Linus Torvalds 2005-04-16 1542 error = register_filesystem(&hugetlbfs_fs_type);
^1da177e4c3f41 Linus Torvalds 2005-04-16 1543 if (error)
8fc312b32b25c6 Mike Kravetz 2019-11-30 1544 goto out_free;
8fc312b32b25c6 Mike Kravetz 2019-11-30 1545
8fc312b32b25c6 Mike Kravetz 2019-11-30 1546 /* default hstate mount is required */
3b2275a8d83a29 Miaohe Lin 2021-02-24 1547 mnt = mount_one_hugetlbfs(&default_hstate);
8fc312b32b25c6 Mike Kravetz 2019-11-30 1548 if (IS_ERR(mnt)) {
8fc312b32b25c6 Mike Kravetz 2019-11-30 1549 error = PTR_ERR(mnt);
8fc312b32b25c6 Mike Kravetz 2019-11-30 1550 goto out_unreg;
8fc312b32b25c6 Mike Kravetz 2019-11-30 1551 }
8fc312b32b25c6 Mike Kravetz 2019-11-30 1552 hugetlbfs_vfsmount[default_hstate_idx] = mnt;
^1da177e4c3f41 Linus Torvalds 2005-04-16 1553
8fc312b32b25c6 Mike Kravetz 2019-11-30 1554 /* other hstates are optional */
42d7395feb56f0 Andi Kleen 2012-12-11 1555 i = 0;
42d7395feb56f0 Andi Kleen 2012-12-11 1556 for_each_hstate(h) {
15f0ec941f4f90 Jan Stancek 2020-01-03 1557 if (i == default_hstate_idx) {
15f0ec941f4f90 Jan Stancek 2020-01-03 1558 i++;
8fc312b32b25c6 Mike Kravetz 2019-11-30 1559 continue;
15f0ec941f4f90 Jan Stancek 2020-01-03 1560 }
8fc312b32b25c6 Mike Kravetz 2019-11-30 1561
32021982a324dc David Howells 2018-11-01 1562 mnt = mount_one_hugetlbfs(h);
8fc312b32b25c6 Mike Kravetz 2019-11-30 1563 if (IS_ERR(mnt))
8fc312b32b25c6 Mike Kravetz 2019-11-30 1564 hugetlbfs_vfsmount[i] = NULL;
8fc312b32b25c6 Mike Kravetz 2019-11-30 1565 else
32021982a324dc David Howells 2018-11-01 1566 hugetlbfs_vfsmount[i] = mnt;
42d7395feb56f0 Andi Kleen 2012-12-11 1567 i++;
42d7395feb56f0 Andi Kleen 2012-12-11 1568 }
32021982a324dc David Howells 2018-11-01 1569
42d7395feb56f0 Andi Kleen 2012-12-11 1570 return 0;
^1da177e4c3f41 Linus Torvalds 2005-04-16 1571
8fc312b32b25c6 Mike Kravetz 2019-11-30 1572 out_unreg:
8fc312b32b25c6 Mike Kravetz 2019-11-30 1573 (void)unregister_filesystem(&hugetlbfs_fs_type);
8fc312b32b25c6 Mike Kravetz 2019-11-30 1574 out_free:
^1da177e4c3f41 Linus Torvalds 2005-04-16 1575 kmem_cache_destroy(hugetlbfs_inode_cachep);
8fc312b32b25c6 Mike Kravetz 2019-11-30 1576 out:
^1da177e4c3f41 Linus Torvalds 2005-04-16 1577 return error;
^1da177e4c3f41 Linus Torvalds 2005-04-16 1578 }
3e89e1c5ea8421 Paul Gortmaker 2016-01-14 @1579 fs_initcall(init_hugetlbfs_fs)

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@xxxxxxxxxxxx

Attachment: .config.gz
Description: application/gzip