History

Merge tag 'sizeof_field-v5.5-rc2' of git://git.kernel.org/pub/scm/linux/kernel/git/kees/linux

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

Linus Torvalds committed 6 years ago

Commit 22ff3112 parents 37d4e84 c593642116 files · +299 −306Browse files

Showing the changes to include/linux (3 of 116 files). Show all

Unified · Split

3 files
  1. include/linux/filter.h +6 −6
  2. include/linux/kvm_host.h +1 −1
  3. include/linux/phy_led_triggers.h +1 −1
include/linux/filter.h+6−6
@@ -420,7 +420,7 @@ static inline bool insn_is_zext(const struct bpf_insn *insn) · 419 unmodified lines
420420
421421 #define BPF_FIELD_SIZEOF(type, field) \
422422 ({ \
423− const int __size = bytes_to_bpf_size(FIELD_SIZEOF(type, field)); \
423+ const int __size = bytes_to_bpf_size(sizeof_field(type, field)); \
424424 BUILD_BUG_ON(__size < 0); \
425425 __size; \
426426 })
@@ -497,7 +497,7 @@ static inline bool insn_is_zext(const struct bpf_insn *insn) · 70 unmodified lines
497497
498498 #define bpf_target_off(TYPE, MEMBER, SIZE, PTR_SIZE) \
499499 ({ \
500− BUILD_BUG_ON(FIELD_SIZEOF(TYPE, MEMBER) != (SIZE)); \
500+ BUILD_BUG_ON(sizeof_field(TYPE, MEMBER) != (SIZE)); \
501501 *(PTR_SIZE) = (SIZE); \
502502 offsetof(TYPE, MEMBER); \
503503 })
@@ -608,7 +608,7 @@ static inline void bpf_compute_data_pointers(struct sk_buff *skb) · 104 unmodified lines
608608 {
609609 struct bpf_skb_data_end *cb = (struct bpf_skb_data_end *)skb->cb;
610610
611− BUILD_BUG_ON(sizeof(*cb) > FIELD_SIZEOF(struct sk_buff, cb));
611+ BUILD_BUG_ON(sizeof(*cb) > sizeof_field(struct sk_buff, cb));
612612 cb->data_meta = skb->data - skb_metadata_len(skb);
613613 cb->data_end = skb->data + skb_headlen(skb);
614614 }
@@ -646,9 +646,9 @@ static inline u8 *bpf_skb_cb(struct sk_buff *skb) · 31 unmodified lines
646646 * attached to sockets, we need to clear the bpf_skb_cb() area
647647 * to not leak previous contents to user space.
648648 */
649− BUILD_BUG_ON(FIELD_SIZEOF(struct __sk_buff, cb) != BPF_SKB_CB_LEN);
650− BUILD_BUG_ON(FIELD_SIZEOF(struct __sk_buff, cb) !=
651− FIELD_SIZEOF(struct qdisc_skb_cb, data));
649+ BUILD_BUG_ON(sizeof_field(struct __sk_buff, cb) != BPF_SKB_CB_LEN);
650+ BUILD_BUG_ON(sizeof_field(struct __sk_buff, cb) !=
651+ sizeof_field(struct qdisc_skb_cb, data));
652652
653653 return qdisc_skb_cb(skb)->data;
654654 }
include/linux/kvm_host.h+1−1
@@ -149,7 +149,7 @@ static inline bool is_error_page(struct page *page) · 148 unmodified lines
149149 #define KVM_REQUEST_ARCH_BASE 8
150150
151151 #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); \
153153 (unsigned)(((nr) + KVM_REQUEST_ARCH_BASE) | (flags)); \
154154 })
155155 #define KVM_ARCH_REQ(nr) KVM_ARCH_REQ_FLAGS(nr, 0)
include/linux/phy_led_triggers.h+1−1
@@ -14,7 +14,7 @@ struct phy_device; · 13 unmodified lines
1414 #define PHY_LED_TRIGGER_SPEED_SUFFIX_SIZE 11
1515
1616 #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)+\
1818 PHY_LED_TRIGGER_SPEED_SUFFIX_SIZE)
1919
2020 struct phy_led_trigger {