Skip to content

Commit 402736a

Browse files
arndbakpm00
authored andcommitted
mm: shmem: avoid build warning for CONFIG_SHMEM=n
The newly added 'flags' variable is unused and causes a warning if CONFIG_SHMEM is disabled, since the shmem_acct_size() macro it is passed into does nothing: mm/shmem.c: In function '__shmem_file_setup': mm/shmem.c:5816:23: error: unused variable 'flags' [-Werror=unused-variable] 5816 | unsigned long flags = (vm_flags & VM_NORESERVE) ? SHMEM_F_NORESERVE : 0; | ^~~~~ Replace the two macros with equivalent inline functions to get the argument checking. Link: https://lkml.kernel.org/r/20251204102905.1048000-1-arnd@kernel.org Fixes: 6ff1610 ("mm: shmem: use SHMEM_F_* flags instead of VM_* flags") Signed-off-by: Arnd Bergmann <arnd@arndb.de> Acked-by: David Hildenbrand (Red Hat) <david@kernel.org> Acked-by: Mike Rapoport (Microsoft) <rppt@kernel.org> Reviewed-by: Baolin Wang <baolin.wang@linux.alibaba.com> Reviewed-by: Pratyush Yadav <pratyush@kernel.org> Reviewed-by: Pasha Tatashin <pasha.tatashin@soleen.com> Cc: Christian Brauner <brauner@kernel.org> Cc: guoweikang <guoweikang.kernel@gmail.com> Cc: Hugh Dickins <hughd@google.com> Cc: Kairui Song <kasong@tencent.com> Cc: Kemeng Shi <shikemeng@huaweicloud.com> Cc: Lorenzo Stoakes <lorenzo.stoakes@oracle.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
1 parent 2214ec4 commit 402736a

1 file changed

Lines changed: 9 additions & 2 deletions

File tree

mm/shmem.c

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5799,8 +5799,15 @@ EXPORT_SYMBOL_GPL(shmem_truncate_range);
57995799
#define shmem_vm_ops generic_file_vm_ops
58005800
#define shmem_anon_vm_ops generic_file_vm_ops
58015801
#define shmem_file_operations ramfs_file_operations
5802-
#define shmem_acct_size(flags, size) 0
5803-
#define shmem_unacct_size(flags, size) do {} while (0)
5802+
5803+
static inline int shmem_acct_size(unsigned long flags, loff_t size)
5804+
{
5805+
return 0;
5806+
}
5807+
5808+
static inline void shmem_unacct_size(unsigned long flags, loff_t size)
5809+
{
5810+
}
58045811

58055812
static inline struct inode *shmem_get_inode(struct mnt_idmap *idmap,
58065813
struct super_block *sb, struct inode *dir,

0 commit comments

Comments
 (0)