Completion in virsh is enabled when readline is available. In order to
fix build when it's not available, do the following:
* Unconditionally add virsh-completer.[ch] and
virt-admin-completer.[ch] to the build, and provide stub functions
for when readline is not available. This way virsh builds without
complaining about missing symbols used for 'completer' in
vshCmdOptDef;
* In cmdComplete(), mark unused arguments when there's no readline
with ATTRIBUTE_UNUSED.
---
tools/Makefile.am | 20 ++------------------
tools/virsh-completer.c | 23 +++++++++++++++++++++++
tools/virt-admin-completer.c | 12 ++++++++++++
tools/vsh.c | 2 +-
4 files changed, 38 insertions(+), 19 deletions(-)
diff --git a/tools/Makefile.am b/tools/Makefile.am
index 48125f516..8cb66db7d 100644
--- a/tools/Makefile.am
+++ b/tools/Makefile.am
@@ -229,17 +229,9 @@ virsh_SOURCES = \
virsh-snapshot.c virsh-snapshot.h \
virsh-util.c virsh-util.h \
virsh-volume.c virsh-volume.h \
+ virsh-completer.c virsh-completer.h \
$(NULL)
-VIRSH_COMPLETER = \
- virsh-completer.c virsh-completer.h
-
-if WITH_READLINE
-virsh_SOURCES += $(VIRSH_COMPLETER)
-else ! WITH_READLINE
-EXTRA_DIST += $(VIRSH_COMPLETER)
-endif ! WITH_READLINE
-
virsh_LDFLAGS = \
$(AM_LDFLAGS) \
$(PIE_LDFLAGS) \
@@ -256,17 +248,9 @@ virsh_CFLAGS = \
virt_admin_SOURCES = \
virt-admin.c virt-admin.h \
+ virt-admin-completer.c virt-admin-completer.h \
$(NULL)
-VIRT_ADMIN_COMPLETER = \
- virt-admin-completer.c virt-admin-completer.h
-
-if WITH_READLINE
-virt_admin_SOURCES += $(VIRT_ADMIN_COMPLETER)
-else ! WITH_READLINE
-EXTRA_DIST += $(VIRT_ADMIN_COMPLETER)
-endif ! WITH_READLINE
-
virt_admin_LDFLAGS = \
$(AM_LDFLAGS) \
$(COVERAGE_LDFLAGS) \
diff --git a/tools/virsh-completer.c b/tools/virsh-completer.c
index 48dd9fbc2..fd92ee8db 100644
--- a/tools/virsh-completer.c
+++ b/tools/virsh-completer.c
@@ -31,6 +31,7 @@
#include "virxml.h"
+#ifdef WITH_READLINE
char **
virshDomainNameCompleter(vshControl *ctl,
const vshCmd *cmd ATTRIBUTE_UNUSED,
@@ -147,3 +148,25 @@ virshDomainInterfaceCompleter(vshControl *ctl,
virStringListFree(ret);
return NULL;
}
+#else
+char **
+virshDomainNameCompleter(vshControl *ctl ATTRIBUTE_UNUSED,
+ const vshCmd *cmd ATTRIBUTE_UNUSED,
+ unsigned int flags)
+{
+ virCheckFlags(-1, NULL);
+
+ return NULL;
+}
+
+
+char **
+virshDomainInterfaceCompleter(vshControl *ctl ATTRIBUTE_UNUSED,
+ const vshCmd *cmd ATTRIBUTE_UNUSED,
+ unsigned int flags)
+{
+ virCheckFlags(-1, NULL);
+
+ return NULL;
+}
+#endif /* WITH_READLINE */
diff --git a/tools/virt-admin-completer.c b/tools/virt-admin-completer.c
index 2cd471f32..a432f0977 100644
--- a/tools/virt-admin-completer.c
+++ b/tools/virt-admin-completer.c
@@ -30,6 +30,7 @@
#include "virstring.h"
+#ifdef WITH_READLINE
char **
vshAdmServerCompleter(vshControl *ctl,
const vshCmd *cmd ATTRIBUTE_UNUSED,
@@ -74,3 +75,14 @@ vshAdmServerCompleter(vshControl *ctl,
VIR_FREE(ret);
return ret;
}
+#else
+char **
+vshAdmServerCompleter(vshControl *ctl ATTRIBUTE_UNUSED,
+ const vshCmd *cmd ATTRIBUTE_UNUSED,
+ unsigned int flags)
+{
+ virCheckFlags(-1, NULL);
+
+ return NULL;
+}
+#endif /* WITH_READLINE */
diff --git a/tools/vsh.c b/tools/vsh.c
index 4426c08d6..59c8a440e 100644
--- a/tools/vsh.c
+++ b/tools/vsh.c
@@ -3500,7 +3500,7 @@ const vshCmdInfo info_complete[] = {
};
bool
-cmdComplete(vshControl *ctl, const vshCmd *cmd)
+cmdComplete(vshControl *ctl ATTRIBUTE_UNUSED, const vshCmd *cmd ATTRIBUTE_UNUSED)
{
bool ret = false;
#ifdef WITH_READLINE
--
2.15.1