2024-01-16 06:19 UTC+0000 ~ Tiezhu Yang <yangtiezhu@xxxxxxxxxxx> > There exists the following warning when building bpftool: > > CC prog.o > prog.c: In function ‘profile_open_perf_events’: > prog.c:2301:24: warning: ‘calloc’ sizes specified with ‘sizeof’ in the earlier argument and not in the later argument [-Wcalloc-transposed-args] > 2301 | sizeof(int), obj->rodata->num_cpu * obj->rodata->num_metric); > | ^~~ > prog.c:2301:24: note: earlier argument should specify number of elements, later size of each element > > Tested with the latest upstream GCC which contains a new warning option > -Wcalloc-transposed-args. The first argument to calloc is documented to > be number of elements in array, while the second argument is size of each > element, just switch the first and second arguments of calloc() to silence > the build warning, compile tested only. > > Fixes: 47c09d6a9f67 ("bpftool: Introduce "prog profile" command") > Signed-off-by: Tiezhu Yang <yangtiezhu@xxxxxxxxxxx> Reviewed-by: Quentin Monnet <quentin@xxxxxxxxxxxxx> Thank you!