]> xenbits.xensource.com Git - libvirt.git/commitdiff
vsh: Enforce checking for missing help string
authorErik Skultety <eskultet@redhat.com>
Mon, 19 Sep 2016 11:10:38 +0000 (13:10 +0200)
committerErik Skultety <eskultet@redhat.com>
Tue, 20 Sep 2016 13:05:31 +0000 (15:05 +0200)
The intention is to move vshCmddefCheckInternals out of vshCmddefOptParse to
our test suite. First step to do that is to enforce checking for an existing
help string (that also means it's non-empty) in a command because a command
without a help is not much of a use.

Signed-off-by: Erik Skultety <eskultet@redhat.com>
tools/vsh.c

index 4ee472c3a1d0d96b34a72686aaa33ffa9f70222b..f3b3fca61ad2ef84411a81fded11160424f0d984 100644 (file)
@@ -328,6 +328,11 @@ static int
 vshCmddefCheckInternals(const vshCmdDef *cmd)
 {
     size_t i;
+    const char *help = NULL;
+
+    /* Each command has to provide a non-empty help string. */
+    if (!(help = vshCmddefGetInfo(cmd, "help")) || !*help)
+        return -1;
 
     if (!cmd->opts)
         return 0;