Re: [PATCH bpf-next 16/17] selftests/bpf: add iterators tests

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

 



On Sat, Mar 4, 2023 at 1:09 PM Jiri Olsa <olsajiri@xxxxxxxxx> wrote:
>
> On Thu, Mar 02, 2023 at 03:50:14PM -0800, Andrii Nakryiko wrote:
>
> SNIP
>
> > +
> > +SEC("raw_tp")
> > +__success
> > +int iter_pass_iter_ptr_to_subprog(const void *ctx)
> > +{
> > +     int arr1[16], arr2[32];
> > +     struct bpf_iter it;
> > +     int n, sum1, sum2;
> > +
> > +     MY_PID_GUARD();
> > +
> > +     /* fill arr1 */
> > +     n = ARRAY_SIZE(arr1);
> > +     bpf_iter_num_new(&it, 0, n);
> > +     fill(&it, arr1, n, 2);
> > +     bpf_iter_num_destroy(&it);
> > +
> > +     /* fill arr2 */
> > +     n = ARRAY_SIZE(arr2);
> > +     bpf_iter_num_new(&it, 0, n);
> > +     fill(&it, arr2, n, 10);
> > +     bpf_iter_num_destroy(&it);
> > +
> > +     /* sum arr1 */
> > +     n = ARRAY_SIZE(arr1);
> > +     bpf_iter_num_new(&it, 0, n);
> > +     sum1 = sum(&it, arr1, n);
> > +     bpf_iter_num_destroy(&it);
> > +
> > +     /* sum arr2 */
> > +     n = ARRAY_SIZE(arr2);
> > +     bpf_iter_num_new(&it, 0, n);
> > +     sum1 = sum(&it, arr2, n);

this should have been sum2, not sum1, mechanical mistake

> > +     bpf_iter_num_destroy(&it);
> > +
> > +     bpf_printk("sum1=%d, sum2=%d", sum1, sum2);
>
> got to remove this to compile it, debug leftover?

nope, sum1->sum2 typo, which wasn't caught because Dave's patch to
error out on uninitialized variable reads landed a bit later

I'll fix this in v2, of course.


>
> jirka
>
> > +
> > +     return 0;
> > +}
> > +
> > +char _license[] SEC("license") = "GPL";
>
> SNIP




[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