Skip to content

Commit

Permalink
bpftool: Clean up _bpftool_once_attr() calls in bash completion
Browse files Browse the repository at this point in the history
In bpftool's bash completion file, function _bpftool_once_attr() is able
to process multiple arguments. There are a few locations where this
function is called multiple times in a row, each time for a single
argument; let's pass all arguments instead to minimize the number of
function calls required for the completion.

Signed-off-by: Quentin Monnet <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Alexei Starovoitov <[email protected]>
  • Loading branch information
qmonnet authored and Alexei Starovoitov committed Apr 6, 2023
1 parent 7483a7a commit 7319296
Showing 1 changed file with 3 additions and 13 deletions.
16 changes: 3 additions & 13 deletions tools/bpf/bpftool/bash-completion/bpftool
Original file line number Diff line number Diff line change
Expand Up @@ -508,10 +508,7 @@ _bpftool()
;;
*)
COMPREPLY=( $( compgen -W "map" -- "$cur" ) )
_bpftool_once_attr 'type'
_bpftool_once_attr 'dev'
_bpftool_once_attr 'pinmaps'
_bpftool_once_attr 'autoattach'
_bpftool_once_attr 'type dev pinmaps autoattach'
return 0
;;
esac
Expand Down Expand Up @@ -736,16 +733,10 @@ _bpftool()
esac
;;
*)
_bpftool_once_attr 'type'
_bpftool_once_attr 'key'
_bpftool_once_attr 'value'
_bpftool_once_attr 'entries'
_bpftool_once_attr 'name'
_bpftool_once_attr 'flags'
_bpftool_once_attr 'type key value entries name flags dev'
if _bpftool_search_list 'array_of_maps' 'hash_of_maps'; then
_bpftool_once_attr 'inner_map'
fi
_bpftool_once_attr 'dev'
return 0
;;
esac
Expand Down Expand Up @@ -886,8 +877,7 @@ _bpftool()
return 0
;;
*)
_bpftool_once_attr 'cpu'
_bpftool_once_attr 'index'
_bpftool_once_attr 'cpu index'
return 0
;;
esac
Expand Down

0 comments on commit 7319296

Please sign in to comment.