Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

selftests: forwarding: lib: rewrite processing of command line arguments

The piece of code which processes the command line arguments and
populates NETIFS based on them is really unobvious. Rewrite it so that
the intention is clear and the code is easy to follow.

Suggested-by: Petr Machata <petrm@nvidia.com>
Signed-off-by: Ioana Ciornei <ioana.ciornei@nxp.com>
Reviewed-by: Petr Machata <petrm@nvidia.com>
Link: https://patch.msgid.link/20260407102058.867279-1-ioana.ciornei@nxp.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>

authored by

Ioana Ciornei and committed by
Jakub Kicinski
fff75dba 686a7587

+11 -10
+11 -10
tools/testing/selftests/net/forwarding/lib.sh
··· 467 467 TARGETS[$remote_netif]="$REMOTE_TYPE:$REMOTE_ARGS" 468 468 else 469 469 count=0 470 + # Prime NETIFS from the command line, but retain if none given. 471 + if [[ $# -gt 0 ]]; then 472 + unset NETIFS 473 + declare -A NETIFS 470 474 471 - while [[ $# -gt 0 ]]; do 472 - if [[ "$count" -eq "0" ]]; then 473 - unset NETIFS 474 - declare -A NETIFS 475 - fi 476 - count=$((count + 1)) 477 - NETIFS[p$count]="$1" 478 - TARGETS[$1]="local:" 479 - shift 480 - done 475 + while [[ $# -gt 0 ]]; do 476 + count=$((count + 1)) 477 + NETIFS[p$count]="$1" 478 + TARGETS[$1]="local:" 479 + shift 480 + done 481 + fi 481 482 fi 482 483 483 484 ##############################################################################