Message ID | 6b462dc4d7ceffe2ba9141f46bf28350be7c7f4a.1663196541.git.josef@toxicpanda.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | btrfs: strip out btrfs_fs_info dependencies | expand |
On 15/09/2022 07:04, Josef Bacik wrote: > We shouldn't have static_assert()'s in header files in general, but > especially since btrfs_super_block isn't defined in ctree.h. > > Signed-off-by: Josef Bacik <josef@toxicpanda.com> Reviewed-by: Anand Jain <anand.jain@oracle.com>
Looks good,
Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
On Wed, Sep 14, 2022 at 07:04:42PM -0400, Josef Bacik wrote: > We shouldn't have static_assert()'s in header files in general, Why? Since we have the _Static_assert support in all compilers we can do the header compile-time checks. > but > especially since btrfs_super_block isn't defined in ctree.h. > > Signed-off-by: Josef Bacik <josef@toxicpanda.com> > --- > fs/btrfs/ctree.h | 1 - > fs/btrfs/fs.c | 2 ++ > 2 files changed, 2 insertions(+), 1 deletion(-) > > diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h > index a790c58b4c73..3cb4e0aca058 100644 > --- a/fs/btrfs/ctree.h > +++ b/fs/btrfs/ctree.h > @@ -56,7 +56,6 @@ struct btrfs_ioctl_encoded_io_args; > > #define BTRFS_SUPER_INFO_OFFSET SZ_64K > #define BTRFS_SUPER_INFO_SIZE 4096 > -static_assert(sizeof(struct btrfs_super_block) == BTRFS_SUPER_INFO_SIZE); > > + > +static_assert(sizeof(struct btrfs_super_block) == BTRFS_SUPER_INFO_SIZE); This can be dropped as the same assert is right after the super block definition and this is IMO the intended usage pattern. This catches any accidental changes to the structure.
diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h index a790c58b4c73..3cb4e0aca058 100644 --- a/fs/btrfs/ctree.h +++ b/fs/btrfs/ctree.h @@ -56,7 +56,6 @@ struct btrfs_ioctl_encoded_io_args; #define BTRFS_SUPER_INFO_OFFSET SZ_64K #define BTRFS_SUPER_INFO_SIZE 4096 -static_assert(sizeof(struct btrfs_super_block) == BTRFS_SUPER_INFO_SIZE); /* * The reserved space at the beginning of each device. diff --git a/fs/btrfs/fs.c b/fs/btrfs/fs.c index a95d86679d14..c54ee0f943ce 100644 --- a/fs/btrfs/fs.c +++ b/fs/btrfs/fs.c @@ -106,3 +106,5 @@ int __btrfs_fs_compat_ro(struct btrfs_fs_info *fs_info, u64 flag) disk_super = fs_info->super_copy; return !!(btrfs_super_compat_ro_flags(disk_super) & flag); } + +static_assert(sizeof(struct btrfs_super_block) == BTRFS_SUPER_INFO_SIZE);
We shouldn't have static_assert()'s in header files in general, but especially since btrfs_super_block isn't defined in ctree.h. Signed-off-by: Josef Bacik <josef@toxicpanda.com> --- fs/btrfs/ctree.h | 1 - fs/btrfs/fs.c | 2 ++ 2 files changed, 2 insertions(+), 1 deletion(-)