[libvirt] [PATCH] vsh: Fix warnings in command line completer
Jiri Denemark
jdenemar at redhat.com
Wed Oct 5 15:35:53 UTC 2016
On Wed, Oct 05, 2016 at 16:07:09 +0200, Martin Kletzander wrote:
> On Wed, Oct 05, 2016 at 09:26:43AM +0200, Jiri Denemark wrote:
> >@@ -2648,7 +2647,7 @@ vshReadlineParse(const char *text, int state)
> > static vshCommandParser parser, sanitizer;
> > vshCommandToken tk;
> > static const vshCmdDef *cmd;
> >- const vshCmdOptDef *opt;
> >+ const vshCmdOptDef *opt = NULL;
>
> Always a good thing to do, you can't broke something that worked by
> initialization. And it's nicer. Even though Peter^Wsome people would
> argue that it's pointless, especially for ancient and weird compilers
> (i.e. even slightly different compiler version that they're running or
> with one different setting). But looking at the function it's easy to
> dereference that opt lines below in that function. Same way cmd_exists
> can be used without initialization and I believe half of those hundred
> variables too.
Well, about half of the variables in there are *static*, which means
they are initialized. Sure, there are legit uses of static variables in
functions and it may even be this case, I don't know, but I know having
so many of them in a single function is just not OK.
> Basically, I'm trying to say "ACK, you were right, I'm running away too
> now!", which translates to "ACK" in tl;dr language.
Thanks, I pushed the patch.
Jirka
More information about the libvir-list
mailing list