Pull FIELD_SIZEOF conversion from Kees Cook: "A mostly mechanical treewide conversion from FIELD_SIZEOF() to sizeof_field(). This avoids the redundancy of having 2 macros (actually 3) doing the same thing, and consolidates on sizeof_field(). While "field" is not an accurate name, it is the common name used in the kernel, and doesn't result in any unintended innuendo. As there are still users of FIELD_SIZEOF() in -next, I will clean up those during this coming development cycle and send the final old macro removal patch at that time" * tag 'sizeof_field-v5.5-rc2' of git://git.kernel.org/pub/scm/linux/kernel/git/kees/linux: treewide: Use sizeof_field() macro MIPS: OCTEON: Replace SIZEOF_FIELD() macro
Showing the changes to include/linux (3 of 116 files). Show all
Unified · Split
| @@ -420,7 +420,7 @@ static inline bool insn_is_zext(const struct bpf_insn *insn) · 419 unmodified lines | |||
| 420 | 420 | ||
| 421 | #define BPF_FIELD_SIZEOF(type, field) \ | 421 | #define BPF_FIELD_SIZEOF(type, field) \ |
| 422 | ({ \ | 422 | ({ \ |
| 423 | const int __size = bytes_to_bpf_size(FIELD_SIZEOF(type, field)); \ | 423 | const int __size = bytes_to_bpf_size(sizeof_field(type, field)); \ |
| 424 | BUILD_BUG_ON(__size < 0); \ | 424 | BUILD_BUG_ON(__size < 0); \ |
| 425 | __size; \ | 425 | __size; \ |
| 426 | }) | 426 | }) |
| @@ -497,7 +497,7 @@ static inline bool insn_is_zext(const struct bpf_insn *insn) · 70 unmodified lines | |||
| 497 | 497 | ||
| 498 | #define bpf_target_off(TYPE, MEMBER, SIZE, PTR_SIZE) \ | 498 | #define bpf_target_off(TYPE, MEMBER, SIZE, PTR_SIZE) \ |
| 499 | ({ \ | 499 | ({ \ |
| 500 | BUILD_BUG_ON(FIELD_SIZEOF(TYPE, MEMBER) != (SIZE)); \ | 500 | BUILD_BUG_ON(sizeof_field(TYPE, MEMBER) != (SIZE)); \ |
| 501 | *(PTR_SIZE) = (SIZE); \ | 501 | *(PTR_SIZE) = (SIZE); \ |
| 502 | offsetof(TYPE, MEMBER); \ | 502 | offsetof(TYPE, MEMBER); \ |
| 503 | }) | 503 | }) |
| @@ -608,7 +608,7 @@ static inline void bpf_compute_data_pointers(struct sk_buff *skb) · 104 unmodified lines | |||
| 608 | { | 608 | { |
| 609 | struct bpf_skb_data_end *cb = (struct bpf_skb_data_end *)skb->cb; | 609 | struct bpf_skb_data_end *cb = (struct bpf_skb_data_end *)skb->cb; |
| 610 | 610 | ||
| 611 | BUILD_BUG_ON(sizeof(*cb) > FIELD_SIZEOF(struct sk_buff, cb)); | 611 | BUILD_BUG_ON(sizeof(*cb) > sizeof_field(struct sk_buff, cb)); |
| 612 | cb->data_meta = skb->data - skb_metadata_len(skb); | 612 | cb->data_meta = skb->data - skb_metadata_len(skb); |
| 613 | cb->data_end = skb->data + skb_headlen(skb); | 613 | cb->data_end = skb->data + skb_headlen(skb); |
| 614 | } | 614 | } |
| @@ -646,9 +646,9 @@ static inline u8 *bpf_skb_cb(struct sk_buff *skb) · 31 unmodified lines | |||
| 646 | * attached to sockets, we need to clear the bpf_skb_cb() area | 646 | * attached to sockets, we need to clear the bpf_skb_cb() area |
| 647 | * to not leak previous contents to user space. | 647 | * to not leak previous contents to user space. |
| 648 | */ | 648 | */ |
| 649 | BUILD_BUG_ON(FIELD_SIZEOF(struct __sk_buff, cb) != BPF_SKB_CB_LEN); | 649 | BUILD_BUG_ON(sizeof_field(struct __sk_buff, cb) != BPF_SKB_CB_LEN); |
| 650 | BUILD_BUG_ON(FIELD_SIZEOF(struct __sk_buff, cb) != | 650 | BUILD_BUG_ON(sizeof_field(struct __sk_buff, cb) != |
| 651 | FIELD_SIZEOF(struct qdisc_skb_cb, data)); | 651 | sizeof_field(struct qdisc_skb_cb, data)); |
| 652 | 652 | ||
| 653 | return qdisc_skb_cb(skb)->data; | 653 | return qdisc_skb_cb(skb)->data; |
| 654 | } | 654 | } |
| @@ -149,7 +149,7 @@ static inline bool is_error_page(struct page *page) · 148 unmodified lines | |||
| 149 | #define KVM_REQUEST_ARCH_BASE 8 | 149 | #define KVM_REQUEST_ARCH_BASE 8 |
| 150 | 150 | ||
| 151 | #define KVM_ARCH_REQ_FLAGS(nr, flags) ({ \ | 151 | #define KVM_ARCH_REQ_FLAGS(nr, flags) ({ \ |
| 152 | BUILD_BUG_ON((unsigned)(nr) >= (FIELD_SIZEOF(struct kvm_vcpu, requests) * 8) - KVM_REQUEST_ARCH_BASE); \ | 152 | BUILD_BUG_ON((unsigned)(nr) >= (sizeof_field(struct kvm_vcpu, requests) * 8) - KVM_REQUEST_ARCH_BASE); \ |
| 153 | (unsigned)(((nr) + KVM_REQUEST_ARCH_BASE) | (flags)); \ | 153 | (unsigned)(((nr) + KVM_REQUEST_ARCH_BASE) | (flags)); \ |
| 154 | }) | 154 | }) |
| 155 | #define KVM_ARCH_REQ(nr) KVM_ARCH_REQ_FLAGS(nr, 0) | 155 | #define KVM_ARCH_REQ(nr) KVM_ARCH_REQ_FLAGS(nr, 0) |
| @@ -14,7 +14,7 @@ struct phy_device; · 13 unmodified lines | |||
| 14 | #define PHY_LED_TRIGGER_SPEED_SUFFIX_SIZE 11 | 14 | #define PHY_LED_TRIGGER_SPEED_SUFFIX_SIZE 11 |
| 15 | 15 | ||
| 16 | #define PHY_LINK_LED_TRIGGER_NAME_SIZE (MII_BUS_ID_SIZE + \ | 16 | #define PHY_LINK_LED_TRIGGER_NAME_SIZE (MII_BUS_ID_SIZE + \ |
| 17 | FIELD_SIZEOF(struct mdio_device, addr)+\ | 17 | sizeof_field(struct mdio_device, addr)+\ |
| 18 | PHY_LED_TRIGGER_SPEED_SUFFIX_SIZE) | 18 | PHY_LED_TRIGGER_SPEED_SUFFIX_SIZE) |
| 19 | 19 | ||
| 20 | struct phy_led_trigger { | 20 | struct phy_led_trigger { |