Commit 0b50bd48 authored by Björn Töpel's avatar Björn Töpel Committed by Daniel Borkmann

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: default avatarBjörn Töpel <bjorn.topel@intel.com>
Signed-off-by: default avatarDaniel Borkmann <daniel@iogearbox.net>
Link: https://lore.kernel.org/bpf/20210122154725.22140-7-bjorn.topel@gmail.com
parent 8a9cba7e
...@@ -382,21 +382,19 @@ static bool switch_namespace(int idx) ...@@ -382,21 +382,19 @@ static bool switch_namespace(int idx)
static void *nsswitchthread(void *args) static void *nsswitchthread(void *args)
{ {
if (switch_namespace(((struct targs *)args)->idx)) { struct targs *targs = args;
ifdict[((struct targs *)args)->idx]->ifindex =
if_nametoindex(ifdict[((struct targs *)args)->idx]->ifname); targs->retptr = false;
if (!ifdict[((struct targs *)args)->idx]->ifindex) {
ksft_test_result_fail if (switch_namespace(targs->idx)) {
("ERROR: [%s] interface \"%s\" does not exist\n", ifdict[targs->idx]->ifindex = if_nametoindex(ifdict[targs->idx]->ifname);
__func__, ifdict[((struct targs *)args)->idx]->ifname); if (!ifdict[targs->idx]->ifindex) {
((struct targs *)args)->retptr = false; ksft_test_result_fail("ERROR: [%s] interface \"%s\" does not exist\n",
__func__, ifdict[targs->idx]->ifname);
} else { } else {
ksft_print_msg("Interface found: %s\n", ksft_print_msg("Interface found: %s\n", ifdict[targs->idx]->ifname);
ifdict[((struct targs *)args)->idx]->ifname); targs->retptr = true;
((struct targs *)args)->retptr = true;
} }
} else {
((struct targs *)args)->retptr = false;
} }
pthread_exit(NULL); pthread_exit(NULL);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment