Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

MIPS: BPF: Use sizeof_field() instead of FIELD_SIZEOF()

The FIELD_SIZEOF() macro was redundant, and is being removed from the
kernel. Since commit c593642c8be0 ("treewide: Use sizeof_field() macro")
this is one of the last users of the old macro, so replace it.

Signed-off-by: Kees Cook <keescook@chromium.org>
Signed-off-by: Paul Burton <paulburton@kernel.org>
Cc: linux-kernel@vger.kernel.org
Cc: linux-mips@vger.kernel.org

authored by

Kees Cook and committed by
Paul Burton
cc43928b ecb98379

+9 -9
+9 -9
arch/mips/net/bpf_jit.c
··· 689 689 emit_load_imm(r_A, k, ctx); 690 690 break; 691 691 case BPF_LD | BPF_W | BPF_LEN: 692 - BUILD_BUG_ON(FIELD_SIZEOF(struct sk_buff, len) != 4); 692 + BUILD_BUG_ON(sizeof_field(struct sk_buff, len) != 4); 693 693 /* A <- len ==> lw r_A, offset(skb) */ 694 694 ctx->flags |= SEEN_SKB | SEEN_A; 695 695 off = offsetof(struct sk_buff, len); ··· 1093 1093 case BPF_ANC | SKF_AD_PROTOCOL: 1094 1094 /* A = ntohs(skb->protocol */ 1095 1095 ctx->flags |= SEEN_SKB | SEEN_OFF | SEEN_A; 1096 - BUILD_BUG_ON(FIELD_SIZEOF(struct sk_buff, 1096 + BUILD_BUG_ON(sizeof_field(struct sk_buff, 1097 1097 protocol) != 2); 1098 1098 off = offsetof(struct sk_buff, protocol); 1099 1099 emit_half_load(r_A, r_skb, off, ctx); ··· 1118 1118 case BPF_ANC | SKF_AD_CPU: 1119 1119 ctx->flags |= SEEN_A | SEEN_OFF; 1120 1120 /* A = current_thread_info()->cpu */ 1121 - BUILD_BUG_ON(FIELD_SIZEOF(struct thread_info, 1121 + BUILD_BUG_ON(sizeof_field(struct thread_info, 1122 1122 cpu) != 4); 1123 1123 off = offsetof(struct thread_info, cpu); 1124 1124 /* $28/gp points to the thread_info struct */ ··· 1137 1137 b_imm(prog->len, ctx), ctx); 1138 1138 emit_reg_move(r_ret, r_zero, ctx); 1139 1139 if (code == (BPF_ANC | SKF_AD_IFINDEX)) { 1140 - BUILD_BUG_ON(FIELD_SIZEOF(struct net_device, ifindex) != 4); 1140 + BUILD_BUG_ON(sizeof_field(struct net_device, ifindex) != 4); 1141 1141 off = offsetof(struct net_device, ifindex); 1142 1142 emit_load(r_A, r_s0, off, ctx); 1143 1143 } else { /* (code == (BPF_ANC | SKF_AD_HATYPE) */ 1144 - BUILD_BUG_ON(FIELD_SIZEOF(struct net_device, type) != 2); 1144 + BUILD_BUG_ON(sizeof_field(struct net_device, type) != 2); 1145 1145 off = offsetof(struct net_device, type); 1146 1146 emit_half_load_unsigned(r_A, r_s0, off, ctx); 1147 1147 } 1148 1148 break; 1149 1149 case BPF_ANC | SKF_AD_MARK: 1150 1150 ctx->flags |= SEEN_SKB | SEEN_A; 1151 - BUILD_BUG_ON(FIELD_SIZEOF(struct sk_buff, mark) != 4); 1151 + BUILD_BUG_ON(sizeof_field(struct sk_buff, mark) != 4); 1152 1152 off = offsetof(struct sk_buff, mark); 1153 1153 emit_load(r_A, r_skb, off, ctx); 1154 1154 break; 1155 1155 case BPF_ANC | SKF_AD_RXHASH: 1156 1156 ctx->flags |= SEEN_SKB | SEEN_A; 1157 - BUILD_BUG_ON(FIELD_SIZEOF(struct sk_buff, hash) != 4); 1157 + BUILD_BUG_ON(sizeof_field(struct sk_buff, hash) != 4); 1158 1158 off = offsetof(struct sk_buff, hash); 1159 1159 emit_load(r_A, r_skb, off, ctx); 1160 1160 break; 1161 1161 case BPF_ANC | SKF_AD_VLAN_TAG: 1162 1162 ctx->flags |= SEEN_SKB | SEEN_A; 1163 - BUILD_BUG_ON(FIELD_SIZEOF(struct sk_buff, 1163 + BUILD_BUG_ON(sizeof_field(struct sk_buff, 1164 1164 vlan_tci) != 2); 1165 1165 off = offsetof(struct sk_buff, vlan_tci); 1166 1166 emit_half_load_unsigned(r_A, r_skb, off, ctx); ··· 1186 1186 break; 1187 1187 case BPF_ANC | SKF_AD_QUEUE: 1188 1188 ctx->flags |= SEEN_SKB | SEEN_A; 1189 - BUILD_BUG_ON(FIELD_SIZEOF(struct sk_buff, 1189 + BUILD_BUG_ON(sizeof_field(struct sk_buff, 1190 1190 queue_mapping) != 2); 1191 1191 BUILD_BUG_ON(offsetof(struct sk_buff, 1192 1192 queue_mapping) > 0xff);