libbtrfs: drop BUILD_ASSERT macros

The BUILD_ASSERT macro checks what _Static_assert can do. Remove it as
it's not really used in ioctl.h as it defines a stub. The assertions
still remain in the code outside of libbtrfs, we can delete it here as
the API is frozen and won't be changed.

Signed-off-by: David Sterba <dsterba@suse.com>
This commit is contained in:
David Sterba 2024-08-06 14:16:50 +02:00
parent e4afa23863
commit 9b5ae7c6d7
3 changed files with 0 additions and 52 deletions

View File

@ -514,7 +514,6 @@ struct btrfs_super_block {
/* Padded to 4096 bytes */ /* Padded to 4096 bytes */
u8 padding[565]; u8 padding[565];
} __attribute__ ((__packed__)); } __attribute__ ((__packed__));
BUILD_ASSERT(sizeof(struct btrfs_super_block) == BTRFS_SUPER_INFO_SIZE);
/* /*
* Compat flags that we support. If any incompat flags are set other than the * Compat flags that we support. If any incompat flags are set other than the

View File

@ -31,11 +31,6 @@ extern "C" {
#define __user #define __user
#endif #endif
/* We don't want to include entire kerncompat.h */
#ifndef BUILD_ASSERT
#define BUILD_ASSERT(x)
#endif
#define BTRFS_IOCTL_MAGIC 0x94 #define BTRFS_IOCTL_MAGIC 0x94
#define BTRFS_VOL_NAME_MAX 255 #define BTRFS_VOL_NAME_MAX 255
@ -45,7 +40,6 @@ struct btrfs_ioctl_vol_args {
__s64 fd; __s64 fd;
char name[BTRFS_PATH_NAME_MAX + 1]; char name[BTRFS_PATH_NAME_MAX + 1];
}; };
BUILD_ASSERT(sizeof(struct btrfs_ioctl_vol_args) == 4096);
#define BTRFS_DEVICE_PATH_NAME_MAX 1024 #define BTRFS_DEVICE_PATH_NAME_MAX 1024
@ -76,7 +70,6 @@ struct btrfs_qgroup_limit {
__u64 rsv_referenced; __u64 rsv_referenced;
__u64 rsv_exclusive; __u64 rsv_exclusive;
}; };
BUILD_ASSERT(sizeof(struct btrfs_qgroup_limit) == 40);
struct btrfs_qgroup_inherit { struct btrfs_qgroup_inherit {
__u64 flags; __u64 flags;
@ -86,13 +79,11 @@ struct btrfs_qgroup_inherit {
struct btrfs_qgroup_limit lim; struct btrfs_qgroup_limit lim;
__u64 qgroups[0]; __u64 qgroups[0];
}; };
BUILD_ASSERT(sizeof(struct btrfs_qgroup_inherit) == 72);
struct btrfs_ioctl_qgroup_limit_args { struct btrfs_ioctl_qgroup_limit_args {
__u64 qgroupid; __u64 qgroupid;
struct btrfs_qgroup_limit lim; struct btrfs_qgroup_limit lim;
}; };
BUILD_ASSERT(sizeof(struct btrfs_ioctl_qgroup_limit_args) == 48);
#define BTRFS_SUBVOL_NAME_MAX 4039 #define BTRFS_SUBVOL_NAME_MAX 4039
struct btrfs_ioctl_vol_args_v2 { struct btrfs_ioctl_vol_args_v2 {
@ -112,7 +103,6 @@ struct btrfs_ioctl_vol_args_v2 {
__u64 subvolid; __u64 subvolid;
}; };
}; };
BUILD_ASSERT(sizeof(struct btrfs_ioctl_vol_args_v2) == 4096);
/* /*
* structure to report errors and progress to userspace, either as a * structure to report errors and progress to userspace, either as a
@ -161,7 +151,6 @@ struct btrfs_ioctl_scrub_args {
/* pad to 1k */ /* pad to 1k */
__u64 unused[(1024-32-sizeof(struct btrfs_scrub_progress))/8]; __u64 unused[(1024-32-sizeof(struct btrfs_scrub_progress))/8];
}; };
BUILD_ASSERT(sizeof(struct btrfs_ioctl_scrub_args) == 1024);
#define BTRFS_IOCTL_DEV_REPLACE_CONT_READING_FROM_SRCDEV_MODE_ALWAYS 0 #define BTRFS_IOCTL_DEV_REPLACE_CONT_READING_FROM_SRCDEV_MODE_ALWAYS 0
#define BTRFS_IOCTL_DEV_REPLACE_CONT_READING_FROM_SRCDEV_MODE_AVOID 1 #define BTRFS_IOCTL_DEV_REPLACE_CONT_READING_FROM_SRCDEV_MODE_AVOID 1
@ -172,7 +161,6 @@ struct btrfs_ioctl_dev_replace_start_params {
__u8 srcdev_name[BTRFS_DEVICE_PATH_NAME_MAX + 1]; /* in */ __u8 srcdev_name[BTRFS_DEVICE_PATH_NAME_MAX + 1]; /* in */
__u8 tgtdev_name[BTRFS_DEVICE_PATH_NAME_MAX + 1]; /* in */ __u8 tgtdev_name[BTRFS_DEVICE_PATH_NAME_MAX + 1]; /* in */
}; };
BUILD_ASSERT(sizeof(struct btrfs_ioctl_dev_replace_start_params) == 2072);
#define BTRFS_IOCTL_DEV_REPLACE_STATE_NEVER_STARTED 0 #define BTRFS_IOCTL_DEV_REPLACE_STATE_NEVER_STARTED 0
#define BTRFS_IOCTL_DEV_REPLACE_STATE_STARTED 1 #define BTRFS_IOCTL_DEV_REPLACE_STATE_STARTED 1
@ -187,7 +175,6 @@ struct btrfs_ioctl_dev_replace_status_params {
__u64 num_write_errors; /* out */ __u64 num_write_errors; /* out */
__u64 num_uncorrectable_read_errors; /* out */ __u64 num_uncorrectable_read_errors; /* out */
}; };
BUILD_ASSERT(sizeof(struct btrfs_ioctl_dev_replace_status_params) == 48);
#define BTRFS_IOCTL_DEV_REPLACE_CMD_START 0 #define BTRFS_IOCTL_DEV_REPLACE_CMD_START 0
#define BTRFS_IOCTL_DEV_REPLACE_CMD_STATUS 1 #define BTRFS_IOCTL_DEV_REPLACE_CMD_STATUS 1
@ -208,7 +195,6 @@ struct btrfs_ioctl_dev_replace_args {
__u64 spare[64]; __u64 spare[64];
}; };
BUILD_ASSERT(sizeof(struct btrfs_ioctl_dev_replace_args) == 2600);
struct btrfs_ioctl_dev_info_args { struct btrfs_ioctl_dev_info_args {
__u64 devid; /* in/out */ __u64 devid; /* in/out */
@ -218,7 +204,6 @@ struct btrfs_ioctl_dev_info_args {
__u64 unused[379]; /* pad to 4k */ __u64 unused[379]; /* pad to 4k */
__u8 path[BTRFS_DEVICE_PATH_NAME_MAX]; /* out */ __u8 path[BTRFS_DEVICE_PATH_NAME_MAX]; /* out */
}; };
BUILD_ASSERT(sizeof(struct btrfs_ioctl_dev_info_args) == 4096);
struct btrfs_ioctl_fs_info_args { struct btrfs_ioctl_fs_info_args {
__u64 max_id; /* out */ __u64 max_id; /* out */
@ -230,14 +215,12 @@ struct btrfs_ioctl_fs_info_args {
__u32 reserved32; __u32 reserved32;
__u64 reserved[122]; /* pad to 1k */ __u64 reserved[122]; /* pad to 1k */
}; };
BUILD_ASSERT(sizeof(struct btrfs_ioctl_fs_info_args) == 1024);
struct btrfs_ioctl_feature_flags { struct btrfs_ioctl_feature_flags {
__u64 compat_flags; __u64 compat_flags;
__u64 compat_ro_flags; __u64 compat_ro_flags;
__u64 incompat_flags; __u64 incompat_flags;
}; };
BUILD_ASSERT(sizeof(struct btrfs_ioctl_feature_flags) == 24);
/* balance control ioctl modes */ /* balance control ioctl modes */
#define BTRFS_BALANCE_CTL_PAUSE 1 #define BTRFS_BALANCE_CTL_PAUSE 1
@ -315,7 +298,6 @@ struct btrfs_ioctl_balance_args {
__u64 unused[72]; /* pad to 1k */ __u64 unused[72]; /* pad to 1k */
}; };
BUILD_ASSERT(sizeof(struct btrfs_ioctl_balance_args) == 1024);
#define BTRFS_INO_LOOKUP_PATH_MAX 4080 #define BTRFS_INO_LOOKUP_PATH_MAX 4080
struct btrfs_ioctl_ino_lookup_args { struct btrfs_ioctl_ino_lookup_args {
@ -323,7 +305,6 @@ struct btrfs_ioctl_ino_lookup_args {
__u64 objectid; __u64 objectid;
char name[BTRFS_INO_LOOKUP_PATH_MAX]; char name[BTRFS_INO_LOOKUP_PATH_MAX];
}; };
BUILD_ASSERT(sizeof(struct btrfs_ioctl_ino_lookup_args) == 4096);
#define BTRFS_INO_LOOKUP_USER_PATH_MAX (4080 - BTRFS_VOL_NAME_MAX - 1) #define BTRFS_INO_LOOKUP_USER_PATH_MAX (4080 - BTRFS_VOL_NAME_MAX - 1)
struct btrfs_ioctl_ino_lookup_user_args { struct btrfs_ioctl_ino_lookup_user_args {
@ -339,7 +320,6 @@ struct btrfs_ioctl_ino_lookup_user_args {
*/ */
char path[BTRFS_INO_LOOKUP_USER_PATH_MAX]; char path[BTRFS_INO_LOOKUP_USER_PATH_MAX];
}; };
BUILD_ASSERT(sizeof(struct btrfs_ioctl_ino_lookup_user_args) == 4096);
struct btrfs_ioctl_search_key { struct btrfs_ioctl_search_key {
/* which root are we searching. 0 is the tree of tree roots */ /* which root are we searching. 0 is the tree of tree roots */
@ -407,7 +387,6 @@ struct btrfs_ioctl_search_args_v2 {
* to store item */ * to store item */
__u64 buf[0]; /* out - found items */ __u64 buf[0]; /* out - found items */
}; };
BUILD_ASSERT(sizeof(struct btrfs_ioctl_search_args_v2) == 112);
/* With a @src_length of zero, the range from @src_offset->EOF is cloned! */ /* With a @src_length of zero, the range from @src_offset->EOF is cloned! */
struct btrfs_ioctl_clone_range_args { struct btrfs_ioctl_clone_range_args {
@ -415,7 +394,6 @@ struct btrfs_ioctl_clone_range_args {
__u64 src_offset, src_length; __u64 src_offset, src_length;
__u64 dest_offset; __u64 dest_offset;
}; };
BUILD_ASSERT(sizeof(struct btrfs_ioctl_clone_range_args) == 32);
/* flags for the defrag range ioctl */ /* flags for the defrag range ioctl */
#define BTRFS_DEFRAG_RANGE_COMPRESS 1 #define BTRFS_DEFRAG_RANGE_COMPRESS 1
@ -445,7 +423,6 @@ struct btrfs_ioctl_same_args {
__u32 reserved2; __u32 reserved2;
struct btrfs_ioctl_same_extent_info info[0]; struct btrfs_ioctl_same_extent_info info[0];
}; };
BUILD_ASSERT(sizeof(struct btrfs_ioctl_same_args) == 24);
struct btrfs_ioctl_defrag_range_args { struct btrfs_ioctl_defrag_range_args {
/* start of the defrag operation */ /* start of the defrag operation */
@ -477,7 +454,6 @@ struct btrfs_ioctl_defrag_range_args {
/* spare for later */ /* spare for later */
__u32 unused[4]; __u32 unused[4];
}; };
BUILD_ASSERT(sizeof(struct btrfs_ioctl_defrag_range_args) == 48);
struct btrfs_ioctl_space_info { struct btrfs_ioctl_space_info {
__u64 flags; __u64 flags;
@ -490,7 +466,6 @@ struct btrfs_ioctl_space_args {
__u64 total_spaces; __u64 total_spaces;
struct btrfs_ioctl_space_info spaces[0]; struct btrfs_ioctl_space_info spaces[0];
}; };
BUILD_ASSERT(sizeof(struct btrfs_ioctl_space_args) == 16);
struct btrfs_data_container { struct btrfs_data_container {
__u32 bytes_left; /* out -- bytes not needed to deliver output */ __u32 bytes_left; /* out -- bytes not needed to deliver output */
@ -507,7 +482,6 @@ struct btrfs_ioctl_ino_path_args {
/* struct btrfs_data_container *fspath; out */ /* struct btrfs_data_container *fspath; out */
__u64 fspath; /* out */ __u64 fspath; /* out */
}; };
BUILD_ASSERT(sizeof(struct btrfs_ioctl_ino_path_args) == 56);
struct btrfs_ioctl_logical_ino_args { struct btrfs_ioctl_logical_ino_args {
__u64 logical; /* in */ __u64 logical; /* in */
@ -556,7 +530,6 @@ struct btrfs_ioctl_get_dev_stats {
__u64 unused[128 - 2 - BTRFS_DEV_STAT_VALUES_MAX]; /* pad to 1k + 8B */ __u64 unused[128 - 2 - BTRFS_DEV_STAT_VALUES_MAX]; /* pad to 1k + 8B */
}; };
BUILD_ASSERT(sizeof(struct btrfs_ioctl_get_dev_stats) == 1032);
/* BTRFS_IOC_SNAP_CREATE is no longer used by the btrfs command */ /* BTRFS_IOC_SNAP_CREATE is no longer used by the btrfs command */
#define BTRFS_QUOTA_CTL_ENABLE 1 #define BTRFS_QUOTA_CTL_ENABLE 1
@ -566,14 +539,12 @@ struct btrfs_ioctl_quota_ctl_args {
__u64 cmd; __u64 cmd;
__u64 status; __u64 status;
}; };
BUILD_ASSERT(sizeof(struct btrfs_ioctl_quota_ctl_args) == 16);
struct btrfs_ioctl_quota_rescan_args { struct btrfs_ioctl_quota_rescan_args {
__u64 flags; __u64 flags;
__u64 progress; __u64 progress;
__u64 reserved[6]; __u64 reserved[6];
}; };
BUILD_ASSERT(sizeof(struct btrfs_ioctl_quota_rescan_args) == 64);
struct btrfs_ioctl_qgroup_assign_args { struct btrfs_ioctl_qgroup_assign_args {
__u64 assign; __u64 assign;
@ -585,7 +556,6 @@ struct btrfs_ioctl_qgroup_create_args {
__u64 create; __u64 create;
__u64 qgroupid; __u64 qgroupid;
}; };
BUILD_ASSERT(sizeof(struct btrfs_ioctl_qgroup_create_args) == 16);
struct btrfs_ioctl_timespec { struct btrfs_ioctl_timespec {
__u64 sec; __u64 sec;
@ -601,7 +571,6 @@ struct btrfs_ioctl_received_subvol_args {
__u64 flags; /* in */ __u64 flags; /* in */
__u64 reserved[16]; /* in */ __u64 reserved[16]; /* in */
}; };
BUILD_ASSERT(sizeof(struct btrfs_ioctl_received_subvol_args) == 200);
/* /*
* If we have a 32-bit userspace and 64-bit kernel, then the UAPI * If we have a 32-bit userspace and 64-bit kernel, then the UAPI
@ -631,7 +600,6 @@ struct btrfs_ioctl_received_subvol_args_32 {
__u64 flags; /* in */ __u64 flags; /* in */
__u64 reserved[16]; /* in */ __u64 reserved[16]; /* in */
} __attribute__ ((__packed__)); } __attribute__ ((__packed__));
BUILD_ASSERT(sizeof(struct btrfs_ioctl_received_subvol_args_32) == 192);
#define BTRFS_IOC_SET_RECEIVED_SUBVOL_32_COMPAT_DEFINED 1 #define BTRFS_IOC_SET_RECEIVED_SUBVOL_32_COMPAT_DEFINED 1
@ -683,15 +651,6 @@ struct btrfs_ioctl_send_args {
__u32 version; /* in */ __u32 version; /* in */
__u8 reserved[28]; /* in */ __u8 reserved[28]; /* in */
}; };
/*
* Size of structure depends on pointer width, was not caught in the early
* days. Kernel handles pointer width differences transparently.
*/
BUILD_ASSERT(sizeof(__u64 *) == 8
? sizeof(struct btrfs_ioctl_send_args) == 72
: (sizeof(void *) == 4
? sizeof(struct btrfs_ioctl_send_args) == 68
: 0));
/* /*
* Different pointer width leads to structure size change. Kernel should accept * Different pointer width leads to structure size change. Kernel should accept
@ -711,7 +670,6 @@ struct btrfs_ioctl_send_args_64 {
__u64 flags; /* in */ __u64 flags; /* in */
__u64 reserved[4]; /* in */ __u64 reserved[4]; /* in */
} __attribute__((packed)); } __attribute__((packed));
BUILD_ASSERT(sizeof(struct btrfs_ioctl_send_args_64) == 72);
#define BTRFS_IOC_SEND_64_COMPAT_DEFINED 1 #define BTRFS_IOC_SEND_64_COMPAT_DEFINED 1
@ -790,7 +748,6 @@ struct btrfs_ioctl_get_subvol_rootref_args {
__u8 num_items; __u8 num_items;
__u8 align[7]; __u8 align[7];
}; };
BUILD_ASSERT(sizeof(struct btrfs_ioctl_get_subvol_rootref_args) == 4096);
/* /*
* Data and metadata for an encoded read or write. * Data and metadata for an encoded read or write.

View File

@ -48,14 +48,6 @@
#endif #endif
#endif #endif
#define __token_glue(a,b,c) ___token_glue(a,b,c)
#define ___token_glue(a,b,c) a ## b ## c
#ifdef DEBUG_BUILD_CHECKS
#define BUILD_ASSERT(x) extern int __token_glue(compile_time_assert_,__LINE__,__COUNTER__)[1-2*!(x)] __attribute__((unused))
#else
#define BUILD_ASSERT(x)
#endif
#ifdef __CHECKER__ #ifdef __CHECKER__
#define __force __attribute__((force)) #define __force __attribute__((force))
#define __bitwise__ __attribute__((bitwise)) #define __bitwise__ __attribute__((bitwise))