]> git.ipfire.org Git - thirdparty/libvirt.git/commit
vsh: Accept NULL @list in vshCompleterFilter()
authorMichal Privoznik <mprivozn@redhat.com>
Tue, 2 Feb 2021 09:39:19 +0000 (10:39 +0100)
committerMichal Privoznik <mprivozn@redhat.com>
Wed, 10 Feb 2021 10:51:59 +0000 (11:51 +0100)
commit6ba61373b7a20096e8d37af6f7c0871068742946
tree3748bc22171199fefb85fbdf1da482c351db9f90
parent268f16293c480919b34e53d102ae0751385e2c31
vsh: Accept NULL @list in vshCompleterFilter()

The aim of vshCompleterFilter() is to take a string list and a
prefix and remove all strings from the list that don't have the
desired prefix. The function is used to filter out those strings
returned by a completer callback that don't correspond with
user's (partial) input. For instance, domain name completer
virshDomainNameCompleter() returns all domain names and then
vshCompleterFilter() refines the list so that only domains with
correct prefix of their name are offered to user. This was a
design choice - it allows us to have shorter completers as they
do not have to copy the list filtering over and over.

Having said all of that, it may happen that a completer does not
return anything (e.g. there is no domain in requested state,
virsh is not connected and thus completer exited early, etc.). In
that case, the string list is NULL and vshCompleterFilter() can
simply return early.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Jonathon Jongsma <jjongsma@redhat.com>
tools/vsh.c