Re: [PATCH bpf-next v4 06/24] bpf: Refactor kptr_off_tab into btf_record

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, Nov 04, 2022 at 12:39:55AM +0530, Kumar Kartikeya Dwivedi wrote:
> -
> -	for (i = 0; i < nr_off; i++) {
> +	rec->cnt = 0;
> +	for (i = 0; i < cnt; i++) {
>  		const struct btf_type *t;
>  		s32 id;
>  
> @@ -3500,28 +3499,24 @@ struct bpf_map_value_off *btf_parse_kptrs(const struct btf *btf,
>  				ret = -EINVAL;
>  				goto end_mod;
>  			}
> -			tab->off[i].kptr.dtor = (void *)addr;
> +			rec->fields[i].kptr.dtor = (void *)addr;
>  		}
>  
> -		tab->off[i].offset = info_arr[i].off;
> -		tab->off[i].type = info_arr[i].type;
> -		tab->off[i].kptr.btf_id = id;
> -		tab->off[i].kptr.btf = kernel_btf;
> -		tab->off[i].kptr.module = mod;
> +		rec->fields[i].offset = info_arr[i].off;
> +		rec->fields[i].type = info_arr[i].type;
> +		rec->fields[i].kptr.btf_id = id;
> +		rec->fields[i].kptr.btf = kernel_btf;
> +		rec->fields[i].kptr.module = mod;
> +		rec->cnt++;
>  	}
> -	tab->nr_off = nr_off;
> -	return tab;
> +	rec->cnt = cnt;
> +	return rec;

This is weird. You also undo this assignment in the next patch.
What is the point of rec->cnt = 0;
followed by rec->cnt++
just to be overwritten with rec->cnt = cnt;
??



[Index of Archives]     [Linux Samsung SoC]     [Linux Rockchip SoC]     [Linux Actions SoC]     [Linux for Synopsys ARC Processors]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]


  Powered by Linux