bpf: Don't use idx variable when registering kfunc dtors
authorDavid Vernet <void@manifault.com>
Wed, 23 Nov 2022 13:52:53 +0000 (07:52 -0600)
committerAlexei Starovoitov <ast@kernel.org>
Wed, 23 Nov 2022 19:58:34 +0000 (11:58 -0800)
commit2fcc6081a7bf8f7f531cffdc58b630b822e700a1
tree667483bd95315d4527abcbfd56456fbb765d6283
parent8a2162a9227dda936a21fe72014a9931a3853a7b
bpf: Don't use idx variable when registering kfunc dtors

In commit fda01efc6160 ("bpf: Enable cgroups to be used as kptrs"), I
added an 'int idx' variable to kfunc_init() which was meant to
dynamically set the index of the btf id entries of the
'generic_dtor_ids' array. This was done to make the code slightly less
brittle as the struct cgroup * kptr kfuncs such as bpf_cgroup_aquire()
are compiled out if CONFIG_CGROUPS is not defined. This, however, causes
an lkp build warning:

>> kernel/bpf/helpers.c:2005:40: warning: multiple unsequenced
   modifications to 'idx' [-Wunsequenced]
.btf_id       = generic_dtor_ids[idx++],

Fix the warning by just hard-coding the indices.

Fixes: fda01efc6160 ("bpf: Enable cgroups to be used as kptrs")
Reported-by: kernel test robot <lkp@intel.com>
Signed-off-by: David Vernet <void@manifault.com>
Acked-by: Yonghong Song <yhs@fb.com>
Link: https://lore.kernel.org/r/20221123135253.637525-1-void@manifault.com
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
kernel/bpf/helpers.c