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 Signed-off-by: Pankaj Bharadiya <pankaj.laxminarayan.bharadiya@intel.com> Link: https://lore.kernel.org/r/20190924105839.110713-3-pankaj.laxminarayan.bharadiya@intel.com Co-developed-by: Kees Cook <keescook@chromium.org> Signed-off-by: Kees Cook <keescook@chromium.org> Acked-by: David Miller <davem@davemloft.net> # for net
This commit is contained in:

committed by
Kees Cook

parent
e43723292d
commit
c593642c8b
@@ -2652,17 +2652,17 @@ static int mem_ldx_skb(struct nfp_prog *nfp_prog, struct nfp_insn_meta *meta,
|
||||
|
||||
switch (meta->insn.off) {
|
||||
case offsetof(struct __sk_buff, len):
|
||||
if (size != FIELD_SIZEOF(struct __sk_buff, len))
|
||||
if (size != sizeof_field(struct __sk_buff, len))
|
||||
return -EOPNOTSUPP;
|
||||
wrp_mov(nfp_prog, dst, plen_reg(nfp_prog));
|
||||
break;
|
||||
case offsetof(struct __sk_buff, data):
|
||||
if (size != FIELD_SIZEOF(struct __sk_buff, data))
|
||||
if (size != sizeof_field(struct __sk_buff, data))
|
||||
return -EOPNOTSUPP;
|
||||
wrp_mov(nfp_prog, dst, pptr_reg(nfp_prog));
|
||||
break;
|
||||
case offsetof(struct __sk_buff, data_end):
|
||||
if (size != FIELD_SIZEOF(struct __sk_buff, data_end))
|
||||
if (size != sizeof_field(struct __sk_buff, data_end))
|
||||
return -EOPNOTSUPP;
|
||||
emit_alu(nfp_prog, dst,
|
||||
plen_reg(nfp_prog), ALU_OP_ADD, pptr_reg(nfp_prog));
|
||||
@@ -2683,12 +2683,12 @@ static int mem_ldx_xdp(struct nfp_prog *nfp_prog, struct nfp_insn_meta *meta,
|
||||
|
||||
switch (meta->insn.off) {
|
||||
case offsetof(struct xdp_md, data):
|
||||
if (size != FIELD_SIZEOF(struct xdp_md, data))
|
||||
if (size != sizeof_field(struct xdp_md, data))
|
||||
return -EOPNOTSUPP;
|
||||
wrp_mov(nfp_prog, dst, pptr_reg(nfp_prog));
|
||||
break;
|
||||
case offsetof(struct xdp_md, data_end):
|
||||
if (size != FIELD_SIZEOF(struct xdp_md, data_end))
|
||||
if (size != sizeof_field(struct xdp_md, data_end))
|
||||
return -EOPNOTSUPP;
|
||||
emit_alu(nfp_prog, dst,
|
||||
plen_reg(nfp_prog), ALU_OP_ADD, pptr_reg(nfp_prog));
|
||||
|
@@ -15,7 +15,7 @@
|
||||
|
||||
const struct rhashtable_params nfp_bpf_maps_neutral_params = {
|
||||
.nelem_hint = 4,
|
||||
.key_len = FIELD_SIZEOF(struct bpf_map, id),
|
||||
.key_len = sizeof_field(struct bpf_map, id),
|
||||
.key_offset = offsetof(struct nfp_bpf_neutral_map, map_id),
|
||||
.head_offset = offsetof(struct nfp_bpf_neutral_map, l),
|
||||
.automatic_shrinking = true,
|
||||
|
@@ -374,7 +374,7 @@ nfp_bpf_map_alloc(struct nfp_app_bpf *bpf, struct bpf_offloaded_map *offmap)
|
||||
}
|
||||
|
||||
use_map_size = DIV_ROUND_UP(offmap->map.value_size, 4) *
|
||||
FIELD_SIZEOF(struct nfp_bpf_map, use_map[0]);
|
||||
sizeof_field(struct nfp_bpf_map, use_map[0]);
|
||||
|
||||
nfp_map = kzalloc(sizeof(*nfp_map) + use_map_size, GFP_USER);
|
||||
if (!nfp_map)
|
||||
|
@@ -24,7 +24,7 @@ struct nfp_app;
|
||||
#define NFP_FL_STAT_ID_MU_NUM GENMASK(31, 22)
|
||||
#define NFP_FL_STAT_ID_STAT GENMASK(21, 0)
|
||||
|
||||
#define NFP_FL_STATS_ELEM_RS FIELD_SIZEOF(struct nfp_fl_stats_id, \
|
||||
#define NFP_FL_STATS_ELEM_RS sizeof_field(struct nfp_fl_stats_id, \
|
||||
init_unalloc)
|
||||
#define NFP_FLOWER_MASK_ENTRY_RS 256
|
||||
#define NFP_FLOWER_MASK_ELEMENT_RS 1
|
||||
|
Reference in New Issue
Block a user