[PATCH 3/3] virsh: Error out if VSH_OT_STRING option has VSH_OFLAG_REQ flag

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Recent commit 12bd207e217f3c5dc2272a5ea943b81067bd8034 fixed few
VSH_OT_STRING options that should've been VSH_OT_DATA.  That lead me to
this commit that enforces people to check that newly added options have
proper type.  Thanks to virsh erroring out with error message, this will
immediately show up in 'make check' thanks to our virsh-synopsis test.

Signed-off-by: Martin Kletzander <mkletzan@xxxxxxxxxx>
---
 tools/virsh.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/tools/virsh.c b/tools/virsh.c
index 41893bb..e10b3de 100644
--- a/tools/virsh.c
+++ b/tools/virsh.c
@@ -1386,6 +1386,12 @@ vshCmddefHelp(vshControl *ctl, const char *cmdname)
                     break;
                 case VSH_OT_STRING:
                     /* OT_STRING should never be VSH_OFLAG_REQ */
+                    if (opt->flags & VSH_OFLAG_REQ) {
+                        vshError(ctl,
+                                 _("internal error: bad options in command: '%s'"),
+                                 def->name);
+                        return false;
+                    }
                     snprintf(buf, sizeof(buf), _("--%s <string>"), opt->name);
                     break;
                 case VSH_OT_DATA:
-- 
2.1.3

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]