History

treewide: Use sizeof_field() macro

Replace all the occurrences of FIELD_SIZEOF() with sizeof_field() except at places where these are defined. Later patches will remove the unused definition of FIELD_SIZEOF(). This patch is generated using following script: EXCLUDE_FILES="include/linux/stddef.h|include/linux/kernel.h" git grep -l -e "\bFIELD_SIZEOF\b" | while read file; do if [[ "$file" =~ $EXCLUDE_FILES ]]; then continue fi sed -i -e 's/\bFIELD_SIZEOF\b/sizeof_field/g' $file; done

Pankaj Bharadiya committed 6 years ago

Commit c5936421 parent e437232115 files · +298 −298Browse files

Showing the changes to include/linux (3 of 115 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 {

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t