selftests/bpf: Remove casting by introduce local variable
Let us use a local variable in nsswitchthread(), so we can remove a lot of casting for better readability. Signed-off-by: Björn Töpel <bjorn.topel@intel.com> Signed-off-by: Daniel Borkmann <daniel@iogearbox.net> Link: https://lore.kernel.org/bpf/20210122154725.22140-7-bjorn.topel@gmail.com
This commit is contained in:
parent
8a9cba7ea8
commit
0b50bd48cf
|
@ -382,21 +382,19 @@ static bool switch_namespace(int idx)
|
|||
|
||||
static void *nsswitchthread(void *args)
|
||||
{
|
||||
if (switch_namespace(((struct targs *)args)->idx)) {
|
||||
ifdict[((struct targs *)args)->idx]->ifindex =
|
||||
if_nametoindex(ifdict[((struct targs *)args)->idx]->ifname);
|
||||
if (!ifdict[((struct targs *)args)->idx]->ifindex) {
|
||||
ksft_test_result_fail
|
||||
("ERROR: [%s] interface \"%s\" does not exist\n",
|
||||
__func__, ifdict[((struct targs *)args)->idx]->ifname);
|
||||
((struct targs *)args)->retptr = false;
|
||||
struct targs *targs = args;
|
||||
|
||||
targs->retptr = false;
|
||||
|
||||
if (switch_namespace(targs->idx)) {
|
||||
ifdict[targs->idx]->ifindex = if_nametoindex(ifdict[targs->idx]->ifname);
|
||||
if (!ifdict[targs->idx]->ifindex) {
|
||||
ksft_test_result_fail("ERROR: [%s] interface \"%s\" does not exist\n",
|
||||
__func__, ifdict[targs->idx]->ifname);
|
||||
} else {
|
||||
ksft_print_msg("Interface found: %s\n",
|
||||
ifdict[((struct targs *)args)->idx]->ifname);
|
||||
((struct targs *)args)->retptr = true;
|
||||
ksft_print_msg("Interface found: %s\n", ifdict[targs->idx]->ifname);
|
||||
targs->retptr = true;
|
||||
}
|
||||
} else {
|
||||
((struct targs *)args)->retptr = false;
|
||||
}
|
||||
pthread_exit(NULL);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue