All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] btrfs: Fix unused variable in load_free_space_cache()
@ 2022-07-22 16:38 Nathan Chancellor
  2022-07-25 16:02 ` David Sterba
  0 siblings, 1 reply; 2+ messages in thread
From: Nathan Chancellor @ 2022-07-22 16:38 UTC (permalink / raw)
  To: Chris Mason, Josef Bacik, David Sterba
  Cc: Ioannis Angelakopoulos, linux-btrfs, linux-kernel, Nathan Chancellor

When CONFIG_LOCKDEP is unset, there is a warning about the mapping
variable being unused:

  fs/btrfs/free-space-cache.c:929:24: warning: variable 'mapping' set but not used [-Wunused-but-set-variable]
          struct address_space *mapping;
                                ^
  1 warning generated.

lockdep_set_class() does not do anything with the first parameter to the
macro when CONFIG_LOCKDEP is not set so just eliminate the mapping
variable and use inode instead, which is always used in the function.

Fixes: 22d85ab1af7d ("btrfs: Change the lockdep class of struct inode's invalidate_lock")
Link: https://github.com/ClangBuiltLinux/linux/issues/1672
Signed-off-by: Nathan Chancellor <nathan@kernel.org>
---
 fs/btrfs/free-space-cache.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/fs/btrfs/free-space-cache.c b/fs/btrfs/free-space-cache.c
index a2b2329ae558..e8fce6b19559 100644
--- a/fs/btrfs/free-space-cache.c
+++ b/fs/btrfs/free-space-cache.c
@@ -926,7 +926,6 @@ int load_free_space_cache(struct btrfs_block_group *block_group)
 	int ret = 0;
 	bool matched;
 	u64 used = block_group->used;
-	struct address_space *mapping;
 
 	/*
 	 * Because we could potentially discard our loaded free space, we want
@@ -991,8 +990,8 @@ int load_free_space_cache(struct btrfs_block_group *block_group)
 	 * space inodes to prevent false positives related to locks for normal
 	 * inodes.
 	 */
-	mapping = &inode->i_data;
-	lockdep_set_class(&mapping->invalidate_lock, &btrfs_free_space_inode_key);
+	lockdep_set_class(&inode->i_data.invalidate_lock,
+			  &btrfs_free_space_inode_key);
 
 	ret = __load_free_space_cache(fs_info->tree_root, inode, &tmp_ctl,
 				      path, block_group->start);

base-commit: ba37a9d53d71f94ed78f2e53d84be7fa77e2a2b3
-- 
2.37.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] btrfs: Fix unused variable in load_free_space_cache()
  2022-07-22 16:38 [PATCH] btrfs: Fix unused variable in load_free_space_cache() Nathan Chancellor
@ 2022-07-25 16:02 ` David Sterba
  0 siblings, 0 replies; 2+ messages in thread
From: David Sterba @ 2022-07-25 16:02 UTC (permalink / raw)
  To: Nathan Chancellor
  Cc: Chris Mason, Josef Bacik, David Sterba, Ioannis Angelakopoulos,
	linux-btrfs, linux-kernel

On Fri, Jul 22, 2022 at 09:38:54AM -0700, Nathan Chancellor wrote:
> When CONFIG_LOCKDEP is unset, there is a warning about the mapping
> variable being unused:
> 
>   fs/btrfs/free-space-cache.c:929:24: warning: variable 'mapping' set but not used [-Wunused-but-set-variable]
>           struct address_space *mapping;
>                                 ^
>   1 warning generated.
> 
> lockdep_set_class() does not do anything with the first parameter to the
> macro when CONFIG_LOCKDEP is not set so just eliminate the mapping
> variable and use inode instead, which is always used in the function.
> 
> Fixes: 22d85ab1af7d ("btrfs: Change the lockdep class of struct inode's invalidate_lock")
> Link: https://github.com/ClangBuiltLinux/linux/issues/1672
> Signed-off-by: Nathan Chancellor <nathan@kernel.org>

Folded to the patch, thanks.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-07-25 16:07 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-07-22 16:38 [PATCH] btrfs: Fix unused variable in load_free_space_cache() Nathan Chancellor
2022-07-25 16:02 ` David Sterba

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.