btrfs: basic header cleanups
PATCH 1/2 btrfs: cleanup recursive include of the same header
In reply to Qu WenruoWe have several headers that are including themselves, triggering clangd warnings.
Just remove such unnecessary include.
--- fs/btrfs/btrfs_inode.h | 1 - fs/btrfs/extent_map.h | 1 - fs/btrfs/fs.h | 1 - fs/btrfs/locking.h | 1 - fs/btrfs/lru_cache.h | 1 - 5 files changed, 5 deletions(-)
fs/btrfs/btrfs_inode.h +0 -1
@@ -19,7 +19,6 @@#include <uapi/linux/btrfs_tree.h> #include <trace/events/btrfs.h> #include "block-rsv.h" -#include "btrfs_inode.h" #include "extent_map.h" #include "extent_io.h" #include "extent-io-tree.h"
fs/btrfs/extent_map.h +0 -1
@@ -9,7 +9,6 @@#include <linux/list.h> #include <linux/refcount.h> #include "misc.h" -#include "extent_map.h" #include "compression.h" struct btrfs_inode ;
fs/btrfs/fs.h +0 -1
@@ -29,7 +29,6 @@#include "extent-io-tree.h" #include "async-thread.h" #include "block-rsv.h" -#include "fs.h" struct inode ;struct super_block ;
fs/btrfs/locking.h +0 -1
@@ -11,7 +11,6 @@#include <linux/lockdep.h> #include <linux/percpu_counter.h> #include "extent_io.h" -#include "locking.h" struct extent_buffer ;struct btrfs_path ;
fs/btrfs/lru_cache.h +0 -1
@@ -6,7 +6,6 @@#include <linux/types.h> #include <linux/maple_tree.h> #include <linux/list.h> -#include "lru_cache.h" /* * A cache entry. This is meant to be embedded in a structure of a user of
Signature · 1 line
2.45.1
PATCH 2/2 btrfs: do not directly rwlock_types.h
In reply to Qu WenruoThere is already an error inside that header:
#if !defined(__LINUX_SPINLOCK_TYPES_H)
# error "Do not include directly, include spinlock_types.h" #endif
Thankfully it never get triggered as some other headers have already included spinlock_types.h.
However clangd would still do a proper warning on that if only extent_map.h is opened.
Fix it by using spinlock_types.h instead.
--- fs/btrfs/extent_map.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/btrfs/extent_map.h +1 -1
@@ -4,7 +4,7 @@#define BTRFS_EXTENT_MAP_H #include <linux/compiler_types.h> -#include <linux/rwlock_types.h> +#include <linux/spinlock_types.h> #include <linux/rbtree.h> #include <linux/list.h> #include <linux/refcount.h>
Signature · 1 line
2.45.1
cover btrfs: basic header cleanups
While reading headers, clangd would do a lot of extra checks, from the very basic like including the header itself, to missing type definition inside the header's include chain.
There are 2 very basic fixes can be done immediately:
- Do not do recursive include
- Do not include rwlock_types.h
As it already mentioned to include spinlock_types.h instead.
Qu Wenruo (2):
btrfs: cleanup recursive include of the same header
btrfs: do not directly rwlock_types.h
fs/btrfs/btrfs_inode.h | 1 - fs/btrfs/extent_map.h | 3 +-- fs/btrfs/fs.h | 1 - fs/btrfs/locking.h | 1 - fs/btrfs/lru_cache.h | 1 - 5 files changed, 1 insertion(+), 6 deletions(-)
Signature · 1 line
2.45.1
Re: [PATCH 1/2] btrfs: cleanup recursive include of the same header
In reply to Qu WenruoQuoted 7 lines · Qu Wenruo
We have several headers that are including themselves, triggering clangd warnings.
Just remove such unnecessary include.
Signed-off-by Qu Wenruo <[email protected]>
Maybe add a
Not sure how many people are using clangd or if it causes warnings with other tools.
Anyway:
Thanks.
Quoted 72 lines
--- fs/btrfs/btrfs_inode.h | 1 - fs/btrfs/extent_map.h | 1 - fs/btrfs/fs.h | 1 - fs/btrfs/locking.h | 1 - fs/btrfs/lru_cache.h | 1 - 5 files changed, 5 deletions(-)fs/btrfs/btrfs_inode.h +0
-1@@ -19,7 +19,6 @@#include <uapi/linux/btrfs_tree.h> #include <trace/events/btrfs.h> #include "block-rsv.h" -#include "btrfs_inode.h" #include "extent_map.h" #include "extent_io.h" #include "extent-io-tree.h" fs/btrfs/extent_map.h +0
-1@@ -9,7 +9,6 @@#include <linux/list.h> #include <linux/refcount.h> #include "misc.h" -#include "extent_map.h" #include "compression.h" struct btrfs_inode ;fs/btrfs/fs.h +0
-1@@ -29,7 +29,6 @@#include "extent-io-tree.h" #include "async-thread.h" #include "block-rsv.h" -#include "fs.h" struct inode ;struct super_block ;fs/btrfs/locking.h +0
-1@@ -11,7 +11,6 @@#include <linux/lockdep.h> #include <linux/percpu_counter.h> #include "extent_io.h" -#include "locking.h" struct extent_buffer ;struct btrfs_path ;fs/btrfs/lru_cache.h +0
-2@@ -6,7 +6,6 @@#include <linux/types.h> #include <linux/maple_tree.h> #include <linux/list.h> -#include "lru_cache.h" /* * A cache entry. This is meant to be embedded in a structure of a user of -- 2.45.1
Re: [PATCH 2/2] btrfs: do not directly rwlock_types.h
In reply to Qu WenruoQuoted 7 lines · Qu Wenruo
There is already an error inside that header:
#if !defined(__LINUX_SPINLOCK_TYPES_H)
# error "Do not include directly, include spinlock_types.h" #endif
Quoted 8 lines
Thankfully it never get triggered as some other headers have already included
spinlock_types.h.However clangd would still do a proper warning on that if only
extent_map.his opened.
Fix it by usingspinlock_types.hinstead.Signed-off-by Qu Wenruo <[email protected]>
Looks good, but the subject is missing a word, it should be:
btrfs: do not directly include rwlock_types.h
Anyway, that can be updated when adding the patch to for-next, so:
Thanks.
Quoted 21 lines
--- fs/btrfs/extent_map.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)fs/btrfs/extent_map.h +1
-2@@ -4,7 +4,7 @@#define BTRFS_EXTENT_MAP_H #include <linux/compiler_types.h> -#include <linux/rwlock_types.h> +#include <linux/spinlock_types.h> #include <linux/rbtree.h> #include <linux/list.h> #include <linux/refcount.h> --2.45.1
Quoted 6 lines · Qu Wenruo
While reading headers, clangd would do a lot of extra checks, from the very basic like including the header itself, to missing type definition inside the header's include chain.
There are 2 very basic fixes can be done immediately:
Quoted 8 lines
- Do not do recursive include
- Do not include
rwlock_types.h
As it already mentioned to includespinlock_types.hinstead.Qu Wenruo (2):
btrfs: cleanup recursive include of the same header
btrfs: do not directlyrwlock_types.h
Re: [PATCH 1/2] btrfs: cleanup recursive include of the same header
In reply to Filipe MananaQuoted 5 lines · Filipe Manana
Quoted 4 lines · Qu Wenruo
We have several headers that are including themselves, triggering clangd warnings.
Quoted 7 lines
Quoted 3 lines
Just remove such unnecessary include.
Signed-off-by Qu Wenruo <[email protected]>Maybe add a
Fixes 602035d7fecf ("btrfs: add forward declarations and headers, part 2")
Adding Fixes: to tags could trigger the stable workflow and the patches could be picked for backport although it's not necessary. Mentioning the patch that introduced the problme in changelog text should be sufficient in such cases.