[libvirt] [PATCH] vsh: Fix warnings in command line completer

Michal Privoznik mprivozn at redhat.com
Thu Oct 6 07:57:58 UTC 2016


On 05.10.2016 09:26, Jiri Denemark wrote:
> GCC complained that
> 
> vsh.c: In function 'vshReadlineOptionsGenerator':
> vsh.c:2622:29: warning: unused variable 'opt' [-Wunused-variable]
>          const vshCmdOptDef *opt = &cmd->opts[list_index];
>                              ^
> vsh.c: In function 'vshReadlineParse':
> vsh.c:2830:44: warning: 'opt' may be used uninitialized in this function
> [-Wmaybe-uninitialized]
>              completed_list = opt->completer(autoCompleteOpaque,
> 
> Signed-off-by: Jiri Denemark <jdenemar at redhat.com>
> ---
> 
> Notes:
>     I'm not very fond of the second hunk, but the completer is such
>     a horrible piece of code I couldn't believe it was pushed. I just
>     made the easiest fix and ran away from the code screaming.

Well, this area has always been a mess. And I think it is mostly because
of how readline API works. The completer is called multiple times and we
have to do a lot in it in order to provide all the completions.
Having said that, I'm not sure what can be done here to improve the code
apart from rewriting it completely from scratch (or switching to a
different library, e.g. libedit).

Michal




More information about the libvir-list mailing list